doPostBack

Discussion in 'ASP .Net' started by masoud bayan, Jan 17, 2005.

  1. masoud bayan

    masoud bayan Guest

    Hi ,

    I used your suggested code to replace doPostBack in my application, but it
    seems window.onbeforeunload is called before, window.__doPostBack, so it can
    not change the condition for showing warning message.
    I am using datagrid with links as ButtonColumn but I do not want
    onbeforeunload event called when they are clicked.

    Any suggestion?

    Thanks
    Masoud





    here are two approaches

    1) write a custom validator that sets the flag
    2) replace __doPostback with your own routine that sets the flag. note:
    submit buttons donot call __doPostback, so you must also catch the postback
    in the onsubmit handler.

    -- bruce (sqlwork.com




    Hi there,

    I have an asp.net page with essentially a "don't forget to save" pop-up
    that is called when the user attempts to navigate away from the page.
    The user has the option to cancel and prevent the page from unloading.

    Since the form data is posted back to the server and saved during a
    normal postback, I don't need to prompt unless the user is actually
    going to a different URL or closing the browser. Currently, I get
    around this with a hidden field called hidPromptToSave and by checking
    that in my function that onbeforeunload calls. I configured each
    control that causes a postback to set that value to false, which causes
    the function to exit without prompting.

    This worked when I could add the onclick attribute to the controls in
    the OnInit method in my code behind. Now, however, I have added a
    twist. I added paging to a datagrid and each page link causes a
    postback (naturally). Unfortunately, the page links are anchor tags
    with an href that calls doPostBack. I can't seem to find a way to add
    to the href or onclick attributes of these links. I've tried a whole
    lot of things both client-side and server-side.

    Assuming I won't ever find a way to add attributes to those links, can
    anyone suggest a different way to give a user the chance to save before
    closing or navigating away, but not doing this on postpack? One
    additional restriction is that we don't want to automatically save
    without asking and then let them continue.

    Thanks!
     
    masoud bayan, Jan 17, 2005
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.