Getting HTML style attribute in Custom WebControl

Discussion in 'ASP .Net Web Controls' started by msnews.microsoft.com, Oct 30, 2003.

  1. This seems like it should be easy (and maybe it is) but I can't figure it
    out.

    I have a custom web control (derived from
    System.Web.UI.WebControls.WebControl)
    I'm in Grid Layout mode so at design time the HTML in the .aspx page looks
    like this:

    <cc2:CAUTreeView id="cautv" style="Z-INDEX: 101; LEFT: 16px; POSITION:
    absolute; TOP: 224px" runat="server" Width="50px"></cc2:CAUTreeView>

    In my override of Render I want to get the style attribute so I can output
    the same positioning information so the control renders in the exact spot
    that it was designed in. I can't find any way to get at this at run-time.

    Any ideas?

    </joel>
    msnews.microsoft.com, Oct 30, 2003
    #1
    1. Advertising

  2. msnews.microsoft.com

    HD Guest

    try something like this

    if(Style != null)
    {
    writer.write("<span style\"" + Style + "\">");
    writer.write("Your display text");
    writer.write("</span>"
    }

    hd

    "msnews.microsoft.com" <> wrote in message
    news:OX9%...
    > This seems like it should be easy (and maybe it is) but I can't figure it
    > out.
    >
    > I have a custom web control (derived from
    > System.Web.UI.WebControls.WebControl)
    > I'm in Grid Layout mode so at design time the HTML in the .aspx page looks
    > like this:
    >
    > <cc2:CAUTreeView id="cautv" style="Z-INDEX: 101; LEFT: 16px; POSITION:
    > absolute; TOP: 224px" runat="server" Width="50px"></cc2:CAUTreeView>
    >
    > In my override of Render I want to get the style attribute so I can output
    > the same positioning information so the control renders in the exact spot
    > that it was designed in. I can't find any way to get at this at run-time.
    >
    > Any ideas?
    >
    > </joel>
    >
    >
    HD, Oct 31, 2003
    #2
    1. Advertising

  3. Doh! I was doing that but in the constructor. The Style wasn't loaded yet!

    As soon as I did it in my Render override it worked fine.

    Thanks and sorry for the waste of time!

    </joel>

    "HD" <> wrote in message
    news:...
    > try something like this
    >
    > if(Style != null)
    > {
    > writer.write("<span style\"" + Style + "\">");
    > writer.write("Your display text");
    > writer.write("</span>"
    > }
    >
    > hd
    >
    > "msnews.microsoft.com" <> wrote in message
    > news:OX9%...
    > > This seems like it should be easy (and maybe it is) but I can't figure

    it
    > > out.
    > >
    > > I have a custom web control (derived from
    > > System.Web.UI.WebControls.WebControl)
    > > I'm in Grid Layout mode so at design time the HTML in the .aspx page

    looks
    > > like this:
    > >
    > > <cc2:CAUTreeView id="cautv" style="Z-INDEX: 101; LEFT: 16px;

    POSITION:
    > > absolute; TOP: 224px" runat="server" Width="50px"></cc2:CAUTreeView>
    > >
    > > In my override of Render I want to get the style attribute so I can

    output
    > > the same positioning information so the control renders in the exact

    spot
    > > that it was designed in. I can't find any way to get at this at

    run-time.
    > >
    > > Any ideas?
    > >
    > > </joel>
    > >
    > >

    >
    >
    msnews.microsoft.com, Oct 31, 2003
    #3
  4. msnews.microsoft.com

    Guest

    Instead of overriding the Render method, you may want to
    override the RenderContents method.

    Olivier
    >-----Original Message-----
    >try something like this
    >
    >if(Style != null)
    >{
    > writer.write("<span style\"" + Style + "\">");
    > writer.write("Your display text");
    > writer.write("</span>"
    >}
    >
    >hd
    >
    >"msnews.microsoft.com" <> wrote in

    message
    >news:OX9%...
    >> This seems like it should be easy (and maybe it is)

    but I can't figure it
    >> out.
    >>
    >> I have a custom web control (derived from
    >> System.Web.UI.WebControls.WebControl)
    >> I'm in Grid Layout mode so at design time the HTML in

    the .aspx page looks
    >> like this:
    >>
    >> <cc2:CAUTreeView id="cautv" style="Z-INDEX: 101;

    LEFT: 16px; POSITION:
    >> absolute; TOP: 224px" runat="server"

    Width="50px"></cc2:CAUTreeView>
    >>
    >> In my override of Render I want to get the style

    attribute so I can output
    >> the same positioning information so the control

    renders in the exact spot
    >> that it was designed in. I can't find any way to get

    at this at run-time.
    >>
    >> Any ideas?
    >>
    >> </joel>
    >>
    >>

    >
    >
    >.
    >
    , Nov 3, 2003
    #4
    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. Guest
    Replies:
    2
    Views:
    725
  2. Alessandro Zifiglio

    absolutePositioning attribute of Custom webcontrol

    Alessandro Zifiglio, Nov 26, 2003, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    122
    Alessandro Zifiglio
    Nov 28, 2003
  3. Ken Varn
    Replies:
    0
    Views:
    430
    Ken Varn
    Apr 26, 2004
  4. Fabricio

    Custom webcontrol that references another webcontrol

    Fabricio, Sep 21, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    171
    Fabricio
    Sep 21, 2005
  5. Curt_C [MVP]

    Custom WebControl, custom property list

    Curt_C [MVP], Sep 1, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    165
    Curt_C [MVP]
    Sep 1, 2005
Loading...

Share This Page