2009-09-10

How to apply styles to the HTML controls by C#.net code

First, get the reference to the HTML control

Ex:-LinkButton lb = (LinkButton)Page.FindControl("LinkButton2");

Then apply the style to the link button by adding the following code

            lb.Attributes.Add("type", "text/css");
            lb.Attributes.Add("rel", "stylesheet");
            lb.Attributes.Add("class", "ph10");

No comments: