|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
OnClientClick with confirm doesn't workMy GridView has a button with OnClientClick="if (!confirm('Delete?')) return
false;" which must deletes a record only if the user click on the OK button of the confirmation window, but if he clicks on the Cancel button the record is also deleted, that is, it is not working. Could someone help me? On 8 Jan, 14:00, Mauricio Pires
<MauricioPi***@discussions.microsoft.com> wrote: > My GridView has a button with OnClientClick="if (!confirm('Delete?')) return Hi Mauricio,> false;" which must deletes a record only if the user click on the OK button > of the confirmation window, but if he clicks on the Cancel button the record > is also deleted, that is, it is not working. > > Could someone help me? Had same problem myself some time ago. Solution was to use OnClientClick="return confirm('Delete?');" Hope this helps. Steve You need to also set the Submit behavior I think. If you leave it at default
a Submit button is generated which will always submit. If you use UseSubmitBehavior == false the button gets generated as a button in which case you can control submission manually: <asp:Button runat="server" id="myButton" UseSubmitBehavior="False" OnClientClient="if (!confirm("Delete?") return; window.forms[0].submit();" /> +++ Rick --- Show quoteHide quote "Mauricio Pires" <MauricioPi***@discussions.microsoft.com> wrote in message news:F0F4070E-7E4E-4B30-803F-6DE295603050@microsoft.com... > My GridView has a button with OnClientClick="if (!confirm('Delete?')) > return > false;" which must deletes a record only if the user click on the OK > button > of the confirmation window, but if he clicks on the Cancel button the > record > is also deleted, that is, it is not working. > > Could someone help me? > > rstrahl,
You don't need to use the UseSubmitBehavior in this instance as the OnClientClick="return confirm('Delete?');" will return false if the user selects No on the confirmation box, which in turn blocks the button click event from bubbling any further. i.e. stopping the form submission. OnClientClick="return confirm('Delete?');" is basically a shorthand version of your code. Steve Show quoteHide quote On Jan 14, 2:32 am, "rstrahl" <rickstr***@hotmail.com> wrote: > You need to also set the Submit behavior I think. If you leave it at default > a Submit button is generated which will always submit. If you use > UseSubmitBehavior == false the button gets generated as a button in which > case you can control submission manually: > > <asp:Button runat="server" id="myButton" UseSubmitBehavior="False" > OnClientClient="if (!confirm("Delete?") return; > window.forms[0].submit();" /> > > +++ Rick --- > -- > Rick Strahl > West Wind Technologieswww.west-wind.com/weblog > > "Mauricio Pires" <MauricioPi***@discussions.microsoft.com> wrote in message > > news:F0F4070E-7E4E-4B30-803F-6DE295603050@microsoft.com... > > > My GridView has a button with OnClientClick="if (!confirm('Delete?')) > > return > > false;" which must deletes a record only if the user click on the OK > > button > > of the confirmation window, but if he clicks on the Cancel button the > > record > > is also deleted, that is, it is not working. > > > Could someone help me?
Other interesting topics
Check for table
Adapting ReorderList WebControl for rendering dynamic html SelectCommand with SelectParameters.Add UpdateProgress animated gif freezes in ajax postback RE: Gridview templaye button control Re: FTP download Validator for checkbox is not getting triggered always RE: SelectCommand with SelectParameters.Add Re: Databinding Syntax Not Working in ListView LayoutTemplate You_need_fast_money??????º |
|||||||||||||||||||||||