Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Using JavaScript with WebImageButton
posted

I'm trying to do a simple Delete Confirm using javascript on the click of a WebImageButton & I cannot get it to work. I know the function is fine because if I use a regular .net button it works with no problem. Please let me know if I'm missing something. I keep getting a - Can't eval return ShowConfirm('Are you sure?')"

Button ASPX code:

 

 

 

<

 

 

igtxt:WebImageButton ID="DeleteBtn" runat="server" Text="Delete"

 

 

Height="20px" Width="44px"

 

 

AutoSubmit="true">

 

 

<ClientSideEvents Click="return ShowConfirm('Are you sure?')" /></igtxt:WebImageButton

>

Javascript Definition:

<

 

script type="text/javascript">function ShowConfirm(MsgTxt) {

 

if (confirm(MsgTxt))

{

return true; }

 

else

{

return false; }

}

</script>

Parents
No Data
Reply
  • 65
    posted

    I was able to get it to start displaying the confirm dialog by removing the return in the following code:

    <ClientSideEvents Click="return ShowConfirm('Are you sure?')" />

    The problem now is that now matter whether the user clicks the OK button or the Cancel button the control posts back to the server. i tried turning of the autopost property but then I dont know how to make it postback when they hit OK.

Children
No Data