net use web methods to save data from JavaScript when i press save the all page go the top how i can save sta开发者_如何学JAVAte position after post back
You can set it programmatically
Page.MaintainScrollPositionOnPostBack = true;
In the page declaration
<%@ Page MaintainScrollPositionOnPostback="true" %>
Or in the web.configs <system.web>
section.
<pages maintainScrollPositionOnPostBack="true" />
The reason the page is returning to the top, is because it is being Submitted and hence reloaded.
If you want to keep the position of the page you have 2 options;
1) Use a Anchor (See: http://www.hypergurl.com/anchors.html) 2) Post your form using AJAX and then you do not need to reload the page
Option 2 is the prefered, if you are using webforms you could use an AJAX Update Panel, or if you are using MVC you can do it using JQuery.
try to setting the following page directive in your page
<%@ Page MaintainScrollPositionOnPostback="true" %>
I solved the question, and my method of doing this was the following:
I put a javascript:void(0)
in an a
tag, as shown here:
<a href="javascript:void(0)">
精彩评论