Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted

1 solution

Issue is because of AutoPostBack=true.
Because of this your page is get reloaded.

So instead of that you can achieve the same functionality using javascript without page postback as mentioned below :

TextBoxes :

XML
<asp:TextBox runat="server" ID="TextBox1" onchange="ManageText(this.value)"></asp:TextBox>
<asp:TextBox runat="server" ID="TextBox2"></asp:TextBox>



JavaScript Method :

XML
function ManageText(value) 
{
 document.getElementById('<%=TextBox2.ClientID%>').value = value;
}
 
Share this answer
 
v3
Comments
Member 9762654 23-Aug-13 5:37am    
yes we can do like this
CodeBlack 23-Aug-13 5:40am    
Do not forget to mark it as an answer and rate this solution. So our any of the developer friends who are looking for the same solution can get the quick answer.

Have a nice day.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900