您的位置:首页 > 编程语言 > ASP

如何:在 ASP.NET 网页中设置控件的 HTML 属性

2013-03-17 22:03 615 查看
<body id="body" runat="server">
<form id="form1" runat="server">

<!-- Example1 -->
<input runat="server" id="Button1" type="button" onmouseover="rollover()" onmouseout="exitrollover()" />
</form>
</body>

<script runat="server">
private void Page_Load()
{
//Example 2
Button1.Attributes.Add("onclick", "alert('hello, world')");
Button1.Style.Add("background-color", "red");

//Example 3
Button1.Attributes["bgcolor"] = "lightblue";

}
</script>


        Button1.Attributes.Add("onclick", "alert('hello, world')");  //添加标准Html 属性

        Button1.Style.Add("background-color", "red");//向样式里面添加指定的样式属性

       

        //Example 3

        Button1.Attributes["bgcolor"] = "lightblue";//添加标准的Html属性

      
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐