Pergunta

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

    Foi útil?

    Solução

    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:

    Outras dicas

    Try looking into or using either:

    AJAX Control Toolkit, or

    JQuery Autocomplete Plugin

    Alternatively you could try to call _postback() function from a client side event/function for your textbox in javascript

    Licenciado em: CC-BY-SA com atribuição
    Não afiliado a StackOverflow
    scroll top