Macnique
Macnique

Reputation: 1034

How to redirect to a different page from a javascript alert box in a .net application?

I have a web application where i am displaying an javascript alert box when user edits fields and clicks on the save button.Then i want to redirect the page to home page when user clicks "ok" on the javascript alert box ? I am using c# code

Type cstype = this.GetType();

ClientScriptManager cs = this.ClientScript;
if (!cs.IsStartupScriptRegistered(cstype, "AlertScript"))
{
    String csScriptText = "alert(' settings have been saved ');";
    cs.RegisterStartupScript(cstype, "TestScript", csScriptText, true);
}

Upvotes: 0

Views: 590

Answers (1)

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114377

.NET really has nothing to do with it since it all happens on the client via JavaScript.

String csScriptText = "alert(' settings have been saved ');document.location='http://.../newurl.htm'";

Upvotes: 3

Related Questions