Click here to Skip to main content
15,885,920 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a requirement like, creating the complete web page dynamically.
means user should have an interface, they can design the form like required text box,label,drop down etc. and that has to be saved and while refresh,it should have a link in menu and by clicking it the form has to be loaded and user should be able to do data entry in that page and save it to DB
Posted
Comments
sraman222 15-May-12 1:50am    
i have a problem , i'm using the following code to add the dynamically created html in my content place holder...
it got cleared while postback ...
Help me out in this
string test = Session["htmlText"].ToString();

Master.FindControl("ContentPlaceHolder1").Controls.Add(new LiteralControl(test));

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 9-May-12 10:06am    
Well, I don't think this is really from scratch. Please see my answer -- this is really from scratch.
--SA
Don't you think that this is the second most trivial case of ASP.NET, following the most trivial case where you don't use server-side code at all, only HTML? All server-side Web technologies allow creation of pages from scratch. This is the most basic skill everyone should learn almost from the very beginning.

This is probably the simplest recipe I could think of:

Add a Web page to your ASP.NET Web project. Let's assume this is the very first page created from the project template called "Default.aspx". The code-behind server-side C# file will be "Default.aspx.cs".

Remove everything from "Default.aspx" except this:
ASP.NET
<%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" %>


In "Default.aspx.cs", you can write:
C#
public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, System.EventArgs e) {
        this.Response.Write("<html><body><h1>Hello, ASP.NET page from scratch!</h1></body><html>");
    }
}


Are you getting the idea? Using Response.Write, you can render any content on your page, perform any required calculations using C# code in this class, other classes you may want create, other assemblies you may want to reference — anything at all. However, it's more practical to use at least HTML skeleton in your *.aspx pages and add server-side code using <%@ ... %> syntax where you need it.

—SA
 
Share this answer
 
v2
Comments
sraman222 9-May-12 10:08am    
the thing is end user cannot type any html or c#. i need to show a design screen just like VS so they will pick the required control...
Sergey Alexandrovich Kryukov 9-May-12 10:20am    
No, no. This is your problem. Yes, he can. I'm just answering to your basic question -- how to generate a page from scratch. You task is to add the HTML-generating code which would take data from user-entered data and put it in your page.
--SA
sraman222 9-May-12 10:25am    
yes, i got your point,thanks i got an idea from this... i have to save the design created by user somewhere and should have a page to render by the design selected by the user... will it work fine for multiple pages?
Sergey Alexandrovich Kryukov 9-May-12 11:40am    
Sure. Yes, it will work for multiple pages as well, if you think about it.
Will you accept this answer formally (green button)? -- thanks.
--SA
Sandeep Mewara 9-May-12 11:38am    
My 5! Someone downvoted it.

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