当前位置:IT168首页 > 技术开发 > 概述
[收藏此页] [打印] [推荐] [评论]

扩展Label控件 - 实现回发(Postback)功能

责任编辑:nancy作者:ITPUB论坛   2008-05-14   
【内容导航】
文本Tag: 微软 sql

【IT168技术文档】

  扩展Label控件:
  通过注册HiddenField控件,使Label控件支持回发(Postback)功能

  使用方法(设置属性):
  EnablePostback - 是否启用Label控件的回发(Postback)
  HiddenFieldPostfix - 使Label支持回发(Postback)的隐藏控件的后缀名
  关键代码
  ScriptLibrary.js
function yy_sl_copyTextToHiddenField(source, destination) { /// <summary>将Label控件的的值赋给隐藏控件</summary> document.getElementById(destination).value = document.getElementById(source).innerHTML; }
  SmartLabel.cs
using System; using System.Collections.Generic; using System.Text; using System.Web.UI.WebControls; using System.Web.UI; [assembly: System.Web.UI.WebResource("YYControls.SmartLabel.Resources.ScriptLibrary.js", "text/javascript")] namespace YYControls { /**//// <summary> /// SmartLabel类,继承自DropDownList /// </summary> [ToolboxData(@"<{0}:SmartLabel runat='server'></{0}:SmartLabel>")] [System.Drawing.ToolboxBitmap(typeof(YYControls.Resources.Icon), "SmartLabel.bmp")] public partial class SmartLabel : Label { /**//// <summary> /// 构造函数 /// </summary> public SmartLabel() { } /**//// <summary> /// OnPreRender /// </summary> /// <param name="e">e</param> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // 实现Label控件的回发(Postback)功能 ImplementPostback(); } } }
上一页
1
23下一页
收藏到: 添加到“百度搜藏”添加到“QQ书签”添加到“Google书签”添加到“Yahoo收藏”添加到“和讯网摘”
【内容导航】
本文欢迎转载,转载请注明:转载自IT168 [ http://www.it168.com/ ]
本文链接:http://tech.it168.com/d/2008-05-14/200805142138500.shtml
技术开发相关文章   .net server SQL 微软
  • 暂无
友情推介