强制回发

sha*_*ach 16 c# asp.net postback

有没有办法在代码中强制回发?

我希望强制从我的asp.net Web应用程序后面的c#代码中的方法引发回发.

mam*_*moo 9

在表单提交后触发回发,因此它与客户端操作有关...请查看此处的解释: ASP.NET - 是否可以从服务器代码触发回发?

这里是一个解决方案:http: //forums.asp.net/t/928411.aspx/1

  • 对于那些使用较新版本.NET的用户,你必须使用`Page.ClientScript.GetPostBackEventReference`,因为'this.GetPostBackEventReference(...)'已经过时了.也可能是`Page.ClientScript.RegisterStartupScript(...)`. (2认同)

liv*_*ove 8

您可以尝试重定向到同一页面.

Response.Redirect(Request.RawUrl);
Run Code Online (Sandbox Code Playgroud)


dev*_*ius 6

更简单:

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "DoPostBack", "__doPostBack(sender, e)", true);
Run Code Online (Sandbox Code Playgroud)