All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
精华:AJAX开发简略(第一部分)_[AJAX教程]
visual c++ MFC调试宏
Visual C++中面向对象程序设计方法
Zope的优点及和Apache+PHP+MySQL的比较_php资料_编程技术
在ASP.NET程序中值得注意的两个地方_.net资料_编程技术
ASP.NET中动态控制RDLC报表_[Asp.Net教程]_0
PHP技巧:PHP中时间和日期函数总结_[PHP教程]
C#网络应用编程基础练习题与答案(四)_.net资料_编程技术
最近写的一个PHP操作Access类(PHP+ODBC+Access)_php资料_编程技术
Apache伪静态html(URL Rewrite)设置法_[PHP教程]
Reading number is top 10 pictures
A man's favorite things6
HongMenYan premiere XinLiangGong clairvoyant outfit PK YiFeiLiu2
Wear bikinis cock
The world's top ten most beautiful railway station1
Sora aoi calligraphy show
Fierce! China's special forces training the devil2
The money of more than 100 countries and regions1
The little woman's bright wire1
ashlynn brooke
西游四格漫画(二)
Download software ranking
中国结婚习俗实录
仙剑奇侠传98硬盘WINXP版
Rio big adventure
Sora aoi, the maid, students' uniforms
Eclipse-CALMSANNY (second edition)
艳兽都市
The cock of the Grosvenor LTD handsome
Tram sex maniac 2 (H) rar bag16
网页特效实例大全
Boxer's Top ten classic battle9
aaa published in(发表于) 2013/12/6 10:40:09 Edit(编辑)
自定义阿ASP.NET,CheckBox的设计思路_.net资料_编程技术

自定义阿ASP.NET,CheckBox的设计思路_.net资料_编程技术

自定义阿ASP.NET CheckBox的设计思路_.net资料_编程技术-数科优化网
  有人要问,你疯了吧,checkbox控件还用写你重写吗?没办法,最近做一个asp.net项目,写开发模板的时候,需要这样做!我的模板需要在前台用javascript控制控件的值和状态初始化,需要很多特殊的html attribute,记录一些控制参数,但是ms提供的控件没有这些属性,因此连checkbox都要自己做了!我的checkbox的需求是:

  1: 包含所有的ms checkbox属性方法和事件

  2: 此外,要对自己定义的checkbox加上enableflag,witowner等自定义属性

  问题和解决思路如下:

  问题: 如果直接继承ms的checkbox, 使用this.attributes.add("witowner","true") 语句给控件添加自定义属性,属性会添加到控件产生的上,checkbox上没有加上这个属性,在前台无法用javascript获取该属性,来控制checkbox.

  解决思路:如果继承webcontrol,然后覆盖render方法,在render的时候,用类似chkcheckbox.rendercontrol(writer); 的语句添加htmlinputcheckbox,再加一个文字label,应该可以用符合控件的方式模拟出ms checkbox,并且带自己定义属性的功能。但是,这个时候出现的问题是:无法把控件放到中,设置控件背景颜色等属性,无法针对控件生效! 解决办法:

  为了满足以上需求,控件继承webcontrol, 覆盖rendercontents,语法如下


///
/// 绘制控件的内容,即:绘制span包含的部分,在rendercontents函数里面写
/// 子控件的render,可以让复合控件的span包含子控件,便于写前台script操作。
///

///
protected override void rendercontents(htmltextwriter writer)
{
 setgroupattributes();

 if(this.textalign==textalign.right)
 {
  chkcheckbox.id=this.clientid+"_checkbox";

  chkcheckbox.rendercontrol(writer);
 
  writer.write("");
 }
 else
 {
  writer.write("");
  chkcheckbox.id=this.clientid+"_checkbox";
  chkcheckbox.rendercontrol(writer);
 }
}

private void setgroupattributes()
{
 //所有的cswit控件都需要带有这个属性
 chkcheckbox.attributes.add("witowner","true");
}




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.