Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Automaticall show bottom of  multiline text

Posted on 2011-05-13
10
Medium Priority
?
427 Views
Last Modified: 2012-08-14
Hi,

I'm trying to find a way of automatically showing the bottom of my textbox when an aspx page loads. It is a multiline textbox. I've searched around and have found ways to do it on non web controls i.e    textbox1.SelectionStart = TextBox1.Text.Length - 1
                        textbox1.ScrollToCaret()

However selectionstart does not come up when I try to use it on my  codebehind of my aspx page. Is there a way of achieving this for my textbox on my web page.

Thanks
0
Comment
Question by:Michael Roodt
  • 5
  • 4
10 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 35752873
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35752887
The code you have should work on a asp.net web server control ie. : <asp:TextBox ... >
What control are you tring to achieve this on <input> ?
0
 
LVL 2

Author Comment

by:Michael Roodt
ID: 35752918
I've attached an exmple with the error I get. I thought it should work but for some reason it doesn't.

Thanks
<asp:TextBox ID="jmaordTextBoxReason" runat="server" TextMode="MultiLine" 
       ReadOnly="True" Height="550px" Width="870px" AutoPostBack="True" Font-Size="X-Large"></asp:TextBox>

Open in new window

a.png
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35752950
Hmm yeah only works with the winforms textbox not asp.net think you'll have to go with a javascript example
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35752956
something like :

<script type="text/javascript">
     function scrollDown()      {
       document.getElementById('<%=TextBox1.ClientID%>').scrollTop = document.getElementById('<%=TextBox1.ClientID%>').scrollHeight;     };   
</script> 

Open in new window

0
 
LVL 2

Author Comment

by:Michael Roodt
ID: 35753036
<script type="text/javascript">
        function scrollDown() {
            document.getElementById('<%=jmaordTextBoxReason%>').scrollTop = document.getElementById('<%=jmaordTextBoxReason%>').scrollHeight;
        };  
</script>  


I put the above in but it still goes to the top.
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35753346
try this in your page load :

protected void Page_Load(object sender, EventArgs e)
{

   if (!IsPostBack)

   {

      Page.ClientScript.RegisterStartupScript(this.GetType(),       
      "ScrollTextbox",

      "<script type=\"text/javascript\">document.getElementById('" +

      this.jmaordTextBoxReason +

      "').scrollTop = document.getElementById('" +

      this.jmaordTextBoxReason.ClientID +

      "').scrollHeight; " +

      " </script>");

   }

}

Open in new window

0
 
LVL 2

Author Comment

by:Michael Roodt
ID: 35755099
if i put in the code below, I had to convert it to vb  I get the error as shown on the screen. I have not changed any of the code other than converting it.

Thanks
If Not IsPostBack Then
            Page.ClientScript.RegisterStartupScript(Me.[GetType](), "ScrollTextbox", "<script type=""text/javascript"">document.getElementById('" & Convert.ToString(Me.jmaordTextBoxReason) & "').scrollTop = document.getElementById('" & Convert.ToString(Me.jmaordTextBoxReason.ClientID) & "').scrollHeight; " & " </script>")
        End If

Open in new window

a.png
0
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 2000 total points
ID: 35755143
change to :

If Not IsPostBack Then  
            Page.ClientScript.RegisterStartupScript(Me.[GetType](), "ScrollTextbox", "<script type=""text/javascript"">document.getElementById('" & Me.jmaordTextBoxReason.ClientID & "').scrollTop = document.getElementById('" & Me.jmaordTextBoxReason.ClientID & "').scrollHeight; " & " </script>")  
        End If

Open in new window

0
 
LVL 2

Author Closing Comment

by:Michael Roodt
ID: 35755585
Perfect! Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Over time, the online landscape has altered considerably, but that’s nothing compared to the up-and-coming trends that will shape the web design industry in the coming year. Keep reading to find out which trends will shape B2B web design in 2018.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question