Click here to Skip to main content
16,015,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai confirm message is not working in my project. The Problem is i am using javascript function to validate the controls and calling it on click of button i.e Onclientclick() event. Again in server side i am calling confirm javascript to same button. Like below
btnClick.Attributes.Add("onclick", "if(confirm('Do u like to Continue?')) { document.getElementById('hdnTxt').value=1 } else { document.getElementById('hdnTxt').value=0;}");


in aspx page i am calling like this
<asp:ImageButton runat="server" ID="btnSave" ImageUrl="~/Images/16_L_save.gif" OnClientClick="return ShowConfirmation();" Height="15px" Width="15px" ToolTip="Save"  OnClick="btnClick_Click">


now confirm box is not coming,if i remove OnClientClick="return ShowConfirmation();" in button event, it works fine. But i need both to work @ same time

How can i solve this problem
Posted
Updated 8-Mar-11 19:52pm
v2

1 solution

But i need both to work @ same time
Only one can work at a time. Internally, at the time of rendering both results in client side onclick event. Thus, one overrides other.

If you want execution written in both, then keep only one and append the operation in it. Like:
OnClientClick="if(confirm('Do u like to Continue?')) { document.getElementById('hdnTxt').value=1 } else { document.getElementById('hdnTxt').value=0;}; return ShowConfirmation();"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900