<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdateMain" runat="server">
        <ContentTemplate>
             <asp:Label ID="lblPageCount" runat="server" Text=""></asp:Label>
        <asp:Button ID="btnPre" runat="server" Text="上一页" onclick="btnPre_Click" />
        <asp:Button ID="btnNext" runat="server" Text="下一页" onclick="btnNext_Click" />
        <a href="Default13.aspx">13页</a>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;public partial class CRMMember_Default11 : System.Web.UI.Page
{
    public Int32 MyPageIndex
    {
        get
        {
            return (ViewState["MyPageIndex"] == null || Convert.ToInt32(ViewState["MyPageIndex"]) < 1) ? 1 : Convert.ToInt32(ViewState["MyPageIndex"]);
        }
        set
        {
            ViewState["MyPageIndex"] = value;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        BindList();
    }    void BindList()
    {
        lblPageCount.Text = MyPageIndex.ToString();
    }    protected void btnPre_Click(object sender, EventArgs e)
    {
        MyPageIndex -= 1;
        BindList();
    }
    protected void btnNext_Click(object sender, EventArgs e)
    {
        MyPageIndex += 1;
        BindList();
    }
}
我在用ViewState来做保存分页的功能后
当翻页后
再点击到别一个页面
然后再点浏览器的后退
这时就发现问题了比如
我现在翻页到第5页
然后点击到别一页
再点浏览器的后退
我的MyPageIndex总是变为1
但当我当击下一页的时候,
又可以正确的指定到第六页
然后我把Asp.net Ajax的UploadPanel删除后
后退可以正常显示第5页那我上页的代码要实现Ajax又要点击后退的时候可以正常显示上一页的页数
那么我上页哪里错了呢
又怎么改啊谢谢星期天加班到10点多了还跑不了啊谢谢

解决方案 »

  1.   


     Ajax 本身就不能后退呀
      

  2.   

    一楼说的是啊
    所以你要后退自己做个按钮设置操作内容
    用了ajax后
    浏览器的前进后退就没什么用了啊
      

  3.   

    这应该是ajax本身的特性决定的,如果想使用浏览器的前进后退,一般在页面中需要使用iframe来解决,楼主可以搜搜相关的解决方案
      

  4.   

    同意楼上的And1楼的,2楼的也不错
      

  5.   

    AJAX禁止了后退,建议LZ用iframe来解决