---
title: "How to implement click event on textbox"  
description: "How to implement click event on textbox"  
author: "Anonymous User"  
published: 2014-11-27  
updated: 2014-11-27  
canonical: https://www.mindstick.com/forum/12705/how-to-implement-click-event-on-textbox  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# How to implement click event on textbox

In my [web application](https://www.mindstick.com/articles/13069/progressive-web-application-pwas-all-you-need-to-know-about) I need a [functionality](https://www.mindstick.com/blog/136/using-watermark-functionality-in-textbox-by-jquery) so that when users [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) on [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) to [input](https://www.mindstick.com/forum/159209/how-can-i-read-convert-an-input-stream-into-a-string-in-java) [values](https://www.mindstick.com/forum/327/sum-textbox-values), it should make the [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) and the other [fields](https://www.mindstick.com/forum/159126/sql-query-for-all-tables-and-fields-in-an-oracle-db) visible?

I am using the code provided below but, could not get it working.

## C#:

```
protected void TextBox1_Click(object sender, EventArgs e){   
ButtonSearch.Visible = true;}
```

**[ASP.Net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder):**

```
<asp:TextBox ID="TextBox1"runat="server" OnTextChanged="TextBox1_TextChanged"
OnClick="TextBox1_Click"></asp:TextBox><asp:Button ID="ButtonSearch"runat="server" OnClick="ButtonSearch_Click"
Text="Search" Visible="False" />
```

How to accomplish this?

Thanks

## Replies

### Reply by Pravesh Singh

Hi John, \

Set AutoPostback="True". This way the event will be fired server-side, and the button will become visible.

<asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged" OnClick="TextBox1_Click" AutoPostBack="true"></asp:TextBox>

However, if you only want to toogle visility of a button, you really should considerate javascript. This will save a trip back to the server.

```
<asp:TextBox onclick="txtBox1_ClientClicked()"ID="TextBox1" runat="server"
OnClick="TextBox1_Click"></asp:TextBox> <asp:Button ID="ButtonSearch" runat="server" OnClick="ButtonSearch_Click"
Text="Search" style="display:none;" /> <script type="text/javascript">    function txtBox1_ClientClicked(){        var theButton= document.getElementById('<%=ButtonSearch.ClientID%>');       
theButton.style.display = 'block';    }</script>
```


---

Original Source: https://www.mindstick.com/forum/12705/how-to-implement-click-event-on-textbox

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
