Styling DIVs in an UpdatePanel

  • Thread starter Thread starter Wannabe
  • Start date Start date
W

Wannabe

when I try to style a div using the id tag, from an external style sheet, it
is not recognized. If I change the style sheet id to a class, it is
recognized. Is this how styling a div within an update panel supposed to work?

Example:

HTML
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="myDiv" class="myDiv">whatever
</div>
</ContentTemplate>
</UpdatePanel>

This is not recognized in an update panel
#myDiv
{
border: solid 1px blue;
}

This is recognized in an update panel

..myDiv
{
border: solid 1px green;
}
 
Thanks, but unless I missed something, that talks about styling an
updatepanel and I want to style the DIVs that are in my updatepanel.
 
The ideas presented in the post apply pretty well here. For example if your
DIV would be a server-side control, getting the ClientID would work (in case
you use master pages etc which impact on the IDs rendered in the end), or
enclosing the content in another element which you can style at will.

I suppose using classes instead of IDs would be preferred anyways for that
reason (ASP.NET autogenerating IDs).

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
 
You're right...thanks!

Teemu Keiski said:
The ideas presented in the post apply pretty well here. For example if your
DIV would be a server-side control, getting the ClientID would work (in case
you use master pages etc which impact on the IDs rendered in the end), or
enclosing the content in another element which you can style at will.

I suppose using classes instead of IDs would be preferred anyways for that
reason (ASP.NET autogenerating IDs).

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
 
Back
Top