简体   繁体   English

Javascript回发事件

[英]Javascript Postback Event

I have a user control that is supposed to write a value to a hidden field every time the consuming page posts back. 我有一个用户控件,该控件应该在每次使用页面回发时将值写入隐藏字段。

Is there any way to trap the postback event at the page level? 有什么办法可以在页面级别捕获回发事件? Perhaps I can wire up an event so that I can run a function every time the page posts back. 也许我可以关联一个事件,以便每次页面回发时都可以运行一个函数。

Thanks. 谢谢。

You can determine within Page_Load whether an operation is the result of a postback (i'm assuming this is what you mean by "trapping the postback event at the page level". 您可以在Page_Load中确定某个操作是否是回发的结果(我假设这是通过“在页面级别捕获回发事件”来表示的)。

protected void Page_Load(object sender, EventArgs e)
{
    if (Page.IsPostback)
    {
       //Your code here.

    }
}

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

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