Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a chat application attached to my website where the user enters data from a textbox and user can view the replies from the other side using textbox with multiline mode.But,The Problem is I had added the Multiline textbox inside an updatePanel with the Timer to refresh periodically.The problem arises here,After every refresh the textbox scrolls back to top position.The user cant view the recently recieved messages.
can,Any one suggests the way to overcome the problem?
Posted
Updated 27-Jul-12 19:31pm
v2
Comments
Kenneth Haugland 28-Jul-12 1:38am    
Dont the multiline textboxes have scroll into view ?

To maintain scroll position, 2 options:
1. try MaintainScrollPosition page attribute. Refer: MSDN: Page.MaintainScrollPositionOnPostBack Property [^]
OR
2. you can keep track of the scroll position on client side before the onchange event fires. Restore the scroll position back to what you stored last time after the page refresh. Refer: Part of the article provides way to do it[^]
 
Share this answer
 
hello

Java
TextBox1.Select(TextBox1.TextLength, 1)
TextBox1.ScrollToCaret()
TextBox1.Focus()


That will select the last character in the text box. If you want to select the entire last row you can just adjust the 2nd parameter in the Select method to be = the length of the last line.

or

If you call AppendText to add new text to the TextBox then it will automatically scroll to the end of the text.
 
Share this answer
 
v2
Comments
Nandakishore G N 28-Jul-12 1:47am    
NileshBhai..Thank u for the response..But,I had already Used this tech..But its not working..The error i got is


System.Web.UI.WebControls.TextBox' does not contain a definition for 'SelectionStart' and no extension method 'SelectionStart' accepting a first argument of type 'System.Web.UI.WebControls.TextBox' could be found (are you missing a using directive or an assembly reference?)
You can do this by making use of a function called ScrollToCaret. You need to first set the caret position to the end of the text box, then you can scroll to it. Here's how to do it:
C#
//move the caret to the end of the text
textBox.SelectionStart = textBox.TextLength;
//scroll to the caret
textBox.ScrollToCaret();
//Sets the cursor
textBox.Focus();


I believe SelectionStart is only available for System.Windows.Forms.TextBox[^]. Use this set of properties for System.Web.UI.WebControls.TextBox[^].
 
Share this answer
 
v3
Comments
_Amy 28-Jul-12 1:53am    
Check my updated answer.
Nandakishore G N 28-Jul-12 2:34am    
_Amy..Thank u..for reply..but SelectionStart is not a function which can be used in the web application..It belongs to windows...app...
Member 11357998 2-Jun-20 4:20am    
My code..
Patient_FactRow[] patfaq = new Patient_FactRow[1];
patfaq[0] = new Patient_FactRow();
patfaq[0].DM_Patient_Ref = Patient_ref;
patfaq[0].First_Name = "Sandeep";
IBOPatientActivity boActivity23 = (IBOPatientActivity)Activator.GetObject(typeof(IBOPatientActivity), ClientCache.WebServerURI + "BOPatientActivity.rem");
long retval90 = boActivity23.PatientInfo(XLCareUtils.si, patfaq); --> System.Security.SecurityException: 'Request failed.'getting error

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