When/how redirect to a different ASP .NET page

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi;

The ASP .NET book I have only talks about putting everything in a single
aspx and aspx.cs file. However, it seems to me you want to redirect to a
different page/class for each logical page. Which brings up 2 questions:

1) When the user presses submit, is best practice to immediately redirect to
the new page and have that read the controls from the first page. Or do you
read the values from the controls and then redirect with the read values in
an object.

2) How do I redirect to another page of mine?
 
Hi;

The ASP .NET book I have only talks about putting everything in a single
aspx and aspx.cs file. However, it seems to me you want to redirect to a
different page/class for each logical page. Which brings up 2 questions:

1) When the user presses submit, is best practice to immediately redirect to
the new page and have that read the controls from the first page. Or do you
read the values from the controls and then redirect with the read values in
an object.

2) How do I redirect to another page of mine?


Not any more.

In ASP.NET, the usual practice is to process form variables in the
code-behind page.

Generally, you check for postback, and read the controls there and
process as you wish.


To redirect, you use the Response.Redirect method, similar to ASP.


By the way, that must be a very simple book if it deals with projects
with only one page/class?

Take a look at some of the examples provided on ASP.NET or
GotDotNet.com


-- ipgrunt
 
David said:
Hi;

The ASP .NET book I have only talks about putting everything in a single
aspx and aspx.cs file. However, it seems to me you want to redirect to a
different page/class for each logical page. Which brings up 2 questions:

1) When the user presses submit, is best practice to immediately redirect to
the new page and have that read the controls from the first page. Or do you
read the values from the controls and then redirect with the read values in
an object.

2) How do I redirect to another page of mine?

When you design a form in asp.net, all events basically go to the same
page that display the form. You may, however, let two or more different
pages inherit from one code-behind Page class, like this:

class MyFormPage: Page
|
-- class FormDisplayPage -- ShowForm.aspx
|
-- class FormHandlePage --- ConfirmSubmit.aspx
\-- SubmitDone.aspx
 
Hi Dave,

Yes, the redirecting to a different page(cross-page posting) does be an
existing problem in the current ASP.NET version. And the problem has been
addressed in the ASP.NET2 which has complete cross-page posting model
support.
Currently in ASP.NET1.X, we may need to use serverside's Server.Transfer to
workaround such scenario.

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top