国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

將ASP.NET Control轉(zhuǎn)換為String

2024-07-10 12:57:11
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
下面的類(lèi)可以實(shí)現(xiàn)將asp.net的control(包括aspx頁(yè)面)轉(zhuǎn)換成string字符串,可以用于:

用郵件發(fā)送asp.net的內(nèi)容
用xslt轉(zhuǎn)換頁(yè)面的輸出
aspx頁(yè)面的全局字符串的使用

c#代碼

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代碼

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 renderpage(byval pagelocation as string) as string
dim context as system.web.httpcontext = system.web.httpcontext.current
dim result as stringbuilder = new stringbuilder(1024)
context.server.execute(pagelocation, _
new htmltextwriter(new stringwriter(result)))
return result.tostring()
end function
end class

中國(guó)最大的web開(kāi)發(fā)資源網(wǎng)站及技術(shù)社區(qū),
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 安化县| 密云县| 克什克腾旗| 茌平县| 来安县| 东乌| 银川市| 隆德县| 科技| 成武县| 黄平县| 镇巴县| 巴林右旗| 鹤峰县| 化隆| 师宗县| 普洱| 延津县| 亚东县| 巧家县| 图片| 兴山县| 邵阳市| 繁昌县| 五原县| 兴文县| 涟源市| 百色市| 揭西县| 泰兴市| 浦东新区| 澄迈县| 平陆县| 西吉县| 五峰| 平安县| 柯坪县| 博兴县| 吉安县| 贞丰县| 纳雍县|