Styling DIVs in an UpdatePanel

Discussion in 'ASP .Net' started by Wannabe, Jun 24, 2008.

  1. Wannabe

    Wannabe Guest

    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;
    }
     
    Wannabe, Jun 24, 2008
    #1
    1. Advertising

  2. Wannabe

    Teemu Keiski Guest

    Hi,

    see:

    UpdatePanel and CSS
    http://weblogs.asp.net/rajbk/archive/2007/01/14/updatepanel-and-css.aspx

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


    "Wannabe" <> wrote in message
    news:...
    > 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;
    > }
     
    Teemu Keiski, Jun 24, 2008
    #2
    1. Advertising

  3. Wannabe

    Wannabe Guest

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

    "Teemu Keiski" wrote:

    > Hi,
    >
    > see:
    >
    > UpdatePanel and CSS
    > http://weblogs.asp.net/rajbk/archive/2007/01/14/updatepanel-and-css.aspx
    >
    > --
    > Teemu Keiski
    > AspInsider, ASP.NET MVP
    > http://blogs.aspadvice.com/joteke
    > http://teemukeiski.net
    >
    >
    > "Wannabe" <> wrote in message
    > news:...
    > > 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;
    > > }

    >
    >
    >
     
    Wannabe, Jun 24, 2008
    #3
  4. Wannabe

    Teemu Keiski Guest

    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



    "Wannabe" <> wrote in message
    news:...
    > Thanks, but unless I missed something, that talks about styling an
    > updatepanel and I want to style the DIVs that are in my updatepanel.
    >
    > "Teemu Keiski" wrote:
    >
    >> Hi,
    >>
    >> see:
    >>
    >> UpdatePanel and CSS
    >> http://weblogs.asp.net/rajbk/archive/2007/01/14/updatepanel-and-css.aspx
    >>
    >> --
    >> Teemu Keiski
    >> AspInsider, ASP.NET MVP
    >> http://blogs.aspadvice.com/joteke
    >> http://teemukeiski.net
    >>
    >>
    >> "Wannabe" <> wrote in message
    >> news:...
    >> > 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;
    >> > }

    >>
    >>
    >>
     
    Teemu Keiski, Jun 24, 2008
    #4
  5. Wannabe

    Wannabe Guest

    You're right...thanks!

    "Teemu Keiski" wrote:

    > 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
    >
    >
    >
    > "Wannabe" <> wrote in message
    > news:...
    > > Thanks, but unless I missed something, that talks about styling an
    > > updatepanel and I want to style the DIVs that are in my updatepanel.
    > >
    > > "Teemu Keiski" wrote:
    > >
    > >> Hi,
    > >>
    > >> see:
    > >>
    > >> UpdatePanel and CSS
    > >> http://weblogs.asp.net/rajbk/archive/2007/01/14/updatepanel-and-css.aspx
    > >>
    > >> --
    > >> Teemu Keiski
    > >> AspInsider, ASP.NET MVP
    > >> http://blogs.aspadvice.com/joteke
    > >> http://teemukeiski.net
    > >>
    > >>
    > >> "Wannabe" <> wrote in message
    > >> news:...
    > >> > 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;
    > >> > }
    > >>
    > >>
    > >>

    >
    >
    >
     
    Wannabe, Jun 24, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roshawn

    Styling a control

    Roshawn, Aug 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    369
    clintonG
    Aug 21, 2004
  2. rich
    Replies:
    0
    Views:
    724
  3. Replies:
    3
    Views:
    481
    Rob Meade
    Aug 8, 2007
  4. Nathan Sokalski
    Replies:
    1
    Views:
    589
    miher
    Jun 15, 2009
  5. maya
    Replies:
    4
    Views:
    243
Loading...

Share This Page