国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 庄浪县| 龙川县| 宜都市| 涞源县| 松原市| 庆安县| 铁力市| 天水市| 玛沁县| 宁武县| 汾阳市| 肃北| 宁南县| 香港 | 泰安市| 衡阳市| 龙陵县| 喀什市| 萨迦县| 怀宁县| 永寿县| 海阳市| 静乐县| 福建省| 河源市| 丹寨县| 林周县| 越西县| 阿拉尔市| 商水县| 墨江| 平顺县| 吴江市| 沾化县| 肃宁县| 于田县| 乌审旗| 图们市| 平顶山市| 青州市| 泰州市|