473,378 Members | 1,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

rendering a control to a string: why doesn't this work?

PJ6
Nothing comes out of this, even though I tried to observe what I thought the
HtmlTextWriter might expect for method calls.

I must be missing something simple, but what?

Private Sub TestRender()
Dim lbl As New Label
lbl.Text = "FOO"
Dim ms As New System.IO.MemoryStream
Dim tw As New System.IO.StreamWriter(ms)
Dim writer As New System.Web.UI.HtmlTextWriter(tw)
writer.BeginRender()
lbl.RenderControl(writer)
writer.EndRender()
writer.Flush()
Dim sr As New System.IO.StreamReader(ms)
Dim html As String = sr.ReadToEnd
End Sub

Paul
Jun 27 '07 #1
2 980
PJ6,

insert the following line before opening the streamreader:
ms.Position = 0
"PJ6" wrote:
Nothing comes out of this, even though I tried to observe what I thought the
HtmlTextWriter might expect for method calls.

I must be missing something simple, but what?

Private Sub TestRender()
Dim lbl As New Label
lbl.Text = "FOO"
Dim ms As New System.IO.MemoryStream
Dim tw As New System.IO.StreamWriter(ms)
Dim writer As New System.Web.UI.HtmlTextWriter(tw)
writer.BeginRender()
lbl.RenderControl(writer)
writer.EndRender()
writer.Flush()
Dim sr As New System.IO.StreamReader(ms)
Dim html As String = sr.ReadToEnd
End Sub

Paul
Jun 28 '07 #2
PJ6
D'oh... knew I forgot something.

Thanks :)
Paul

"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.comwrot e
in message news:81**********************************@microsof t.com...
PJ6,

insert the following line before opening the streamreader:
ms.Position = 0
"PJ6" wrote:
>Nothing comes out of this, even though I tried to observe what I thought
the
HtmlTextWriter might expect for method calls.

I must be missing something simple, but what?

Private Sub TestRender()
Dim lbl As New Label
lbl.Text = "FOO"
Dim ms As New System.IO.MemoryStream
Dim tw As New System.IO.StreamWriter(ms)
Dim writer As New System.Web.UI.HtmlTextWriter(tw)
writer.BeginRender()
lbl.RenderControl(writer)
writer.EndRender()
writer.Flush()
Dim sr As New System.IO.StreamReader(ms)
Dim html As String = sr.ReadToEnd
End Sub

Paul

Jun 28 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David Whitney | last post by:
All: I have a control that renders a table. As the table is rendered, each row in the table is constructed by creating a run-time (dynamic) object that is derived from an HtmlTableRow. The row...
2
by: Mike Speak | last post by:
I have a user control that I want to use to render 4 menu items (retrieved from db) on the top of each of my asp.net pages. The user control defines a table, with one TR and one TD. Within the...
0
by: Scott Yenor | last post by:
Hello, I am writing a control library that has a control that inherits from System.Web.UI.Control. The control works fine and I am able to loop through the child controls and display everything...
1
by: Alan Mendelevich | last post by:
Hi, I'm trying to render control stored in ascx file to a string. I succeed with the main part but events (at least OnLoad) doesn't fire (or aren't automatically wired to Page_Load() method in...
3
by: matthias s. | last post by:
Hi there, I'm building a usercontrol to provide language selection options. The availabe languages are retrieved dynamically and should be shown as flags (ImageButtons) in a table. But I've...
5
by: Dave A | last post by:
I am writing an ASP.NET tool that will allow the client to create their own online froms. ie the client can add tect boxes, text, drop downs,etc with absolutely no technical skill what so ever....
1
by: Jarod | last post by:
Hey When I put my control into DetailsView in a template I see it and it seems as working ok. After compile it works on the page. But in normal view in designer I don't see my detailsView instead...
5
by: paul.hester | last post by:
Hi all, I have a custom control with an overridden Render method. Inside this method I'm rendering each control in its collection using their RenderControl method. However, I'm running into a...
0
by: pabloazorin | last post by:
I developed a Date Picker web control using C# and .net framework 1.1 I added my control to Visual Studio 2003 IDE toolbar. When I drag and drop my control to design web page, the control renders...
3
by: SAL | last post by:
Hello, I did google this issue and found some stuff related to BrowserCaps section of either web.config or machine.config but it didn't work. It seems that most pages in my webapp are okay but a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.