Latest

6/recent/ticker-posts

Header Ads Widget

Show message and redirect to another page and on same page in asp.net c#

In this artical we learn how to show message and redirect to another page after performing some task in asp.net C#




//simply we added this at c# code side

 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('write alert message here which you want to shown.');window.location ='page url where you want to redirect after message';", true);



//by using below example you can show message and redirect to same page after performing any action

string redirecturl = Page.Request.Url.ToString();

//if you have query string in url then add
var nameValues = HttpUtility.ParseQueryString(Request.QueryString.ToString());
if(nameValues!="" ){           
 redirecturl = redirecturl + "?" + nameValues;
}


 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('write alert message here which you want to shown.');window.location ='" + redirecturl + "';", true);

Post a Comment

0 Comments