当前位置: 代码迷 >> ASP.NET >> CheckBox 的LabelAttributes属性的Add方法的参数有什么限定吗?解决办法
  详细解决方案

CheckBox 的LabelAttributes属性的Add方法的参数有什么限定吗?解决办法

热度:6719   发布时间:2013-02-25 00:00:00.0
CheckBox 的LabelAttributes属性的Add方法的参数有什么限定吗?
CheckBox   的LabelAttributes属性的Add方法可以只给ChcekBox   的Text设置属性。msdn上add()定义如下:public   void   Add   (
string   key,
string   value
)
我想请问一下;参数有什么限制吗?比如key必须是浏览器能够识别的属性比如:OnMouseOver,Value必须是html语句?还是没有限制。
我用于测试的代码出现了问题?大家帮我看看?谢谢!


<%@   Page   Language= "C# "   AutoEventWireup= "true "   %>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script   runat= "server ">
        void   Page_Load(object   sendre,   EventArgs   e)
        {
                CheckBox1.InputAttributes.Add( "OnMouseOver ",   "this.sytle.backgroundColor= 'red ' ");
                CheckBox1.LabelAttributes.Add( "onmouseout ",   "this.sytle.backgroundColor= 'white ' ");
        }
</script>
<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   runat= "server ">
        <title> Untitled   Page </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
        <asp:CheckBox   ID= "CheckBox1 "   runat= "server "   TextAlign= "Left "   Text= "True "/>  
        </div>
        </form>
</body>
</html>

祝大家中秋快乐!

------解决方案--------------------------------------------------------
LabelAttributes属性的Add
key可以自己随便定义了,不一定是特有的属性
  相关解决方案