By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,188 Members | 834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,188 IT Pros & Developers. It's quick & easy.

doPostBack

P: n/a
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

"bruce barker" <no***********@safeco.com> wrote in message
news:O5****************@TK2MSFTNGP11.phx.gbl...
1) could be any control thats supports validation on the page (must not be
empty)

2)

air code:

RegisterStartupScript("postback",@"
<script>
if (window.__doPostBack) {
window.__oldPostBack = window.__doPostBack;
window.__doPostBack = function(t, a) {
// add custom code here
window.__oldPostBack(t,a);
}
</script>
");

-- bruce (sqlwork.com)
"lilfos" <do**********@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
| Thanks Bruce.
|
| A couple of questions:
|
| 1. I would need to set a custom validator's "control to validate"
| property, right? If so, would that be the DataGrid? The links
| themselves are not controls and they are not available at design time.
|
| 2. How would I replace __doPostBack? I saw a reference to this in
| another post and tried things like oldPostBack = __doPostBack;
| __doPostBack = myPostBack, but this seemed to have not effect. I
| figure those were just interpreted as variable names rather than
| function names, so the functions themselves never changed.
| Thanks again.
|


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!


Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.