简体   繁体   中英

Update a label on aspx page before a Response.Redirect

I have the following redirect but need to change the label to say "Success" before the re-direct:

Response.Redirect(Url)

I've tried passing in false and then changing the label.Text = "Success"

Also tried saving a value like this

What you need is a way to save data during transition. So the first time the validation is passed store the values into Session variable without success.

Session ("label") = "Success
Response.Redirect(Url, False)


Label.Text = Session("label")

Is the only way to do this through a java script?

Would I use:

Page.ClientScript.RegisterClientScriptBlock
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anyKey", "<script>alert('Success'); window.open(" + url + ");</script>", false);

or if you want to open the url when user presses ok button on your message box, you can also do it like this

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anyKey", "<script>if(confirm('Success')) window.open(" + url + ");</script>", false);

also, as Aristo says above

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anyKey", "<script>$('#"+ lblYourLabel.ClientID +"').val('Success'); var t=setTimeout(function(){window.open(" + url + ");},3000);</script>", false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM