By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,214 Members | 2,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,214 IT Pros & Developers. It's quick & easy.

Skin not being applied

P: n/a
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=""/>
Jun 5 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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 Samualson" <te*******@hotmail.comwrote in message
news:eA**************@TK2MSFTNGP04.phx.gbl...
>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=""/>


Jun 6 '07 #2

P: n/a
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.

"PlatinumBay" <st*******@community.nospamwrote in message
news:up*************@TK2MSFTNGP06.phx.gbl...
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 Samualson" <te*******@hotmail.comwrote in message
news:eA**************@TK2MSFTNGP04.phx.gbl...
>>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=""/>



Jun 6 '07 #3

P: n/a
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

"T Samualson" <te*******@hotmail.comwrote in message
news:Ox**************@TK2MSFTNGP04.phx.gbl...
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.

"PlatinumBay" <st*******@community.nospamwrote in message
news:up*************@TK2MSFTNGP06.phx.gbl...
>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 Samualson" <te*******@hotmail.comwrote in message
news:eA**************@TK2MSFTNGP04.phx.gbl...
>>>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=""/>




Jun 6 '07 #4

P: n/a
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.

"PlatinumBay" <st*******@community.nospamwrote in message
news:Oi**************@TK2MSFTNGP05.phx.gbl...
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

"T Samualson" <te*******@hotmail.comwrote in message
news:Ox**************@TK2MSFTNGP04.phx.gbl...
>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.

"PlatinumBay" <st*******@community.nospamwrote in message
news:up*************@TK2MSFTNGP06.phx.gbl...
>>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 Samualson" <te*******@hotmail.comwrote in message
news:eA**************@TK2MSFTNGP04.phx.gbl...
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=""/>




Jun 6 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.