控件的老祖宗Control类
来源:互联网 发布:创建表注释sql语句 编辑:程序博客网 时间:2024/04/30 19:20
虽然我们写的自定义控件一般都是从WebControl类继承的但是还是要说一下,控件的老祖宗类Control类。
属性:
BindingContainer控件的数据绑定容器
Parent对当前控件的父级控件的引用
ClientID服务器控件的Html的Client端的id
Site当前控件的容器信息
Controls子控件
SkinID应用于控件的外观绑定
EnableTheming师傅能应用主题
TemolateControl该控件的模板
EnableViewState是否保持控件的视图状态
Context 当前web的请求上下文
Id控件的id
ViewState 所有视图状态
NamingContainer控件的命名容器
UniqueID唯一分层标识符
Page控件的页面实例
Visible是否显示
方法:
ApplyStyleSheetSkin激昂样式表的皮肤应用到当前控件
DataBind控件数据绑定
FindControl容器中查找指定控件
Focus获取焦点
GetType获取控件类型
HasControl判断控件是否有子控件
RenderControl输出控件内容
ResolveClientUrl获取浏览器可以使用的Url
ResolveUrl转换Url
SetRenderMethodDelegate设置呈现的委托
使用Control类的方法:
Control control=new Control();
control.ApplyStyleSheetSkin(this);
control.FindControl("TextBox");
control.Focus();
bool hasControl=control.HasControl();
control.ResolveClintUrl("http://www.baidu.com/
control.ResolveUrl(("http://www.baidu.com/
写一个简单的自定义控件
namespace MyFirstControl
{
public class MyControlOne:Control
{
public MyControlOne(){}
//重写控件的呈现部分
protected override void Render(HtmlTextWriter writer)
{
writer.Writer("this is my first control,it's ClientId is"+this.ClientID);
}
}
}
遍历页面文本的实例:
stringbuilder strb=new stringbuilder();
foreach(Control ctrl in this.Page.Control[3].Controls)
{
if(ctr1.GetType().Name=="CheckBox")
{
CheckBox cb=(CheckBox)ctrl;
if(cb.Checked)
strb.Append(cd.Text+"<br/>");
}
}
Literal1.Text=strb.tostring();
转自:http://www.cnblogs.com/liuchunze/archive/2008/06/01/1211607.html
- 控件的老祖宗Control类
- java的老祖宗之Object类
- 老祖宗的老话大全收藏
- 所有控件的基类:Control
- 老祖宗的遗产与流行时尚:蓬荜生辉
- 错误植入法与老祖宗的智慧
- 老祖宗的智慧:"十不过",字字珠玑!
- List Control 控件的使用
- Custom Control控件的使用
- TAB Control控件 的使用方法
- Tab Control控件的使用
- VSTab Control控件的使用
- Progress Control控件的使用
- Custom Control 控件的使用
- Picture control 控件的使用
- TAB Control控件 的使用方法。
- CList Control 控件的使用
- 老祖宗总结的12条决定命运的秘诀
- funambol 时间戳
- DSP程序Flash程序下载到RAM中运行
- 自动投票。。。
- 进程
- Web开发中需要了解的东西 (转)
- 控件的老祖宗Control类
- 通过va_list和/dev/kmsg在串口打印调试信息
- oracle导入或者导出数据库、表
- ReadYuvFile
- 不要轻易许下承诺
- 给jre更多内存
- VI编辑器的配置
- 4315. Digit Count
- phpmyadmin 没有 innodb引擎