ChangeWorld
ChangeWorld

Reputation: 431

Hide textbox with onClick event on AspNet without refreshing page

Here are my controls:

<div class="row">
    <asp:LinkButton ID="btnDescrizione" runat="server" CssClass="btn waves-effect waves-red btn-large">Aggiungi Descrizione</asp:LinkButton>
</div>

<div class="input-field col s6">
    <asp:TextBox ID="txtDescrizione" TextMode="multiline" Columns="50" Rows="5" CssClass="materialize-textarea" runat="server" />
    <label id="lblDescrizione" for="txtDescrizione" runat="server">Textarea</label>
</div>

Here is my JavaScript

<script type="text/javascript">
    $(document).ready(function() {
    $('#<%= btnDescrizione.ClientID %>').change(function() {
    $('#<%= txtDescrizione.ClientID %>').is(':clicked') ? $('#<%= txtDescrizione.ClientID %>').show() : $('#<%= txtDescrizione.ClientID %>').hide();
  });
});
</script>

I know how to do it in code behind, but I would like to make it work with JavaScript because in that way my page won't refresh.

Upvotes: 0

Views: 138

Answers (1)

Vishnu
Vishnu

Reputation: 897

I think you are looking for the onclientclick property.

https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.button.onclientclick?view=netframework-4.8

Upvotes: 1

Related Questions