Styling DIVs in an UpdatePanel

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;
}
 
W

Wannabe

Thanks, but unless I missed something, that talks about styling an
updatepanel and I want to style the DIVs that are in my updatepanel.
 
T

Teemu Keiski

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
 
W

Wannabe

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top