动态创建aspx页面而不使用文件流概念 [英] Dynamically create the aspx page without using filestream concepts

查看:76
本文介绍了动态创建aspx页面而不使用文件流概念的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不使用文件流概念的情况下动态生成aspx页面和aspx.cs页面(web应用程序)。



i使用文件概念创建动态aspx页面但我需要(没有文件流或IO命名空间)aspx页。

解决方案

在代码隐藏中动态构建ASP.NET网页 [ ^ ]


< pre lang =xml> protected void Button1_Click(object sender,EventArgs e)
{
string pgname = TextBox1.Text;
String [] sASPX = {<%@ Page 语言 = \ C#\ AutoEventWireup = \ true \ CodeBehind = \ + < span class =code-attribute> pgname < span class =code-attribute> + 。aspx.cs \ 继承 = \ + pgname + \ %>
< < span class =code-leadattribute>!DOCTYPE html PUBLIC \ - // W3C // DTD XHTML 1.0 Transitional // EN \ \http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\ >
< html xmlns = \ < span class =code-attribute> http://www.w3.org/1999/xhtml\ >
< head runat = \ server \ >
< title > Untitled Page < / title >
< / head >
< body >
< 表格 id = \ form1 \ runat = \ server \ >
< div >

< / div >
< / form >
< / body >
< / html > };

String [] sCS = {using System;,
using System.Data;,
using System.Configuration;,
using System.Web;,
使用System.Web.Security;,
使用System.Web.UI;,
使用System.Web.UI.WebControls;,
using System.Web.UI.WebControls.WebParts;,
using System.Web.UI.HtmlControls;,
using System.Text;,
using System.Data.Sql;,
using System.Data.SqlClient;,
namespace Dynamic_Page_Creation,
{,
public partial class + pgname +:System.Web.UI.Page,
{,
protected void Page_Load(object sender,EventArgs e),
{,
},

}, };

string sa2 =C:\\Documents and Settings \\keerthana105 \\\\ my Documents \\Visual Studio 2008 \\Projects \\\\\ Creation\\Dynamic Page creation\\+ pgname +.aspx;
File.WriteAllLines(sa2,sASPX);
File.WriteAllLines(sa2 +。ccs,sCS);


How to dynamically generate the aspx page and aspx.cs page(web application) without using filestream concepts.

i created dynamic aspx page using file concepts but i need (without file stream or IO namespaces)aspx page.

解决方案

Building ASP.NET Web Pages Dynamically in the Code-Behind[^]


protected void Button1_Click(object sender, EventArgs e)
        {
            string pgname = TextBox1.Text;
            String[] sASPX = {"<%@ Page Language=\"C#\" AutoEventWireup=\"true\"  CodeBehind=\"" + pgname + ".aspx.cs\" Inherits=\"" + pgname + "\" %> ",
                                 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> ",
                                 "<html xmlns=\"http://www.w3.org/1999/xhtml\" >",
                                 "<head runat=\"server\"> ",
                                 "    <title>Untitled Page</title>",
                                 "</head>",
                                 "<body>",
                                 "    <form id=\"form1\" runat=\"server\">",
                                 "    <div>",

                                 "    </div>",
                                 "    </form>",
                                 "</body>",
                                 "</html>"};

            String[] sCS = {"using System;",
                              "using System.Data;",
                              "using System.Configuration;",
                              "using System.Web;",
                              "using System.Web.Security;",
                              "using System.Web.UI;",
                              "using System.Web.UI.WebControls;",
                              "using System.Web.UI.WebControls.WebParts;",
                              "using System.Web.UI.HtmlControls;",
                              "using System.Text;",
                              "using System.Data.Sql;",
                              "using System.Data.SqlClient;",
                              "namespace Dynamic_Page_Creation",
                              "{",
                              "public partial class " + pgname + " : System.Web.UI.Page ",
                              "{",
                              "protected void Page_Load(object sender, EventArgs e)",
                              "{",
                              "}",

                              "}","}"};

            string sa2 = "C:\\Documents and Settings\\keerthana105\\My Documents\\Visual Studio 2008\\Projects\\Dynamic Page Creation\\Dynamic Page Creation\\" + pgname + ".aspx";
            File.WriteAllLines(sa2,sASPX);
            File.WriteAllLines(sa2 + ".cs",sCS);


这篇关于动态创建aspx页面而不使用文件流概念的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆