javascript - Confirmation message from the ASP.NET code behind file -
i have login screen login.aspx after login want show confirmation message saying
"you being redirected demo page. want continue?",
if user clicked yes, need redirect them demo page. other wise redirect home page. how can this?
i want following...
protected void login_click(object sender, imageclickeventargs e) { //some validation , calculations.. scriptmanager.registerstartupscript(this, this.gettype(), "script", "confirm('you redirecting demo page ". want continue" ?');", true); //my doubt if(ok button clicked) { //redirect demo page } else { //redirect home page } }
you wont result of confirm on server side. can call javascript function registerstartupscript , put confirm dialog in function.
although can somehow send value of confirm on server side using postback of ajax call not see reason that.
code behind
scriptmanager.registerstartupscript(this, this.gettype(), "script", "redirectdecision();", true);
html
<script type="text/javascript"> function redirectdecision() { if(confirm('you redirecting demo page ". want continue" ?')) window.location = "http://www.yoururlfirst.com"; else window.location = "http://www.yoururlsecond.com"; } </script>
Comments
Post a Comment