在显示某一新闻分类中的信息时,用了AspNetPager来分页,新闻分类页是News_List.aspx,在首页Default.aspx中通过News_List.aspx?Classid=10这种方式来传递参数到News_List.aspx中,对应的News_List.aspx.cs是protected void Page_Load(object sender, EventArgs e)
{
string Condition = "";
if (Request["ClassID"] != null)
{
int ClassID = Convert.ToInt32(Request.QueryString["ClassID"]);
Condition = "ClassID=" + ClassID;
}
if(!IsPostBack)
BindNewsList(Helper.GuaranteeConfig.PageSize, 1, true, Condition);
} private int RecordCount = 0;
#region 获取数据
private void BindNewsList(int pageSize, int pageIndex, bool OrderByType, string Condition)
{
DataSet ds = new BLL.T_News().GetNewsListByPage(pageSize, pageIndex, OrderByType, Condition, out RecordCount); AspNetPager1.PageSize = Helper.GuaranteeConfig.PageSize;
AspNetPager1.RecordCount = RecordCount;
AspNetPager1.CurrentPageIndex = pageIndex; if (ds == null || ds.Tables[0].Rows.Count == 0)
return; for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
strNewsList += ContentStr(ds.Tables[0].Rows[i]["Title"].ToString(), ds.Tables[0].Rows[i]["DateTime"].ToString(), Convert.ToInt32(ds.Tables[0].Rows[i]["N_ID"]), Convert.ToInt32(ds.Tables[0].Rows[i]["Hits"]), ds.Tables[0].Rows[i]["Brief"].ToString(), ds.Tables[0].Rows[i]["SourceUrl"].ToString(), ds.Tables[0].Rows[i]["Source"].ToString());
}
}
#endregion #region 分页
//分页
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BindNewsList(Helper.GuaranteeConfig.PageSize, e.NewPageIndex, true, "");
}
#endregion在改造为伪静态时,Default.aspx中改为<a href="c29.html" target="_blank">更多</a>,web.config中的配置为<add url="~/c(\d{1,9}).html" to="~/News_List.aspx?Classid=$1"/>,但在打开c29.html页后,如果点击AspNetPager分页时,页面的url地址又变成了News_List.aspx?Classid=29。
怎么能实现伪静态呢?
{
string Condition = "";
if (Request["ClassID"] != null)
{
int ClassID = Convert.ToInt32(Request.QueryString["ClassID"]);
Condition = "ClassID=" + ClassID;
}
if(!IsPostBack)
BindNewsList(Helper.GuaranteeConfig.PageSize, 1, true, Condition);
} private int RecordCount = 0;
#region 获取数据
private void BindNewsList(int pageSize, int pageIndex, bool OrderByType, string Condition)
{
DataSet ds = new BLL.T_News().GetNewsListByPage(pageSize, pageIndex, OrderByType, Condition, out RecordCount); AspNetPager1.PageSize = Helper.GuaranteeConfig.PageSize;
AspNetPager1.RecordCount = RecordCount;
AspNetPager1.CurrentPageIndex = pageIndex; if (ds == null || ds.Tables[0].Rows.Count == 0)
return; for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
strNewsList += ContentStr(ds.Tables[0].Rows[i]["Title"].ToString(), ds.Tables[0].Rows[i]["DateTime"].ToString(), Convert.ToInt32(ds.Tables[0].Rows[i]["N_ID"]), Convert.ToInt32(ds.Tables[0].Rows[i]["Hits"]), ds.Tables[0].Rows[i]["Brief"].ToString(), ds.Tables[0].Rows[i]["SourceUrl"].ToString(), ds.Tables[0].Rows[i]["Source"].ToString());
}
}
#endregion #region 分页
//分页
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BindNewsList(Helper.GuaranteeConfig.PageSize, e.NewPageIndex, true, "");
}
#endregion在改造为伪静态时,Default.aspx中改为<a href="c29.html" target="_blank">更多</a>,web.config中的配置为<add url="~/c(\d{1,9}).html" to="~/News_List.aspx?Classid=$1"/>,但在打开c29.html页后,如果点击AspNetPager分页时,页面的url地址又变成了News_List.aspx?Classid=29。
怎么能实现伪静态呢?
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BindNewsList(Helper.GuaranteeConfig.PageSize, e.NewPageIndex, true, "");
}