Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to retainig view state ??

Status
Not open for further replies.

jambai

Programmer
Mar 21, 2007
58
US
I have created a ASP.NET application and created two forms (Webform1.aspx & Webform2.aspx).

I am displaying the Webform2.aspx based on the Webform1.aspx input,
For example if the user didn't fill some field in Webform1.aspx then I am showing the Webform2.aspx as a alert message, and I am opening this Webform2.aspx using window.open

From the Webform2.aspx the user may go back to the Webform1.aspx and fill the values or he may submitting the Webform1.aspx , from the Webform2.aspx without filling the required fields in Webform1.aspx

When I am submitting the Webform1.aspx from Webform2.aspx, the values which I entered in Webform1.aspx is not retaining.

I have already set the page, controls viewstate=true in Webform1.aspx

I am Using the below code to submitting the Webform1.aspx from Webform2.aspx

window.opener.location.href = "../order/ExistingOrder.aspx?type=save&QLoginid="+str.replace(/&/,"%26")+"&OrderId="+orderId.value
 
that's alot of back and forth between forms and you have to verify complex query strings. why not use a validation summary and field validators?

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I agree with jmeckley, but if you really want to keep the values it is better just use a JavaScript Back button. Going back, like clicking your browsers back button should retain the values entered, where as using a hyperlink to lead the user forward to the first page will not retain the entered values.

Just put this into your aspx page, run it, and click the button to test it.
Code:
<input type=button value="Back" onClick="history.go(-1)">

Senior Software Developer
 
But I need to submit the page when I click go back option in the webform2.aspx.

Thanks
Jambai
 
Why not just use a wizard control that blocks progress if the data in a given step is invalid? Less complicated and more usable.

MCP, MCTS - .NET Framework 2.0 Web Applications
 
also viewstate is only present for the current life of the page. it's alive from initial load, through repeated postbacks. if you leave the page and then return, viewstate is reset. this is by design.

It sounds like your attempting to use asp.net philosophy with a web scripting methodology. this won't work. there probally is a solution to your task, but that is not how the framework was intended for use.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top