Getting HTML style attribute in Custom WebControl

  • Thread starter msnews.microsoft.com
  • Start date
M

msnews.microsoft.com

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>
 
H

HD

try something like this

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

hd
 
M

msnews.microsoft.com

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>
 
O

olivier

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

Olivier
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top