asp.net – 哪个控件导致回发?
发布时间:2020-07-03 09:05:53  所属栏目:asp.Net  来源:互联网 
            导读:我有两个按钮: asp:Button ID=Button1 runat=server Text=Button /asp:Button ID=Button2 runat=server Text=Button / 如何在pageLoad确定这两个哪一个导致回发? 有一个简短的解决方案,因为我知道只有两个控件,可以导致这种回发? 您可以使用此方法来获取
                
                
                
            | 
                         我有两个按钮: <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:Button ID="Button2" runat="server" Text="Button" /> 如何在pageLoad确定这两个哪一个导致回发? 解决方法您可以使用此方法来获取导致回发的控件:/// <summary>
/// Retrieves the control that caused the postback.
/// </summary>
/// <param name="page"></param>
/// <returns></returns>
private Control GetControlThatCausedPostBack(Page page)
{
    //initialize a control and set it to null
    Control ctrl = null;
    //get the event target name and find the control
    string ctrlName = page.Request.Params.Get("__EVENTTARGET");
    if (!String.IsNullOrEmpty(ctrlName))
        ctrl = page.FindControl(ctrlName);
    //return the control to the calling method
    return ctrl;
}                        (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  
相关内容
- asp.net-mvc – 什么是应用程序洞察遥测(未配置)在做什么?
 - ASP.NET Core知多少(7):对重复编译说NO -- dotnet watch
 - asp.net 2.0中利用Ajax2.0实现JSON传送大量页面数据
 - .net – ELMAH对企业库异常处理块
 - asp.net-mvc – 在ASP.NET MVC中的LinkButton
 - asp.net – Html.Partial()跳过控制器动作
 - asp.net-mvc-3 – MVC 3 WebGrid – 可以进行内联编辑吗?
 - asp.net-mvc – ASP.NET MVC中的代码
 - asp.net-mvc – 在MVC Controller中访问GET参数
 - asp.net – Azure可以运行WPF吗?
 
推荐文章
            站长推荐
            - ASP.NET(AJAX+JSON)实现对象调用
 - asp.net-mvc – Asp .Net Core – 无法安装Micro
 - asp.net-mvc – ASP.NET MVC获取具有特定配置文件
 - MVC SessionStateAttribute不作为全局属性
 - asp.net-mvc – 在布局视图中获取当前的Applicat
 - 在使用ASP.NET会话时是否可以强制请求并发?
 - ASP.NET Webdeploy失败;项目中不存在AddSchedule
 - 端到ASP.NET MVC的推荐方法
 - 将ASP.NET身份与核心域模型分离 – 洋葱架构
 - asp.net-mvc – 如何在RegularExpression中忽略大
 
热点阅读
            