Monday, January 18, 2010

How do I programmatically assign a SkinID to a control while using a master page in ASP.net 2.0?

In the THEMENAME.skin file, assign a SkinID to the skin:





%26lt;asp:GridView runat=';server'; SkinID=';SKIN_NAME'; Gridlines=';none'; HeaderStyle-BackColor=';Yellow'; /%26gt;





Then, in the page itself, simply apply the SkinID name to the element you want to have inherit the skin:





%26lt;asp:GridView runat=';server'; id=';GRIDVIEWNAME'; SkinID=';SKIN_NAME'; AutoGenerateColums=';False'; /%26gt;





Themes can be inherited by both the master page and the content page that uses the master page, and the same SkinID can apply to multiple elements on the same page (for example, if you have three GridViews on the page, all three can have the same SkinID).

No comments:

Post a Comment