all groups > asp.net webcontrols > october 2003 >
You're in the

asp.net webcontrols

group:

Getting HTML style attribute in Custom WebControl


Getting HTML style attribute in Custom WebControl msnews.microsoft.com
10/30/2003 5:14:00 PM
asp.net webcontrols:
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>

Re: Getting HTML style attribute in Custom WebControl HD
10/31/2003 7:42:40 AM
try something like this

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

hd

[quoted text, click to view]

Re: Getting HTML style attribute in Custom WebControl msnews.microsoft.com
10/31/2003 9:39:43 AM
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>

[quoted text, click to view]

Re: Getting HTML style attribute in Custom WebControl olivier NO[at]SPAM kakoo.net
11/3/2003 2:29:09 AM
Instead of overriding the Render method, you may want to
override the RenderContents method.

Olivier
[quoted text, click to view]
AddThis Social Bookmark Button