Search code examples
asp.netvb.nettextboxautopostback

ASP.NET Textbox: OnTextChange jumps to top of page because of autopostback


I'm using the OnTextChange event on a textbox on an ASP.NET page. To have this working I have to put 'AutoPostBack=true'.

The problem is that the textbox is on the bottom of the page, and when the text changes it has to fill another textbox. This is working fine but when the event triggers the page refreshes and jumps to the top of the page, so I always have to scroll down again to see it. (Due to the autopostback)

Is there anything I can do to prevent it to jump to the top of the page?


Solution

  • Use UpdatePanel and put that text box for which u r triggering OnTextChange event in of from ajax extensions and dont forget to include scriptmanager at top of the page the code goes like this <asp:UpdatePanel> <content> <asp:TextBox runat="server" AutoPostBack="true" OnTextChanged="textbox_textchanged"> </asp:TextBox> </content> </asp:UpdatePanel>