ASP.NET and Page Navigation

Discussion in 'ASP .Net' started by Raj, Oct 23, 2006.

  1. Raj

    Raj Guest

    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
    Raj, Oct 23, 2006
    #1
    1. Advertising

  2. Raj

    Jester98x Guest

    Raj wrote:
    > 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
    Jester98x, Oct 23, 2006
    #2
    1. Advertising

  3. Raj

    BillE Guest

    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

    "Jester98x" <> wrote in message
    news:...
    >
    > Raj wrote:
    >> 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
    >
    BillE, Oct 23, 2006
    #3
  4. 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

    --
    Jesse Liberty
    Microsoft MVP
    Author/ Programmer
    http://www.LibertyAssociates.com




    "Raj" <> wrote in message
    news:...
    > 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
    >
    Jesse Liberty, Oct 23, 2006
    #4
  5. Raj

    Raj Guest

    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


    Jesse Liberty wrote:
    > 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
    >
    > --
    > Jesse Liberty
    > Microsoft MVP
    > Author/ Programmer
    > http://www.LibertyAssociates.com
    >
    >
    >
    >
    > "Raj" <> wrote in message
    > news:...
    > > 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
    > >
    Raj, Oct 23, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Weatherford
    Replies:
    0
    Views:
    342
    Robert Weatherford
    Apr 12, 2004
  2. bienwell
    Replies:
    2
    Views:
    2,291
    bienwell
    Dec 6, 2005
  3. Replies:
    2
    Views:
    526
    Ranginald
    Apr 13, 2006
  4. Laurahn
    Replies:
    3
    Views:
    892
    Steven Cheng[MSFT]
    Feb 6, 2007
  5. Dmitry Klymenko
    Replies:
    2
    Views:
    114
    Richard Creer
    Jan 8, 2007
Loading...

Share This Page