asp.nettextboxdatalistonkeydowncustompaging

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


    Solution

  • 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: