Yup, that is basically what I am doing, but I dont get any content.

StringBuilder sb = new StringBuilder();
using ( StringWriter sw = new StringWriter( sb))
using ( HtmlTextWriter htw = new HtmlTextWriter( sw))
{
MyUserControl ctrl = new MyUserControl();
ctrl.MyProperty = value;
ctrl.RenderControl( htw);
}
return sb.ToString();

When I place the user control on a page it is rendering correctly.
I must be missing something obvious ...

// Ryan

On 9/4/06, Dominick Baier <[EMAIL PROTECTED]> wrote:
using (StringWriter sw = new StringWriter())

   {

       HtmlTextWriter htw = new HtmlTextWriter(sw);

       _grid.RenderControl(htw);

       htw.Flush();

       return sw.ToString();

   }





cheers,
dominick

-----------------------------
Dominick Baier, DevelopMentor
http://www.leastprivilege.com


-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Ryan Heath
Sent: Montag, 4. September 2006 18:02
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: [ADVANCED-DOTNET] UserControl & RenderControl method

Hi,

How can I extract the html of an usercontrol?
The method renderControl is returning an empty content! :S

I want to use an usercontrol's content to be returned in a webservice.

I googled around but cannot find a solution...

// Ryan

===================================
This list is hosted by DevelopMentorR  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com


===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to