Not allow submit if data changed

Discussion in 'ASP .Net' started by David, May 10, 2006.

  1. David

    David Guest

    Using VS2005 and .Net 2.0
    I want to be able to keep the user from moving to another web page if they
    have selected the "Edit" link button on a FormView (or any view for that
    matter), have changed any of the data in bound controls and do not click on
    the "Update" link button. Can anyone help? Thanks.

    David
    David, May 10, 2006
    #1
    1. Advertising

  2. this is just simple javascript. create a variable that is updated on any
    value changed (by attaching script to the onchange event of each control).

    the following is air code

    <body onunload="return doConfirm()" onsubmit="changesSaved =true;">
    <script>
    var changesSaved = true;
    function doConfirm() {
    if (changesSaved ) return window.confirm("You have not saved you
    changes, cancel navigate?");
    return true;
    }
    </script>
    <input type=text onchange="changesSaved =false;">

    note: at form load, with client script you could attach the onchange handler
    (be sure to delegate any existing routines).

    -- bruce (sqlwork.com)

    "David" <> wrote in message
    news:eS%...
    > Using VS2005 and .Net 2.0
    > I want to be able to keep the user from moving to another web page if they
    > have selected the "Edit" link button on a FormView (or any view for that
    > matter), have changed any of the data in bound controls and do not click
    > on the "Update" link button. Can anyone help? Thanks.
    >
    > David
    >
    bruce barker \(sqlwork.com\), May 10, 2006
    #2
    1. Advertising

  3. David

    David Guest

    The textbox ia asp textbox so I have to set attribute in Sub Page_Load.
    However, when I try to reference the control I get an error. The textbox is
    in a FormView inside a EditItemTemplate section. How do I reference this
    control in my VB sub? Thanks.

    David

    "bruce barker (sqlwork.com)" <> wrote
    in message news:...
    > this is just simple javascript. create a variable that is updated on any
    > value changed (by attaching script to the onchange event of each control).
    >
    > the following is air code
    >
    > <body onunload="return doConfirm()" onsubmit="changesSaved =true;">
    > <script>
    > var changesSaved = true;
    > function doConfirm() {
    > if (changesSaved ) return window.confirm("You have not saved you
    > changes, cancel navigate?");
    > return true;
    > }
    > </script>
    > <input type=text onchange="changesSaved =false;">
    >
    > note: at form load, with client script you could attach the onchange
    > handler (be sure to delegate any existing routines).
    >
    > -- bruce (sqlwork.com)
    >
    > "David" <> wrote in message
    > news:eS%...
    >> Using VS2005 and .Net 2.0
    >> I want to be able to keep the user from moving to another web page if
    >> they have selected the "Edit" link button on a FormView (or any view for
    >> that matter), have changed any of the data in bound controls and do not
    >> click on the "Update" link button. Can anyone help? Thanks.
    >>
    >> David
    >>

    >
    >
    David, May 10, 2006
    #3
  4. David

    David Guest

    I think your doConfirm should be if (!changesSaved) ... correct?

    David
    "bruce barker (sqlwork.com)" <> wrote
    in message news:...
    > this is just simple javascript. create a variable that is updated on any
    > value changed (by attaching script to the onchange event of each control).
    >
    > the following is air code
    >
    > <body onunload="return doConfirm()" onsubmit="changesSaved =true;">
    > <script>
    > var changesSaved = true;
    > function doConfirm() {
    > if (changesSaved ) return window.confirm("You have not saved you
    > changes, cancel navigate?");
    > return true;
    > }
    > </script>
    > <input type=text onchange="changesSaved =false;">
    >
    > note: at form load, with client script you could attach the onchange
    > handler (be sure to delegate any existing routines).
    >
    > -- bruce (sqlwork.com)
    >
    > "David" <> wrote in message
    > news:eS%...
    >> Using VS2005 and .Net 2.0
    >> I want to be able to keep the user from moving to another web page if
    >> they have selected the "Edit" link button on a FormView (or any view for
    >> that matter), have changed any of the data in bound controls and do not
    >> click on the "Update" link button. Can anyone help? Thanks.
    >>
    >> David
    >>

    >
    >
    David, May 10, 2006
    #4
    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. Replies:
    1
    Views:
    671
    Rosanne
    Oct 11, 2005
  2. Jeff
    Replies:
    2
    Views:
    925
    clintonG
    Sep 19, 2006
  3. Ryan Taylor
    Replies:
    1
    Views:
    669
    Ryan Taylor
    Sep 9, 2004
  4. Replies:
    2
    Views:
    142
  5. mxbrunet
    Replies:
    1
    Views:
    201
Loading...

Share This Page