L
lilfos
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!
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!