Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to clear data in textbox multiline texfield to click cancel button

What I have tried:

ASP.NET
<asp:textbox id="txtcontent" runat="server" class="form-control" textmode="MultiLine">

Cancel

  function resetproduct() {
                $("#<%= txtsubject.ClientID %>").val("");
                $("#<%= txtcontent.ClientID %>").val("");
                return false;
            }
Posted
Updated 4-Sep-19 3:44am
v2
Comments
ZurdoDev 4-Sep-19 9:25am    
.val("") works so check to see what is being rendered in html by <%= txtsubject.ClientID %>

You should likely end up with $("#txtContent").val("");

1 solution

The working code is here, in your code nothing is wrong please check what txtContent render at client side. Also check jQuery is loaded properly.

<div>
       <asp:TextBox ID="txtcontent" runat="server" class="form-control" TextMode="MultiLine"></asp:TextBox>
       <br />
      <div onclick="resetproduct()">Click to Cancel</div>
</div>

  <script>
      function resetproduct() {
          $("#<%= txtcontent.ClientID %>").val("");
          return false;
      }
  </script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900