I have a div and I am trying to add a CSS class to it in code but I receive the following error when I try
Property or indexer 'System.Web.UI.HtmlControls.HtmlControl.Style' cannot be assigned to -- it is read only
I am using the following code:
protected void BTNEvent_Click(object sender, ImageClickEventArgs e)
{
BtnventCss.Style= "hom_but_a";
}
Can anyone please help me?
What if:
To add or remove a class, instead of overwriting all classes with
keep the HTML correct:
This assures
Especially when client-side development is using several classnames on one element.
In your example, use
You should wrap this in a method/property 😉