相关疑难解决方法(0)

获取ASP.NET控件,该控件在AJAX UpdatePanel中触发回发

与此问题相关:在回发时,如何检查哪个控件导致Page_Init事件中的回发

如果控件包装在ASP.NET AJAX UpdatePanel中,则变量"control"为空,因为它在AJAX PostBack之后具有不同的ID.是否有解决方案来获取在ASP.NET Ajax UpdatePanel中触发回发的控件?

public static string GetPostBackControlName( Page page ) {
        Control control = null;

        /**
         * First we will check the "__EVENTTARGET" because if the postback is made
         * by controls which used the _doPostBack function, it will be available in the Request.Form collection.
         */
        string ctrlname = page.Request.Params["__EVENTTARGET"];

        if ( !String.IsNullOrEmpty( ctrlname ) ) {
            control = page.FindControl( ctrlname );
        } else {
            /**
             * If __EVENTTARGER is null, the control is a …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-ajax

4
推荐指数
1
解决办法
6842
查看次数

标签 统计

asp.net ×1

asp.net-ajax ×1