DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 1 Aug 2007 11:30:03 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Daniel Di Vita


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(propertyDetialsInfoPath)         
       
        propertyInfoUserControl.RenderControl(propertyInfoHTMLWriter)
      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
Date:Wed, 1 Aug 2007 11:30:03 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us