c# – How to set data-attributes with ASP.NET?-ThrowExceptions

Exception or error:

How can data-attributes be set using code behind?

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?

DESIRED MARKUP

<span id="lbl">Text</span>
<div id="pnl" data-attribute="200">Value</div>
How to solve:
pnl.Attributes("data-attribute") = "200"

Leave a Reply

Your email address will not be published. Required fields are marked *