 |
| ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 29th, 2003, 09:56 AM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Dynamic creation of Web Pages
I have a question
If I create an object of a WebForm like
WebForm1 wf=new WebForm1();
How do I create a Web Page corresponding to this WebForm
Response.Redirect("wf.aspx");// This doesn't work. Why?? How do I make it work??
|
|

September 29th, 2003, 04:04 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
If you instantiate an instance of a class that is derived from System.Web.UI.Page (i.e. usually a webform) then you simply have an object instance of that class.
If you want to redirect to "webform1.aspx" then you could have to make this call:
Response.Redirect("webform1.aspx");
By passing the redirector "wf.aspx" you are redirecting to a page that isn't there (unless you also happen to have a real wf.aspx file in your project).
Keep in mind that when you redirect to another page, the framework is creating a brand new instance of the page's class. You can't instantiate your own instance of it and pass it to the redirector.
You can use the Transfer method to pass execution off to another page such that the transferred TO page sees the form post and querystring from the first page, but other than that there's not much you can do.
Peter
|
|

September 30th, 2003, 04:48 AM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
fine peter,
but what i'm tryin is to create a webform at runtime by takin in input from user. This is done offline and am tryin to build a windows utility in c# ASP.NET that will take in from user the no. of forms he wants and all the attributes he wishes to put on them.But that is a later part, as for now i need to know how do i create a webform dynamically and redirect to it at runtime?
|
|

September 30th, 2003, 12:05 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Now I'm more confused. How can you do something "offline" in ASP.Net? I understand if you were building a windows application that created web forms, otherwise I don't see how you are going to achieve this.
You'll need to save the an ASPX file if you want to "create" a web form. You can't redirect to a page that isn't there. That simple matter remains. Unless you get into more complex methods of ASP.Net, you need to have an ASPX page to point a browser to.
It sounds like you are attempting to build a windows client application that will generate ASP.Net pages. Once you have saved the ASPX to a server, then sure, you could launch the URL to that page on that server and the default browser would open up and display the page.
Peter
|
|

October 1st, 2003, 04:23 AM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
yes peter you are right
i am building a windows application that will generate webforms(offline, which can then be used by the user to post on any webserver and use them for his purpose) by taking in the input from the user. The question is how do i create this form and save it onto the server at runtime. Because once that is done it then redirecting to it is no problem.
|
|

October 1st, 2003, 08:28 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Are you going to be building pages that use purely inline server code? Cause you certainly can't deploy pages on the fly like you plan with codebehind.
All you need to do is save a new ASPX which contains all the stuff the user puts in from your win app and then copy or FTP that file to the right place on the web server. Shouldn't be too hard. If you have to do it by FTP you'll need to figure that out. I'm not sure if .Net has FTP functionality built in. Otherwise, it's just a matter of copying to the server's web folder.
You'll probably need to create a template file that the application will use then you need to "write" the html and other stuff that the VS visual designer would normally write. I don't know if there is a way to do this automatically from the component objects. I would highly doubt it is built in. The components know how to output the HTML for their own rendering to the browser, but not the html/script for a component in the ASPX. Seems like this would be a lot of work.
Peter
|
|
 |