Changing forms

  • Thread starter Thread starter Jeremy Ames
  • Start date Start date
J

Jeremy Ames

I am having problems with Server.Transfer when I try to change pages. I have
a page that I have created just to process the information from a previous
web form and then to go to the next page. The update routine puts a hidden
text box into the web form and populates it with an id from a database. When
I reach the next page, the id is not sent, and in fact the URL in the
address bar does not even change. Is there a better way for me to do this?
 
Hi Jeremy,

A couple of quick insights on this will help I think. In the first
webform when you transfer the page then no other events on that page
will occur.. The indexChanged events (et.al) will not fire at this
point. So in your Page_Load routine for page one you could put in a
statement similar to this:

if (Page.IsPostBack) {Server.Transfer("secondpage.aspx");

If you read the data from page one and always transfer to page two
then page two will never be a postback (sans autopostback controls).
That is, if you are just displaying information from the first page
you will always be transferring to the page two as a new page (not a
postback).

In any case you can retrieve the information from the form elements on
the first page by adding something like this to page two:

string myvar_onpagetwo = Request.Form["someFormElementName"];

~~~~~~~~~~~~~
Tommie Carter
www.premiertechnology.com
 
Well I am posting the information on a blank form, then submitting the
server.transfer. The first page is just to update the database. The second
page shows the updated information. There should be no postback information
at all. I am reading the form collection of the request class. Here is my
code:

CreateEmployee.aspx.cs (first page)
private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

string [] sarName = GetEmployeeName((string) Request.QueryString["Id"]);

CreateEmployeeRecord(sarName);

lbEmployees.Value = FindNewEmployee(sarName);

Server.Transfer("EmpDetail.aspx", false);

}



EmpDetail.aspx.cs (second page)

private void Page_Load(object sender, System.EventArgs e)

{

BuildEmployeeDetail(Convert.ToInt32(Request.Form["lbEmployees"]));

lbEmployees.Value = Request.Form["lbEmployees"];

}


Hi Jeremy,

A couple of quick insights on this will help I think. In the first
webform when you transfer the page then no other events on that page
will occur.. The indexChanged events (et.al) will not fire at this
point. So in your Page_Load routine for page one you could put in a
statement similar to this:

if (Page.IsPostBack) {Server.Transfer("secondpage.aspx");

If you read the data from page one and always transfer to page two
then page two will never be a postback (sans autopostback controls).
That is, if you are just displaying information from the first page
you will always be transferring to the page two as a new page (not a
postback).

In any case you can retrieve the information from the form elements on
the first page by adding something like this to page two:

string myvar_onpagetwo = Request.Form["someFormElementName"];

~~~~~~~~~~~~~
Tommie Carter
www.premiertechnology.com
 
Jeremy,

Try substituting this line and see if you get the form values in
the second page. Also check the html being generated since all asp.net
does is generate html for your browser -- if anything is not correct
in the html then simply work backwards to identify the issue on the
asp side of the code.

Server.Transfer("EmpDetail.aspx");

~~~~~~~~~~~~~
Tommie Carter
www.premiertechnology.com
--
Jeremy Ames said:
Well I am posting the information on a blank form, then submitting the
server.transfer. The first page is just to update the database. The second
page shows the updated information. There should be no postback information
at all. I am reading the form collection of the request class. Here is my
code:

CreateEmployee.aspx.cs (first page)
private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

string [] sarName = GetEmployeeName((string) Request.QueryString["Id"]);

CreateEmployeeRecord(sarName);

lbEmployees.Value = FindNewEmployee(sarName);

Server.Transfer("EmpDetail.aspx", false);

}



EmpDetail.aspx.cs (second page)

private void Page_Load(object sender, System.EventArgs e)

{

BuildEmployeeDetail(Convert.ToInt32(Request.Form["lbEmployees"]));

lbEmployees.Value = Request.Form["lbEmployees"];

}


Hi Jeremy,

A couple of quick insights on this will help I think. In the first
webform when you transfer the page then no other events on that page
will occur.. The indexChanged events (et.al) will not fire at this
point. So in your Page_Load routine for page one you could put in a
statement similar to this:

if (Page.IsPostBack) {Server.Transfer("secondpage.aspx");

If you read the data from page one and always transfer to page two
then page two will never be a postback (sans autopostback controls).
That is, if you are just displaying information from the first page
you will always be transferring to the page two as a new page (not a
postback).

In any case you can retrieve the information from the form elements on
the first page by adding something like this to page two:

string myvar_onpagetwo = Request.Form["someFormElementName"];

~~~~~~~~~~~~~
Tommie Carter
www.premiertechnology.com
--
Jeremy Ames said:
I am having problems with Server.Transfer when I try to change pages. I have
a page that I have created just to process the information from a previous
web form and then to go to the next page. The update routine puts a hidden
text box into the web form and populates it with an id from a database. When
I reach the next page, the id is not sent, and in fact the URL in the
address bar does not even change. Is there a better way for me to do this?
 
Back
Top