简体   繁体   English

在Response.Redirect之前更新aspx页面上的标签

[英]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: 我具有以下重定向,但需要在重定向之前将标签更改为“ Success”:

Response.Redirect(Url)

I've tried passing in false and then changing the label.Text = "Success" 我尝试传递false,然后更改label.Text =“成功”

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变量中不会成功。

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


Label.Text = Session("label")

Is the only way to do this through a java script? 是通过Java脚本执行此操作的唯一方法吗?

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 同样,正如亚里士多德(Aristo)所说

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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