scroll go to the top page

后端 未结 4 1251
迷失自我
迷失自我 2020-12-22 06:34

net use web methods to save data from JavaScript when i press save the all page go the top how i can save state position after post back

相关标签:
4条回答
  • 2020-12-22 07:14

    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.

    0 讨论(0)
  • 2020-12-22 07:21

    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)">
    
    0 讨论(0)
  • 2020-12-22 07:24

    try to setting the following page directive in your page

    <%@ Page MaintainScrollPositionOnPostback="true" %>
    
    0 讨论(0)
  • 2020-12-22 07:35

    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" />
    
    0 讨论(0)
提交回复
热议问题