Click here to Skip to main content
15,920,956 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using submit button on that i used confirmation box of javascript.

I set session timeout for 10 mins. after 10 mins it will redirect to login page. but when i click on submit button after 10 min it is opening confirmation box first and when i click ok option it is redirected to login page.

I want to redirect the page on submit button before the confirmation box open.


thanks
reach2sjs
Posted

1 solution

You can use ajax. Before confirmation box of javascript you can check the user session status by ajax. If the session is unavailable then you can redirect by javascript.

var J = jQuery.noConflict();

function IsLoginChecked() {
    return true;
    J.ajax({
        url: "Checker.aspx",
        type: "GET",
        dataType: 'html',
        data: {},
        success: function (data) {
            if(data=="false")
             window.location.href = "Login.aspx";
             else
             {
             return confirm('Are you sure to confirm?');
             }
            return false;
        },
        error: function () {
            return false;
        }
    });
}


Checker.aspx code

protected void Page_Load(object sender, EventArgs e)
    {
Response.Clear();
if(Session["User"] == null)
return false;
else
return true;
Response.End();
    }


add OnClientClick="return IsLoginChecked()==true?true:false;" to the button property.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900