---
title: "Javascript bottun click is not work in asp.net"  
description: "Javascript bottun click is not work in asp.net"  
author: "Anonymous User"  
published: 2014-11-20  
updated: 2014-11-21  
canonical: https://www.mindstick.com/forum/12654/javascript-bottun-click-is-not-work-in-asp-dot-net  
category: "asp.net"  
tags: ["javascript", "client side scripting"]  
reading_time: 1 minute  

---

# Javascript bottun click is not work in asp.net

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to call from JS to C# [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server). I can not use ajax. I have tried to create a [ASP.NET](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) when it clicked it calls the C# function and call the click function from JS:

**On HTML:**

```
<asp:Button runat="server" ID="UploadButton" OnClick="Upload_Click" />
```

**JS:**

```
alert("Before CLICK");document.getElementById("UploadButton").click();alert("After CLICK");ASP.NET:protected void Upload_Click(object sender, EventArgs e){    //CODE}
```

The [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is that the [click event](https://www.mindstick.com/forum/424/how-to-call-form_paint-event-on-button-click-event) from JS does not working. I have tried to write after the first line of the JS code an [alert](https://answers.mindstick.com/qa/30927/what-is-an-alert) to see if the code rich to that line but I can only see "After CLICK".

## Replies

### Reply by Mark M

You should set the ClientIDMode to Static

```
<asp:Button runat="server" ID="UploadButton"ClientIDMode="Static" OnClick="Upload_Click" />
```

Otherwise, it will have some randomized id, generated by ASP.NET, setting the CLientIDMode to Static, you're saying ASP.NET not to meddle with your ids and keep them intact.

Other option would be to use the ClientID property which will have the value of the automatically generated id like

```
document.getElementById('<%= UploadButton.ClientID %>').click();
```


---

Original Source: https://www.mindstick.com/forum/12654/javascript-bottun-click-is-not-work-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
