Wednesday, June 5, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
128
rated 0 times [  132] [ 4]  / answers: 1 / hits: 82477  / 13 Years ago, mon, september 12, 2011, 12:00:00
<asp:Content ID=Content1 ContentPlaceHolderID=HeadContent runat=Server>
<meta http-equiv=refresh content=4 />
<script type=text/javascript>

var xPos1, yPos1;

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoading(pageLoadingHandler);
prm.add_pageLoaded(pageLoaded);
function pageLoaded(sender, args) {

$get('<%=Panel_Users.ClientID %>').scrollLeft = xPos1;
$get('<%=Panel_Users.ClientID %>').scrollTop = yPos1;
}
function pageLoadingHandler(sender, args) {
xPos1 = $get('<%=Panel_Users.ClientID %>').scrollLeft
yPos1 = $get('<%=Panel_Users.ClientID %>').scrollTop;
}
</script>
</asp:Content>


Doesn't work, where am I going wrong





    <asp:ScriptManager ID=ScriptManager1 runat=server EnablePageMethods=true  />    

<div style=height: 504px; width: 941px;>
<asp:Panel runat=server ID=Panel_Users ScrollBars=Auto Style=z-index: 1; left: 748px;
top: 621px; position: absolute; height: 250px; width: 287px>
<asp:UpdatePanel UpdateMode=Conditional ID=UpdatePanel1 runat=server>
<ContentTemplate>
<asp:GridView ID=Grid_UserTable runat=server Style=z-index: 1; left: 2px; top: 5px;
position: absolute; height: 152px; width: 243px BorderColor=#666666 AutoGenerateColumns=False
OnRowDataBound=MyGrid_RowDataBound>
<Columns>
<asp:TemplateField HeaderText=Status>
<ItemTemplate>
<asp:Image ID=Status runat=server />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField=TimeReceived HeaderText=TimeReceived InsertVisible=False
ReadOnly=True SortExpression=TimeReceived />
<asp:BoundField DataField=TimeRead HeaderText=TimeRead SortExpression=TimeRead />
<asp:BoundField DataField=Name HeaderText=Name SortExpression=Name />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</div>


I am trying to make the page stay at the same position when the page refreshes after every 5 seconds and the page goes to top. I tried Page MaintainScrollPositionOnPostback=true . It didn't work, I tried using Ajax but have no idea how to use it. Can someone help me how to do it with Ajax.


More From » c#

 Answers
14

The MaintainScrollPositionOnPostback only works in IE. To do this you can either roll your own client script or use anchor links on different sections of your page/form.



Similar questions here:



MaintainScrollPositionOnPostback is not working - how to debug?



MaintainScrollPositionOnPostback not working with javascript:__doPostBack



maintainScrollPositionOnPostback="true" does not work globally after setting in web.config ,but works in page level,what should I do?


[#90134] Sunday, September 11, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
savanar

Total Points: 237
Total Questions: 105
Total Answers: 99

Location: Wales
Member since Mon, May 17, 2021
3 Years ago
;