如何使用代码设置数据属性?
ASP.NET
<asp:Label ID="lbl" runat="server" Text="Value" />
<asp:Panel ID="pnl" runat="server" />
VB
lbl.Text = "Text"
pnl.Attributes("data-attribute") = "200"
//Is this correct?
渴望的商标
<span id="lbl">Text</span>
<div id="pnl" data-attribute="200">Value</div>
答案 0 :(得分:3)
pnl.Attributes("data-attribute") = "200"
答案 1 :(得分:1)
C#:
pnl.Attributes["data-attribute"] = "200";
VB:
pnl.Attributes("data-attribute") = "200"