在响应之前更新aspx页面上的标签.重定向

Update a label on aspx page before a Response.Redirect

本文关键字:标签 重定向 aspx 响应 更新      更新时间:2023-09-26

我有以下重定向,但在重定向之前需要将标签更改为"成功":

Response.Redirect(Url)

我试着输入false,然后更改标签。Text="成功"

还尝试保存类似的值

您需要的是一种在转换期间保存数据的方法。因此,第一次通过验证时,将值存储到Session变量中,但没有成功。

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

Label.Text = Session("label")

这是通过java脚本实现的唯一方法吗?

我会使用吗

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

或者,如果你想在用户按下你的消息框上的ok按钮时打开url,你也可以这样做

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

同样,正如Aristo在上面所说

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