Convert ASP.NET Control to String
Source: Unknown Author: Unknown Recommended rating: Visits: 13
The following classes can implement the Control of ASP.NET to convert to String strings, which can be used to send ASP.NET with messages to the output ASLT conversion page Output ASPX page Global string of global strings using C # code using System; using System.IO; using System.Text; using System.Web; using System.Web.UI; public class Render {public static string RenderControl (System.Web.UI.Control control) {StringBuilder result = new StringBuilder ( 1024); control.RenderControl (new HtmlTextWriter (new StringWriter (result))); return result.ToString ();} public static string RenderControl (System.Web.UI.TemplateControl control) {StringBuilder result = new StringBuilder (1024); control.RenderControl (new HtmlTextWriter (new StringWriter (result))); return result.ToString ();} public static string RenderPage (string pageLocation) {System.Web.HttpContext context = System.Web.HttpContext.Current; StringBuilder result = new StringBuilder (1024); context.Server.Execute (pageLocation, new HtmlTextWriter (new StringWriter (result))); return result.ToString ();}} VB.NET Code Imports System Imports System.IO Imports System.Text Imports System.Web Imports System.Web.UI Public Class Render Public Shared Function RenderControl (ByVal control As System.Web.UI.Control) _ As String Dim result As StringBuilder = New StringBuilder (1024) control.RenderControl (New HtmlTextWriter (New StringWriter (result))) Return result.ToString () End Function Public Shared Function RenderControl (ByVal control As System.Web.UI.TemplateControl) _ As String Dim result As StringBuilder = New StringBuilder (1024) control.RenderControl (New HtmlTextWriter (New StringWriter (Result)) Return Result.toString () End Function Public Shared Function Render (Byval PageLocation As String) AS String Dim Context As System.Web.httpContext =