Question on building Web Custom Controls

T

The Alchemist

The 'Render' method of a Web Custom Control takes an argument 'output'
of type System.Web.UI.HtmlTextWriter. This HtmlTextWriter renders any
content in the 'Render' method.

I am trying to render the content of my control in ANOTHER method.
When I try to create a new HtmlTextWriter in that method with the
code:

Dim writer As New StringWriter
Dim output2 As New HtmlTextWriter(writer)
output2.Write("TEST")

....it does nothing. This method is being called by another control to
in order to render some content. Can someone please advise how I can
render content from a custom method in a Web Custom Control.

Thanks in advance for any help.
 
J

John Saunders

The Alchemist said:
The 'Render' method of a Web Custom Control takes an argument 'output'
of type System.Web.UI.HtmlTextWriter. This HtmlTextWriter renders any
content in the 'Render' method.

I am trying to render the content of my control in ANOTHER method.
When I try to create a new HtmlTextWriter in that method with the
code:

Dim writer As New StringWriter
Dim output2 As New HtmlTextWriter(writer)
output2.Write("TEST")

...it does nothing. This method is being called by another control to
in order to render some content. Can someone please advise how I can
render content from a custom method in a Web Custom Control.

What is the value of writer.ToString() after the Write? You may also need to
use output2.Flush() before you see the result.
 

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,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top