Convert ASP.NET Control to String

zhaozj2021-02-16  62

The following class can implement the Control of the ASP.NET to convert to String strings, which can be used:

Send an ASP.NET with a message to use the XSLT conversion page Output ASPX page global string of global strings

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); returnrate.tostring ();}}

VB.NET code

转载请注明原文地址:https://www.9cbs.com/read-17735.html

New Post(0)