ASP.NET OnTextChanged not firing from inside an update panel

后端 未结 2 1368
甜味超标
甜味超标 2021-01-11 18:01

I am using an ASP.NET update panel to retrieve user info using the on TextChanged for the textbox, here is my code:



        
2条回答
  •  没有蜡笔的小新
    2021-01-11 18:29

    As @VinayC posted, AutoPostBack means that the page will postback to the server when your TextBox loses focus. No built-in event causes postback on every character added to a text input, and for good reason. UpdatePanel postbacks don't cause the page to flicker, but they can be just as heavy as a full postback.

    If you want to work around this, you can give your textbox a client onchanged event handler, the JavaScript of which will be built from Page.ClientScript.GetPostBackEventReference().

    The correct solution would be to use an AJAX method call from your JavaScript code rather than an UpdatePanel partial postback in onchanged.

提交回复
热议问题