常用的服务器控件

1、label 控件 

只有文本 会被渲染为span 块
如果label的 AssociatedControlID 属性 关联了控件就会
<label for="TextBox2" id="Label1">姓名</label>
渲染成label并赋给for属性
 
2、literal  
直接渲染文本 
mode属性设置为encode可以对html进行encode 避免html攻击

3、textbox 
TextMode 属性 可以设置为password MultiLine 等 
AutoPostBack 属性设置为true 的话,文本发生改变后,焦点离开文本框就会立即post数据
会为控件注册一个_doPostBack方法
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
4,RadioButton
渲染为input type = radio 设置GroupName属性

<input id="RadioButton1" type="radio" name="city" value="RadioButton1" /><label for="RadioButton1">北京</label>
<br />
<input id="RadioButton2" type="radio" name="city" value="RadioButton2" /><label for="RadioButton2">上海</label>

会生成radiobutton文本用label显示 并设置for属性
5、Button

button
<input type="submit" name="Button1" value="Button" id="Button1" />  submit按钮
linkbutton
<a id="LinkButton1" href="javascript:__doPostBack(&#39;LinkButton1&#39;,&#39;&#39;)">LinkButton</a> 
渲染为超链接 链接了一个javascript代码
imagebutton
菊子曰 你玩微博么?写博客么?强力推荐你试试菊子曰
posted @ 2013-06-15 23:56  河之洲  阅读(154)  评论(0)    收藏  举报