nima shayanfar
nima shayanfar

Reputation: 131

how to get attribute value of div in asp.net

I have a div like this:

<div id="1" class="2" no="3" type="4"></div>

i want get property no and type in ASP.net.

please help me.

Upvotes: 0

Views: 4541

Answers (2)

Plamen Nachev
Plamen Nachev

Reputation: 41

Add the runat="server" attribute to the div and access the other attributes in code-behind like this: string attr = divId.Attributes["attrName"];

If you are adding the attributes with javaScript, make sure to run this code after the javaScrip has added them. Otherwise you might get a null refference exception.

Upvotes: 1

Abhijeet Bagul
Abhijeet Bagul

Reputation: 66

add tag runat="server" and then in c# divid.yourproperty

Upvotes: 0

Related Questions