Sample for Alerting user

Discussion in 'ASP .Net Web Controls' started by susie, Dec 3, 2003.

  1. susie

    susie Guest

    I need a sample to alert user to save the data entry when
    he closes the browser.

    When a user close the browser, a message box with
    following open pops up:

    Do you want to save the data before exit?
    Yes No Cancel

    Can anyone help? I know I need a client script to generate
    the msgbox. However I need a sample.

    Thank you very much!
     
    susie, Dec 3, 2003
    #1
    1. Advertising

  2. susie

    Kul Guest

    Check documentation for OnbeforeUnload and OnUnload event in msdn.

    Here is some sample code for you, which clicks a button present in form when
    user navigates out of this page.

    <HTML>
    <HEAD>
    <script language="javascript">
    function ClickSaveBtn(btnName)
    {
    var oObject = document.all.item(btnName);
    if (oObject != null)
    {
    oObject.click();
    }
    }
    </script>
    </HEAD>
    <body text="#000000" onbeforeunload="ClickSaveBtn('saveFormDetails')"
    bgColor="#ffffff" leftMargin="0" topMargin="0"
    onload="setPageHeadingAndStatus('EDUCATION',2,8)" rightMargin="0">
    <form id="MyForm" method="post" runat="server">
    .....
    ...//create a button control here with id = "saveFormDetails"

    </form>


    regards

    -Kul


    "susie" <> wrote in message
    news:050401c3b948$20c08e60$...
    > I need a sample to alert user to save the data entry when
    > he closes the browser.
    >
    > When a user close the browser, a message box with
    > following open pops up:
    >
    > Do you want to save the data before exit?
    > Yes No Cancel
    >
    > Can anyone help? I know I need a client script to generate
    > the msgbox. However I need a sample.
    >
    > Thank you very much!
    >
     
    Kul, Dec 3, 2003
    #2
    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. Jake
    Replies:
    0
    Views:
    566
  2. Peter Aitken

    Alerting the user from code behind

    Peter Aitken, Jul 31, 2004, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    117
    Peter Aitken
    Aug 2, 2004
  3. Farrel Lifson

    RCAP - Common Alerting Protocl for Ruby

    Farrel Lifson, Nov 3, 2009, in forum: Ruby
    Replies:
    1
    Views:
    104
    Farrel Lifson
    Nov 3, 2009
  4. Farrel Lifson
    Replies:
    0
    Views:
    110
    Farrel Lifson
    Apr 6, 2011
  5. Laser Lips
    Replies:
    8
    Views:
    141
    Laser Lips
    Jul 6, 2010
Loading...

Share This Page