我需要在ASP.NET页面对象的标记中添加一些属性(http://www.w3.org/International/questions/qa-http-and-lang).注意:我不能以声明方式执行此操作,并且必须使用服务器端对象模型来执行此操作.有任何想法吗?
添加一些其他信息:我需要在ASP.NET页面渲染生命周期中执行此操作.我需要将属性添加到页面中的根元素.
您应该看到以下MSDN文章:
看起来很简单:
myButton.Attributes.Add("myattribute", "myValue");
Run Code Online (Sandbox Code Playgroud)
更新:您可以对具有id且设置为的任何元素执行此操作runat="server",例如:
<html id="htmlTag" runat="server" ...
this.htmlTag.Attributes.Add("myAttribute", "myValue");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3844 次 |
| 最近记录: |