Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextBox keydown event at server side in asp.net

i have a textbox on a page, now whenever any age number is entered in that page, that page should be loaded in my datalist, i have created rest of the thing, but i am not getting how to trigger the textbox onkeydown event from asp.net, i know working with that from javascript, but the problem is i have below things done in that function:

  • it applies the currentpage value to the static variable from textbox
  • it binds the datalist
  • it enable disable the next previous buttons accordingly
  • and i dont think this i can do from javascript, anyone have any resolution, how this could be achieved from server side, onkeydown event

    like image 806
    Abbas Avatar asked Jan 01 '26 00:01

    Abbas


    1 Answers

    You can capture the keydown event in a javascript function then do a AJAX call to the server. If this does not suit you, then you could try manually do postback in javascript.

    So in your textbox:

    mytextBox.Attributes.Add("onkeydown", "return doDataListBind()");
    

    Now in the javascript function:

    function doDataListBind()
    {
          __doPostBack("myTextBox"); // etc, etc
         // some other code here...
    }
    

    More info can be found here:

    • http://geekswithblogs.net/mnf/archive/2005/11/04/59081.aspx
    • http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/
    like image 59
    skub Avatar answered Jan 02 '26 16:01

    skub



    Donate For Us

    If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!