Another basic question: How to call and show one Web Form from another Web Form?

R

Rob R. Ainscough

I'm new to ASP.NET and Web Development (Primarily a VB6, VB.NET, SQL Server
developer).

I've got an ASP.NET Form (Web Form) that contains various info/controls.
One of these controls is a "Continue" button. I want to load another
ASP.NET Web Form in my project when the "Continue" button is pressed.

I can add VB.NET code to the bn_Continue_Click event such as:

Private Sub bn_Continue_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bn_Continue.Click

Dim MyWebForm As New AWebForm

' What do I use to load MyWebForm in the current browser window?

End Sub

This is very basic, but I've read two ASP.NET books and searched for a
solution and so far all seem to require HTML based coding that loads the
AWebForm.aspx in a separate browser window (which is NOT what I want)?

Also, am I being unrealistic in wanting to NOT keep resorting back to HTML
coding? I find the HTML syntax mind boggling, difficult and time consuming
to sift thru, and just very confusing and verly syntax heavy.

Thanks, Rob.
 
S

Steve C. Orr [MVP, MCSD]

You can do it with one line of code, such as these:

Response.Redirect("WebForm2.aspx")
'or
Server.Transfer("WebForm2.aspx")
 
A

Aaron Corcoran

Rob,

As Steve has pointed out you can use on of the above two methods. One
thing that you may want to consider is the use of panels. Panels
simply provide an alternative to the splitting of pages and can offer a
wizard style approach in a single page. For instance, let's say that
you have two panels. The first panel contains a form where users fill
out their personal information. This panel is set to visible and has a
continue button on it.

Panel2 contains employment information that the user will fill out.
This panel is initially marked with its visible property as false.

Once the user fills in their personal information and clicks the
continue button, you could simply do:

Panel1.Visible = False
Panel2.Visible = True

Thus hiding the personal information panel and showing the employment
information panel.

Again, this might not be desired, but I wanted to offer you an
alternative that I have found helpful when designing Web applications.

Aaron
 
R

Rob R. Ainscough

Steve & Aaron,

Thank you for the response, yes the Response.Redirect works great!

I was thinking of using panels, but the processing I'm going thru requires
some pages that require more than a Panel can offer (in terms of physical
readability).

ASP.NET and Web development is all new to me, so I've got this love/hate
thing going on with it :)

Rob.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top