ASP.NET and Page Navigation

R

Raj

Hi,

I am struggling with this for quite some time and thought will seek
your help on it. What I am doing is, I have Page1.aspx where user
inputs text into text boxes and also has a link to Page2.aspx. On
Page2.aspx user will input some more info and has two buttons 'Save'
and 'Cancel'. Both the buttons on Page2.aspx should take the user back
to Page1.aspx and the data entered by the user on Page1 should not be
lost. So, Response.Redirect is not an option since you lose data.
I tried PostBackURL and 'javascript:history.go(-1)' and that works but
here is my problem.

If user enters invalid data on Page2, clicking on 'Save' button should
not take the user back to Page1. But if I use PostBackURL it is doing
that way and I don't know how to control the event. In otherwords I
want the event to run only when valid data is entered. I can do
validation in btnSave_Click but don't know how to control the flow.

I will truly appreciate your input on the issue. Thank you,

Raj
 
J

Jester98x

Raj said:
Hi,

I am struggling with this for quite some time and thought will seek
your help on it. What I am doing is, I have Page1.aspx where user
inputs text into text boxes and also has a link to Page2.aspx. On
Page2.aspx user will input some more info and has two buttons 'Save'
and 'Cancel'. Both the buttons on Page2.aspx should take the user back
to Page1.aspx and the data entered by the user on Page1 should not be
lost. So, Response.Redirect is not an option since you lose data.
I tried PostBackURL and 'javascript:history.go(-1)' and that works but
here is my problem.

If user enters invalid data on Page2, clicking on 'Save' button should
not take the user back to Page1. But if I use PostBackURL it is doing
that way and I don't know how to control the event. In otherwords I
want the event to run only when valid data is entered. I can do
validation in btnSave_Click but don't know how to control the flow.

I will truly appreciate your input on the issue. Thank you,

Raj

Hi Raj,

It sounds like a wizard control may help you out here. Also use the
data validation controls to assist with data checks. You can use
page.isvalid to check if the page is valid and then continue processing
in which ever direction you want.

Stece
 
B

BillE

Is it necessary to have two pages?
Instead, maybe you could put two panels on the same page, and hide and
display them on postback when the buttons are clicked.

-Bill
 
J

Jesse Liberty

Setting aside the fact that I think you've created a bit of extra complexity
for yourself with the two pages, I think you need to sort out the various
issues:

1. Javascript (let's set that aside for now and stick with traditional
server-side processing)
2. Validation
3. State management

You are right that if you move from page 1 - 2 and then back to 1 page 1's
controls will no longer have view state, but of course you can stash their
values in session state and restore their values manually, which is not
onerous.

Second, you can use the standard validation controls on page 2 and not leave
page 2 until and unless the controls are all valid

What is really sounds like, however, is that you want the second page to be
a "modal dialog" for page 1, in which case you don't really need to shut
page 1 (and thus, it can maintain its state), you just need to have page 2,
on save, validate itself, and if valid, populate session state.

Ah, but here's the problem, there is no easy way for page 2 to notify page 1
that it is now done and there is something nifty for page 1 in session
state.

You have a few choices. The ugly but perhaps easiest way is for page 1 to
look in session state every couple seconds to find a signal: "good data
available" or "page 2 failed". If it finds the former, it gobbles up the
data it needs and populates its additional fields. I'll look into other
ways for one page to signal another, but ASP.NET isn't (as far as I know)
really set up for that.

Enjoy.

-j
 
R

Raj

Thank you very much guys for your prompt response. I can not use
standard validation controls on Page2 which means I have to validate
when user submits 'Submit' on Page2.

I have decided to combine both pages into a single page and place them
in two different panels. I have also looked into wizard control but
will be using that when I am dealing with more than two pages probably.

Thanks guys for your valuable input.

Raj
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top