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

Get confirmation from popup before running code in event handler

P: n/a
mg
I would like the code in the click event handler of an ImageButton to run only after a popup confirm appears and the user clicks its 'OK'. The 'CauseValidation' property of the ImageButton is 'true'
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Place this in the Page_Load event. Note that the first parameter of the Add
method is the JavaScript "onclick" event and the second parameter is a
JavaScript statement.

ImageButton1.Attributes.Add("onclick", "if (!confirm('Are you sure?'))
return false;");

"mg" <mg@theworld.com> wrote in message
news:DB**********************************@microsof t.com...
I would like the code in the click event handler of an ImageButton to run

only after a popup confirm appears and the user clicks its 'OK'. The
'CauseValidation' property of the ImageButton is 'true'
Nov 18 '05 #2

P: n/a
This is mostly an academic question....
I agree this will work in this instance. However, is there a way to
tell/specify what order the events will fire when you have a bunch of them?
"Candan Akyol" <cakyol@-spamwars-veripark.com> wrote in message
news:uv**************@TK2MSFTNGP09.phx.gbl...
Place this in the Page_Load event. Note that the first parameter of the Add method is the JavaScript "onclick" event and the second parameter is a
JavaScript statement.

ImageButton1.Attributes.Add("onclick", "if (!confirm('Are you sure?'))
return false;");

"mg" <mg@theworld.com> wrote in message
news:DB**********************************@microsof t.com...
I would like the code in the click event handler of an ImageButton to
run only after a popup confirm appears and the user clicks its 'OK'. The
'CauseValidation' property of the ImageButton is 'true'

Nov 18 '05 #3

P: n/a
What do you mean "a bunch of them"? Events such as the Javascript one
described below will happen first, as this will prevent the postback from
taking place unless confirmed. On the server side, the page load event will
always fire first, then the onclick event.

"David Jessee" <dj*****@houston.rr.com> wrote in message
news:OS***************@TK2MSFTNGP09.phx.gbl...
This is mostly an academic question....
I agree this will work in this instance. However, is there a way to
tell/specify what order the events will fire when you have a bunch of them?

"Candan Akyol" <cakyol@-spamwars-veripark.com> wrote in message
news:uv**************@TK2MSFTNGP09.phx.gbl...
Place this in the Page_Load event. Note that the first parameter of the

Add
method is the JavaScript "onclick" event and the second parameter is a
JavaScript statement.

ImageButton1.Attributes.Add("onclick", "if (!confirm('Are you sure?'))
return false;");

"mg" <mg@theworld.com> wrote in message
news:DB**********************************@microsof t.com...
I would like the code in the click event handler of an ImageButton to

run
only after a popup confirm appears and the user clicks its 'OK'. The
'CauseValidation' property of the ImageButton is 'true'


Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.