Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Asp.Net Programming

Skin not being applied

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=""/>


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,


"T Samualson" <tera_8@hotmail.com> wrote in message


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" <stevan@community.nospam> wrote in message



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)

        Me.button1.Theme = ""
    End Sub

Hope this helps,


"T Samualson" <tera_8@hotmail.com> wrote in message


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

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" <stevan@community.nospam> wrote in message


Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc