Place an anchor where you want to scroll to, and make sure the relevant javascript is written after the postback. You can get the JS to scroll to the anchor tag here
You can use Focus() method of the message to set focus. But honestly, I do not think your page UI layout is good. If some message is shown as a result of a button click, it should be adjacent to the button. Do not show the message some where else. It does
not make a good layout anyway.
I agree to U Ruchira.Actually situation is that on click of Linkbutton a Rich textbox is inserted on page and that link button is at the top of page (just like forum ).Rich text box is in Div
You can scroll to the bottom of the page using javascripts.
function scroll(){
window.scrollTo(0, document.body.clientHeight);
}
Call that function when you need. If you need it to scroll to the bottom after your postback is done, you can use the below to register that method so it will run right after the post back finishes.
jitteshh
Member
40 Points
63 Posts
About scrolling the page on button click
Apr 30, 2012 12:24 PM|LINK
Hi,
I am a Software Trainee in asp.net (C# ).
In my asp page ,on a click of linkbutton ,I am showing a text message at the bottom of page in
But problem is that ,if any unknown user comes and click on linkbutton ,he feels that there is no action on that click ok Linkbutton.
So I need to scroll the page at the bottom of page OR on click of linkbutton it should goes to that div (where msg is shown) .
I used javascript code but it does not work .
If possible ,please tell me solution of code behind because text message is assigned is code behind.
Kindly Help.
Thanks in advance.
AidyF
Star
9184 Points
1570 Posts
Re: About scrolling the page on button click
Apr 30, 2012 12:31 PM|LINK
Place an anchor where you want to scroll to, and make sure the relevant javascript is written after the postback. You can get the JS to scroll to the anchor tag here
http://stackoverflow.com/questions/3163615/how-to-scroll-html-page-to-given-anchor-using-jquery-or-javascript
mehta_muktes...
Member
344 Points
64 Posts
Re: About scrolling the page on button click
Apr 30, 2012 12:36 PM|LINK
Hi
Use anchor tag instead of link button and give href="#divname" and in onclick event write javascript to show the text as in
Hope this helps!
Please mark as Answer the posts that helped you.
tusharrs
Contributor
3230 Points
668 Posts
Re: About scrolling the page on button click
Apr 30, 2012 12:43 PM|LINK
use a anchor tag and div element where you want to display the message
<a ID="hl1" href="#divmessage" runat="server">Read Message</a>
//at the bottom use div to display the message
<div id="divmessage">your message</div>
( Mark as Answer if it helps you out )
View my Blog
Ruchira
All-Star
42888 Points
7020 Posts
MVP
Re: About scrolling the page on button click
May 01, 2012 05:49 AM|LINK
Hello,
You can use Focus() method of the message to set focus. But honestly, I do not think your page UI layout is good. If some message is shown as a result of a button click, it should be adjacent to the button. Do not show the message some where else. It does not make a good layout anyway.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.jitteshh
Member
40 Points
63 Posts
Re: About scrolling the page on button click
May 02, 2012 05:05 AM|LINK
I had tried this,but the problem is that page scrolls down for a few seconds and goes up ,It should stay at that position .
Also this solution works in some browser ie Firefox and IE, ,it does not work in Chrome and Safari.
PLease help.
jitteshh
Member
40 Points
63 Posts
Re: About scrolling the page on button click
May 02, 2012 05:20 AM|LINK
I agree to U Ruchira.Actually situation is that on click of Linkbutton a Rich textbox is inserted on page and that link button is at the top of page (just like forum ).Rich text box is in Div
Help
Ruchira
All-Star
42888 Points
7020 Posts
MVP
Re: About scrolling the page on button click
May 02, 2012 08:37 AM|LINK
Hello,
You can scroll to the bottom of the page using javascripts.
function scroll(){ window.scrollTo(0, document.body.clientHeight); }Call that function when you need. If you need it to scroll to the bottom after your postback is done, you can use the below to register that method so it will run right after the post back finishes.
Or try by setting the focus at client side. Like below
document.getElementById('<%=TextBoxID.ClientID%>').focus();
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.nilsan
All-Star
16826 Points
3684 Posts
Re: About scrolling the page on button click
May 02, 2012 09:08 AM|LINK
If you want to scroll to bottom of the div, try below :
$('#divFavorDet').scrollTop($('#divFavorDet').height());i.e divFavorDet is your div name.
mahedee
Member
450 Points
116 Posts
Re: About scrolling the page on button click
May 02, 2012 09:38 AM|LINK
You can try with this.I tested it IE and Mozilla.
<a href="#divMsg">Click Here to Scroll</a>
<div id = "divMsg">
This is the message
</div>
Mahedee
Blog: http://mahedee.blogspot.com