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
Rate this:
Please Sign up or sign in to vote.
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
No Biography provided

Comments and Discussions

 
GeneralNice Tip - Voted 4 PinmemberMatt U.23-Aug-12 4:55 
GeneralReason for my vote of 5 Good tip PinmemberPranit Kothari8-Jan-12 21:00 
GeneralReason for my vote of 3 Its a common sense Pinmemberdennis-ye1623-Nov-11 15:34 
GeneralReason for my vote of 5 thanks for the tip! Pinmemberbeginner201122-Nov-11 14:50 
GeneralReason for my vote of 5 Good Pinmemberiambics22-Nov-11 7:49 
Reason for my vote of 5
Good
GeneralReason for my vote of 5 Nice little trick, certainly could b... PinmemberBrianBissell22-Nov-11 5:35 
GeneralReason for my vote of 5 Good one PinmemberDorababu74321-Nov-11 2:28 
GeneralReason for my vote of 5 Helpful in my current project. PinmemberVarun Sareen18-Nov-11 0:49 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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