---
title: "asp:ImageButton click using javascript not working UI"  
description: "asp:ImageButton click using javascript not working UI"  
author: "Anonymous User"  
published: 2015-06-02  
updated: 2015-06-02  
canonical: https://www.mindstick.com/forum/23278/asp-imagebutton-click-using-javascript-not-working-ui  
category: "asp.net"  
tags: ["c#", "javascript"]  
reading_time: 1 minute  

---

# asp:ImageButton click using javascript not working UI

```
<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](https://www.mindstick.com/forum/2199/call-javascript-s-function-from-code-behind)

```
btnAdd.Attributes.Add("onclick", "return
false;"); //Adding client event to avoid submit for some validation
purposeimgProceed.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](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) the [ImageButton](https://www.mindstick.com/articles/12753/imagebutton-in-android) through [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript). But it is not working. I want to fire [server side](https://www.mindstick.com/forum/318/how-to-call-javascript-fuction-in-server-side) "btnAdd_Click" [event](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london) by clicking [image button](https://www.mindstick.com/forum/12796/disable-postback-on-image-button-click-asp).

## Replies

### Reply by Anonymous User

You're setting it up to call a javascript method called proceed

imgProceed.Attributes.Add("onclick", "proceed('" + btnAdd.ClientID + "')");

but your javascript method is actually called proceedToAdd

function proceedToAdd(buttonId)


---

Original Source: https://www.mindstick.com/forum/23278/asp-imagebutton-click-using-javascript-not-working-ui

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
