WebUserControl简单事件定义
2008-07-10 09:50
316 查看
使用WebUserControl来创建控件的时候,事件的定义方法:
控件:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SuperControl.ascx.cs" Inherits="SuperControl" %>
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnTextChanged="DropDownList1_TextChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:DropDownList>
</div>
后台:
public partial class SuperControl : System.Web.UI.UserControl
{
public event EventHandler TextChanged;//事件委托
protected void DropDownList1_TextChanged(object sender, EventArgs e)
{
if (TextChanged != null)
{
TextChanged(this, e);
}
}
}
在页面中的使用方法:
<SuperControl:SupperControl ID="myControl" runat="server" OnTextChanged="myControl_OnTextChanged"/>
控件:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SuperControl.ascx.cs" Inherits="SuperControl" %>
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnTextChanged="DropDownList1_TextChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:DropDownList>
</div>
后台:
public partial class SuperControl : System.Web.UI.UserControl
{
public event EventHandler TextChanged;//事件委托
protected void DropDownList1_TextChanged(object sender, EventArgs e)
{
if (TextChanged != null)
{
TextChanged(this, e);
}
}
}
在页面中的使用方法:
<SuperControl:SupperControl ID="myControl" runat="server" OnTextChanged="myControl_OnTextChanged"/>
相关文章推荐
- C# WinFrom SplitContainer和UserControl组成简单的类似于web系统的框架页
- Web小练习-JavaScript事件的简单练习,监听鼠标的移动
- 20171012学习笔记Selenium 2 第四章WebDriver API 4.2控制浏览器 4.3简单元素操作4.4鼠标事件4.5键盘事件
- ASP.NET页面上直接放置用户控件WebUserControl1时的事件顺序
- ASP.NET Core Web API下事件驱动型架构的实现(一):一个简单的实现
- C# WinFrom SplitContainer和UserControl组成简单的类似于web系统的框架页
- 手机web自己定义滑动事件
- WebUserControl的简单用法,最近的几个项目都反复用到TextBox,CheckBox,RadiobuttonList,所以玩一下webusercontrol,有个投票功能哦。
- 定义一个简单的移动端轻击事件方法tap
- web中接收不到自定义控件事件的简单解决方案(修改控件)
- java:java中一个最简单的事件练习,…
- javascript移动设备Web开发中对touch事件的封装实例
- C# WebService 使用(简单天气查询)
- 从零开始学 Web 之 jQuery(一)jQuery的概念,页面加载事件
- 使用ZendFramework 2.* 创建简单的web应用程序
- 【转】获取web.xml中的context-param和init-param定义的值
- WebView使用详解(二)——WebViewClient与常用事件监听
- C#实现多级子目录Zip压缩解压实例 NET4.6下的UTC时间转换 [译]ASP.NET Core Web API 中使用Oracle数据库和Dapper看这篇就够了 asp.Net Core免费开源分布式异常日志收集框架Exceptionless安装配置以及简单使用图文教程 asp.net core异步进行新增操作并且需要判断某些字段是否重复的三种解决方案 .NET Core开发日志
- 从零开始学 Web 之 jQuery(五)操作元素其他属性,为元素绑定事件
- web前端领域移动端自定义长按事件你用过吗?