RE: HTML Button Not Submitting Page

From: Suresh (anonymous_at_discussions.microsoft.com)
Date: 03/11/04


Date: Thu, 11 Mar 2004 08:51:11 -0800

I wasn't sure if return from Confirm call submitted the form when you had ClientSideValidation turned on??

My experience has been that if you have Clientsidevalidation set then .NET will wire the validation handler to the onclick method of the button. That event will override yours.

But it's interesting you say that it confirms but doesn't submit. I would've expected the opposite.

You may want to try setting CausesValidation for the HTMLButton to false and inside your handler method call Page_ClientValidate() and only return true if operation is confirmed and the page is validated.

HTH,
Suresh.
     
     ----- Alphonse Giambrone wrote: -----
     
     Thanks to info from Steven Cheng I am able to use an HTML button on my aspx
     page in order to wrap text in it.
     I am using it to delete a record in a database and it works.
     My only problem is that I want to include javascript to confirm the deletion
     before submitting.
     I have a javascript function that prompt for confirmation and returns
     true/false.
     For a regular server side button I add it as follows in the page load event
     and it works fine:
     
     btnDelete.Attributes.Add("onclick", "return ConfirmDelete();")
     
     However if I add it the same way to the HTML button, the prompt works, but
     the page is not submitted.
     Looking at the source, this is what is rendered for the event with and
     without my added function:
     
     onclick="return ConfirmDelete(); {if (typeof(Page_ClientValidate) !=
     'function' || Page_ClientValidate())
     __doPostBack('U_PageLinks1$btnDelete','')} "
     
     onclick="{if (typeof(Page_ClientValidate) != 'function' ||
     Page_ClientValidate()) __doPostBack('U_PageLinks1$btnDelete','')} "
     
     Any suggestion on how I can confirm the delete and still submit the page?
     
     TIA
     
     --
     
     Alphonse Giambrone
     Email: a-giam at customdatasolutions dot us