forum

Home / DeveloperSection / Forums / asp:ImageButton click using javascript not working UI

asp:ImageButton click using javascript not working UI

Anonymous User 1974 02-Jun-2015
<asp:ImageButton ID="btnAdd"runat="server" AlternateText="AddNew"
     ImageUrl="../images/add.png" CausesValidation="true" OnClick="btnAdd_Click" />
<asp:Image ID="imgProceed" ImageUrl="~/Images/proceed.gif" runat="server"/>

Code Behind 

btnAdd.Attributes.Add("onclick", "return
false;"); //Adding client event to avoid submit for some validation
purpose
imgProceed.Attributes.Add("onclick", "proceed('" + btnAdd.ClientID + "')");
JavaScript 
function proceed(buttonId)
{    document.getElementById('<%=btnAdd.ClientID%>').removeAttribute("onclick");
    document.getElementById('<%=btnAdd.ClientID%>').click();
}

I tried with the above code. I want to click the ImageButton through JavaScript. But it is not working. I want to fire server side "btnAdd_Click" event by clicking image button.


Updated on 02-Jun-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By