Click here to Skip to main content
15,913,669 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 19-Dec-12 19:48pm
v3
Comments
Orcun Iyigun 20-Dec-12 1:45am    
What have you tried? Have you used your best friend called Google?

XML
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);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900