In my aspx ,
<div id="commentDiv" runat="server">
<%# Eval("myComment")%>
</div>
At the start of this page loading , I want to auto scroll and navigate to this DIV .
How can i do that ?
In my aspx ,
<div id="commentDiv" runat="server">
<%# Eval("myComment")%>
</div>
At the start of this page loading , I want to auto scroll and navigate to this DIV .
How can i do that ?
Refer following code:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"
ScriptMode="Release" />
<script type="text/javascript">
var xPos, yPos;
var param = Sys.WebForms.PageRequestManager.getInstance();
function BeginRequestHandler(sender, args) {
if ($get('<%=divMessages.ClientID%>') != null) {
xPos = $get('<%=divMessages.ClientID%>').scrollLeft;
yPos = $get('<%=divMessages.ClientID%>').scrollTop;
}
}
function EndRequestHandler(sender, args) {
if ($get('<%=divMessages.ClientID%>') != null) {
xPos = $get('<%=divMessages.ClientID%>').scrollLeft = xPos;
yPos = $get('<%=divMessages.ClientID%>').scrollTop = yPos;
}
}
param.add_beginRequest(BeginRequestHandler);
param.add_endRequest(EndRequestHandler);
</script>
This is important link for this issue:
http://basgun.wordpress.com/2008/06/09/maintain-scroll-position-updatepanel-postback/
Hope its helpful.
See http://www.aspdotnet-suresh.com/2012/10/jquery-scroll-to-particular-div.html#middle jquery based function to scroll to specific div by the href tag, which is right above the div. You can add this function in your pageLoad
The easiest way is to have a link when the user press on it, it scroll him to this div.
In your browser side just add <a name="BottomOfThePage"></a>
around the div. And make the link look like this <a href="#BottomOfThePage">Link</a>