loading dinamically webforms

G

Guest

Hello,
My doubt is arround webforms and its load programatically. I have a class
derived from System.Web.UI.Page (clsWebForm), with their own properties and
methods. Inside another webform I instanciate clsWebForm, filling their
properties, but how can I load the webform inside the web explorer?

public class clsWebForm : System.Web.UI.Page
{
....
}

In another page:

private void cmdOk_Click(object sender, System.EventArgs e)
{
clsWebForm clsFrm = new clsWebFormt();
// here I want to load the new web form bu I do not
how!!!!
}



Thanks!
 
S

Scott Allen

private void cmdOk_Click(object sender, System.EventArgs e)
{
clsWebForm clsFrm = new clsWebFormt();
// here I want to load the new web form bu I do not
how!!!!
}

If you want to move processing to a second web form there are a few
techniques that can work. There is Response.Redirect, Server.Transfer,
and in 2.0 there is a cross page post back.

I have an article on these topics here:
http://odetocode.com/Articles/421.aspx

What you don't want to do is create a webform with the new operator,
as you really need ASP.NET's help to properly create and initialize a
form and get it into the processing pipeline.

HTH,
 
G

Guest

Thanks Scott, but I 'm deceived because I thought I could treat webForms as
pure classes and manipulate so. So, I will use Response... and pass Request
parameters until migrate to ASP 2.0.

Best regards,

josepm
 
S

Scott Allen

Webforms are just classes, and you can technically new one up and
manipulate it ... but ...

To do this the right way you need the runtime to create and init the
form via PageParser.GetCompiledPageInstance, because that method knows
who to call for code-generation of the ASPX page, who to call to wire
up implicit event handlers, and all the other "stuff" that needs to
happen for a webform that is going to be part of an HTTP request and
render to the client.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top