Skin not being applied


T

T Samualson

I am programmatically adding controls to my user control but my skin is not
being applied to the control.

The code gets executed in a btn_Click event. I have tried specifically
setting the skinId property with no luck.

Any ideas?

Here is my simplified code:
TextBox newTextBox = new TextBox();
TextBoxPlaceHolder.Controls.Add(new TextBox());

And my skin:
<asp:TextBox runat="server" Style="background-color:lightblue;"
Visible="true" Text=""/>
 
Ad

Advertisements

P

PlatinumBay

T,

You need to set the SkinID property of the TextBox.

TextBox newTextBox = new TextBox();
newTextBox.SkinID = "TextBoxSkin";
TextBoxPlaceHolder.Controls.Add(new TextBox());

In the skin file, you must also include the SkinID attribute.

<asp:TextBox runat="server" SkinID="TextBoxSkin"
Style="background-color:lightblue;" Visible="true" Text=""/>

Hope this helps,


Steve
 
T

T Samualson

Thanks Steve - I was doing that but I thought I would post a simplified
version for the news group.

I have found a few hints about doing it in Page_PreInit() but the controls
are all null still. I created an instance of the master page in pre-init
also so my controls are available but my controls still arent skinning.


What event do you skin your controls in? My controls need to be added
during a btn_onClick event... any help would be greatly appreciated.
 
P

PlatinumBay

T,

The Init event is where the controls are initialized, which is why in
PreInit the controls are not yet initialized. If you override the OnInit or
OnInitComplete method, you should be able to set control themes there.

Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
MyBase.OnInit(e)

Me.button1.Theme = ""
End Sub

Hope this helps,


Steve
 
Ad

Advertisements

T

T Samualson

Something odd must be happening.

The answer to my riddle was how I identify the theme in web.config. I was
using the attribute stylesheettheme="myThemeName" and I changed it to
theme="myThemeName".

Now I can change the theme whenever I want, not just in the OnInit() method
....even in my button OnClick event...

Im just reading up on the advantages of stylesheet theme vs theme and it
appears that stylesheet theme can be overridden...if you can get it to work
I guess.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top