473,405 Members | 2,287 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,405 software developers and data experts.

Render UserControl in Class wihtout access to webform?

I need to render a user control as a HTML string. I do not want the control
to appear on the page, however. Here is what I am doing…
I have an HTML template that will ultimately be sent via e-mail. Inside the
template I have IDs setup for each section that will be replaced with dynamic
data. In one section I need to display a specific kind of data. I already
have a user control that generates what I need. I need to get that control to
fire and then get rendered as HTML to be placed in the appropriate section of
the fore mentioned HTML template. This is the code I have so far:

Private Function BuildPropertyDetialsInfo() As String
Dim propertyInfoControl As New StringBuilder
Dim propertyInfoUserControl As New UserControl
Dim propertyInfoStringWriter As New StringWriter(propertyInfoControl)
Dim propertyInfoHTMLWriter As New
HtmlTextWriter(propertyInfoStringWriter)

Try
propertyInfoUserControl.LoadControl(propertyDetial sInfoPath)

propertyInfoUserControl.RenderControl(propertyInfo HTMLWriter)
Catch ex As Exception
End Try
Return propertyInfoControl.ToString
End Function
I donl’t get anything back. I am assuming that I need to add the control to
the collection, but I don’t know how I would do this since I am not working
on a web form. I am inside a class that doens’t have access to a form page.
Any thoughts?

Daniel

Aug 1 '07 #1
0 1748

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

Similar topics

0
by: Anonymous | last post by:
Hello, i have developed a web componenet library project, which access the usercontrol that resides in another web application. In my component, I load the control like this: Dim uCtrl As...
1
by: jralford | last post by:
Hi, Another question from a C# newbie: I have a usercontrol class that includes a customized control. Now, if I create an instance of the class, and click on it, a click event is raised for the...
3
by: Iain | last post by:
Hi I have page (testCal.aspx) that contains a usercontrol (custCalendar.ascx) - see below signature for code. The UC contains a linkbutton which which when clicked, posts back and displays a...
9
by: Peter | last post by:
I have an Usercontrol on a WebForm, on this Usercontrol is a button, I want to save data that's residing on the WebForm when user clicks on the button that's on the UserControl. How do I call a...
0
by: Sebastian Hiller | last post by:
Hello, i'm new to .Net (i'm using VB as language and i'm working in the code-behind mode) and i can't solve the following problem: I have a WebForm and want to Add a UserControl...
2
by: Craig Douthitt via DotNetMonster.com | last post by:
I am trying to capture an buttonclick on a usercontrol in the webform the usercontrol resides in. After researching this issue, I've come to believe that the best way of handling this is by raising...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
1
by: Kevin R | last post by:
This is one of the weirdest problems I have ever run into. I have had to trim down a bunch of code to give a sample that is more easily readable by those who will view this. Here is the problem:...
1
by: =?Utf-8?B?RGFuaWVsIERpIFZpdGE=?= | last post by:
I posted this a week ago, but did not get a respone yet. I need to render a user control as a HTML string. I do not want the control to appear on the page, however. Here is what I am doing… I...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.