Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8370287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:52:46+00:00 2026-06-09T13:52:46+00:00

function clickButton(e, buttonid) var evt = e ? e : window.event; var bt =

  • 0
function clickButton(e, buttonid)         
            var evt = e ? e : window.event;
            var bt = document.getElementById(buttonid);
            if (bt) {
                if (evt.keyCode == 13) {
                    bt.click();                                                  
                    return false;
                }
            }
        }

txtChatMessage.Attributes.Add("onkeypress", "return clickButton(event,'" + btnSendChat.ClientID + "')");

this function is an attribute that is set in code behind file. How do I reset the text in textbox after the button click fires

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:52:47+00:00Added an answer on June 9, 2026 at 1:52 pm

    You can do it like this, by passing the text field from code behind using this, and setting its value to empty string in javascript

    In code behind

    txtChatMessage.Attributes.Add("onkeypress", "return clickButton(this, event,'" + btnSendChat.ClientID + "')");
    

    In javascript

    function clickButton(txt, e, buttonid){
       var evt = e ? e : window.event;
       var bt = document.getElementById(buttonid);
       if (bt) {
            if (evt.keyCode == 13) {
                 bt.click();    
                 txt.value = "";                                               
                 return false;
       }
    

    The above code will over write the existing value of text box. To save it for later use we can use hidden field

    In html

    <asp:hidden id="hdnText" runat="server" >
    

    In javascript

    function clickButton(txt, e, buttonid){
       var evt = e ? e : window.event;
       var bt = document.getElementById(buttonid);
       if (bt) {
            if (evt.keyCode == 13) {
                 bt.click();    
                 document.getElementById('<%= hdnText.ClientID %>').value = txt.value;                                               
                 return false;
       }
    

    In Code behind

    Send text field to javascript function

    txtChatMessage.Attributes.Add("onkeypress", "return clickButton(this, event,'" + btnSendChat.ClientID + "')");
    

    Get value of textbox from hidden field

    string textBoxValue = hdnText.Value;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = createCustomURL(WinNetwork.UserName); document.getElementById(psyncLink).src =
I have the following code block : function testJQueryClick(){ $('#button2').click(function(){ alert ('Debug'); return false;
$('#div1').on('click', '#otherDiv1', function(event){ //Show popup $('#popupDiv').bPopup({ modalClose: false, follow: [false, false], closeClass: 'close' });
function checkuser(user) { var ret = false; $.ajax({ type:'POST', url:'user.php', async:false, data:{'user':user}, success:function (data)
I have this code in my view function Validate() { if (document.getElementById('MandateName').value == )
For example, I have something like: <div id=buttons> <button class=button>Click</button> </div> <script> $(document).ready(function() {
function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = http://localhost/index.php?nph-psf=0&HOSTID=AD&ALIAS= + WinNetwork.UserName;
I am using $(.button).on(click, function(){ }); to click to a button which is on
Fellow JQuery hackers, hello :-) Suppose you have the following code: $('.links').click(function(){ //Do something
<script src=https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js></script> <script type=text/javascript> $(document).ready(function(){ $('#btnSubmit').bind('click', function(){ var option = $('#option1').val(); if(option == ''){

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.