asp.net – 哪个控件导致回发?
发布时间:2020-12-15 18:50:06 所属栏目: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 – OpenID Connect:验证用户ID令牌或访问令牌的正
- asp.net-mvc – 如何测试MVC控制器的事件
- ASP.NET拒绝基于角色访问某些页面
- asp.net-mvc – 用于asp.net的rails样式数据库迁移?
- asp.net-mvc – 来自HttpRequestMessage内容的文件名
- asp.net-mvc – 通过使用EF 4.1 DBContext为SaveChanges分配
- 请帮助我了解ASP.NET控件的AutoPostBack属性
- asp.net – 无效的回发或回调参数.单击按钮时
- Asp.Net MVC EF各版本区别
- asp.net-mvc-3 – 将复选框绑定到MVC中的int数组/枚举
推荐文章
站长推荐
- asp.net-mvc – 如何在MVC3中托管Web服务?
- asp.net-mvc – 可以为多个部署转换MVC视图,例如
- asp.net-mvc – ASP.NET MVC FluentValidation P
- asp.net-mvc – Umbraco 7自定义cookie
- asp.net-mvc – EF 4.1 Code First:“非空值类型
- asp.net – System.Runtime.InteropServices.COM
- asp.net – 最佳实践:DataBound with loop vs R
- asp.net-mvc-3 – DotNetOpenAuth.Asp在MVC4应用
- 我可以在ASP.NET应用程序中禁用IP地址(或一系列地
- asp.net-mvc-2 – 实体框架4 CTP 4/CTP 5通用存储
热点阅读