设为首页  
联系我们  
加入收藏  
网页制作 冲浪宝典 图形图像 操作系统 软件教学 编程开发 认证考试 安全技术 站长专区 文学驿站 娱乐天地 游戏天地 办公软件
文章搜索
您的位置: 首页 >> 文章首页 >> 编程开发 >> 网络编程 >> ASP.NET技巧 >> 在asp.net中为Web用户控件添加属性和事件
精品推荐
ASP.NET技巧点击TOP10
·ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!
·ASP.NET2.0下含有CheckBox的GridView删除选定记录实例
·在ASP.NET中上传图片并生成缩略图的C#源码
·如何在上传的图片上写字
·asp.net 2.0中用GRIDVIEW插入新记录
·asp.net 2.0下一个标准GRIDVIEW功能的实现(不用datasource控件)
·asp.net中在前台用js增删ListBox的items
·在ASP.NET中显示进度条
·asp.net开发wap程序必备:识别来访手机品牌型号
·在asp.net中为Web用户控件添加属性和事件
网络编程点击TOP10
·ASP.NET 程序中常用的三十三种代码
·CHK文件恢复工具
·.NET 初 级 读 本
·c#操作word表格
·『原创』C#中TreeView类操作全攻略:建立树,新增节点,删除节点,修改节点,拖动节点,与Oracle数据库交互操作(一)
·我的.NET书架 (入门篇)
·从零开始学ASP.NET(基础篇)
·十天学会ASP.net之第一天
·用C#实现木马程序
·官方水晶报表 .NET 应用程序实例下载 (C#、Visual C++.NET)
精选专题

在asp.net中为Web用户控件添加属性和事件

作者: 来源:http://www.xgdown.com/ 时间:2005-11-5 0:25:41

在asp.net中为Web用户控件添加属性和事件(5)     <asp:DropDownList id="DropDownList1" runat="server" AutoPostBack="True">
     <asp:ListItem Value="0" Selected="True">中文</asp:ListItem>
     <asp:ListItem Value="1">英文</asp:ListItem>
    </asp:DropDownList></FONT>
  </form>
 </body>
</HTML>
在后台代码中添加事件和属性。
虽然在前台添加了LogInOutControl1,但是后台代码中不会生成protected LogInOutControl LogInOutControl1;这条语句,我觉得很奇怪,不管先加上他。
接着在Page_Load事件中注册LogInOutClick事件:
this.LogInOutControl1.LogInOutClick += new LogInOutClickHandler(LogInOutControl1_LogInOutClick);

完整代码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace ZZ
{
 public class Default : System.Web.UI.Page
 {
  protected System.Web.UI.WebControls.Label LabelMsg;
  protected System.Web.UI.WebControls.DropDownList DropDownList1;
  protected LogInOutControl LogInOutControl1;
  private void Page_Load(object sender, System.EventArgs e)
  {
   //注册用户控件事件
   this.LogInOutControl1.LogInOutClick += new LogInOutClickHandler(LogInOutControl1_LogInOutClick);
  }
  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   InitializeComponent();
   base.OnInit(e);
  }
  private void InitializeComponent()
  {   
   this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
   this.Load += new System.EventHandler(this.Page_Load);
  }
  #endregion
  private void LogInOutControl1_LogInOutClick(object sender, LogInOutEventArgs e)

共6页 9 7 [1] [2] [3] [4] [5] [68 :>

在asp.net中为Web用户控件添加属性和事件 相关文章:
在asp.net中为Web用户控件添加属性和事件 相关软件:
特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
转载请注明来源:http://www.xgdown.com