Click here to Skip to main content
Click here to Skip to main content

How to show the message and redirect to other page in ASP.NET

By , 20 Nov 2011
 
The below code snippet is used to show the message and redirect to other page:
 
 ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Access Denied. Please contact Administrator for access to this section.');location.href="/KB/tips/login.aspx";", true);
 
The below code snippet is used to show the message and redirect to other page with parameters:
 
ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Data updated successfully. You will now redirected to search page.');location.href="/KB/tips/somepage.aspx"?name=" + name + "&address=" + address + "&state=" + state + "';", true);
 
The below code snippet is used to show the message and redirect to other page with parameters based on user confirm:
 
ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "var r = confirm('Data updated successfully. You will now redirected to search page.'); if (r == true) var str= 'somepage.aspx?name=" + name + "&address=" + address + "&state=" + state + "'; location.href = str ;", true);

License

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

About the Author

mgrks
India India
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralNice Tip - Voted 4memberMatt U.23 Aug '12 - 4:55 
GeneralReason for my vote of 5 Good tipmemberPranit Kothari8 Jan '12 - 21:00 
GeneralReason for my vote of 3 Its a common sensememberdennis-ye1623 Nov '11 - 15:34 
GeneralReason for my vote of 5 thanks for the tip!memberbeginner201122 Nov '11 - 14:50 
GeneralReason for my vote of 5 Goodmemberiambics22 Nov '11 - 7:49 
GeneralReason for my vote of 5 Nice little trick, certainly could b...memberBrianBissell22 Nov '11 - 5:35 
GeneralReason for my vote of 5 Good onememberDorababu74321 Nov '11 - 2:28 
GeneralReason for my vote of 5 Helpful in my current project.memberVarun Sareen18 Nov '11 - 0:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 20 Nov 2011
Article Copyright 2011 by mgrks
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid