Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - ASP viewstate persistence

 
Thread Tools Search this Thread
Old 05-18-2006, 09:52 AM   #1
Default ASP viewstate persistence


What would be the correct way to do this:

Page A:
ComboBox with values A/B/C
Button which redirects to page B.

Page B.
Button which redirects to Page A.

Start page A, combo box has the value A.
Now if i change the combo box in page A to the value B.
Click on the button which takes my to Page B.
Click on the button which takes me back to page A.

Then the viewstate for the combo has been reset to the value A.

So what are the correct way to handle this persistance ?

And what if i need to return values from page B to page A ?
Like a flag which indicates if page B has been cancelled.
In page A check if page B was cancelled and do different stuff.
How is this done ?

I know i can send parameters to page B like this asp?id=10 etc.
Do i need to do it the same way when sending back to page A ?


What i'm actually are going to do is have a datagrid + 4 comboboxes in
page A.
And a add new record function which will redirect to page B for input
of 6 values.
Then goback to page B and refresh the dataset if page B was not
cancelled.
If cancelled then display the same state for the comboboxes and the
datagrid
as before redirecting to page B.

I'm new to this so need some pointers .



Dst
  Reply With Quote
Old 05-18-2006, 12:47 PM   #2
Vlad Iliescu
 
Posts: n/a
Default Re: ASP viewstate persistence

I think the querystring aproach would be the simplest way to go about.
Another aproach would be to use cross-page postbacks, but that would be
a bit messy (you would have to keep the values for the comboboxes
somewhere in page B, and then re-read them from A). Also, the Session
object is an alternative, but I've been taught to stay away from it

  Reply With Quote
Old 05-18-2006, 01:51 PM   #3
Florian Doyon
 
Posts: n/a
Default Re: ASP viewstate persistence

Do you absolutively need to have two separate pages?

Why not use either :

Option 1 :
Code:
<asp:Panel runat=server id=pStepOne visible=true> ... <asp:button runat=server id= btShowStepTwo onClick='btShowStepTwo_Click'/> </asp:Panel> <asp:Panel runat=server id=pStepTwo visible=false> ... <asp:button runat=server id= btShowStepOne onClick='btShowStepOne_Click'/> </asp:Panel>

Option 2 : Use the ASP:MultiViews
<asp:MultiView runat="server" ActiveViewIndex="0">
<asp:View>view one </asp:View>
<asp:View>view two</asp:View>
</asp:MultiView>
<asp:button runat=server onclick="btSwitch_Onclick" text="Switch
views"/>

Option 3: create two usercontrols, so you can reuse them on several
pages

Hope that helps!

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump