showModalDialog里面分页问题

燕飞7 2009-03-02 02:36:02
用showModalDialog打开了一个A页面,A页面里面装了个DataGrid和一个分页控件.
当在分页控件里点击下一页时,会重新打开个A页面,然后在DataGrid中显示下一页的
对应信息.

现在不想实现点击下一页,重新打开个A页面.而是在原来的页面里面,datagrid显示下一页
的信息.怎么来改或者应该怎么设置.
...全文
338 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
燕飞7 2009-03-02
  • 打赏
  • 举报
回复
谢谢,结帖.
CutBug 2009-03-02
  • 打赏
  • 举报
回复
上面js的作用就是清除所有分页链接的target属性
燕飞7 2009-03-02
  • 打赏
  • 举报
回复
可以了,非常感谢CutBug的热情帮助!!!

顺便问句:为什么加上window.onload=function()
就可以了呢??
CutBug 2009-03-02
  • 打赏
  • 举报
回复
其实意思就是target属性不加就可以了
CutBug 2009-03-02
  • 打赏
  • 举报
回复
不用js了把webdiyer:AspNetPager的UrlPagingTarget="_self"属性去掉就可以了
CutBug 2009-03-02
  • 打赏
  • 举报
回复
AspNetPager1用的是后改成<%=AspNetPager1.ClientID%>
CutBug 2009-03-02
  • 打赏
  • 举报
回复
在模态对话框页面加入这个js就ok了
window.onload=function()
{
var div= document.getElementById("AspNetPager1");
var hrefs = div.getElementsByTagName("a");
for(var i=0;i<hrefs.length;i++)
{
if(hrefs[i].target!="")
hrefs[i].removeAttribute("target");
}

}
燕飞7 2009-03-02
  • 打赏
  • 举报
回复
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" CustomInfoHTML="Page %CurrentPageIndex% / %PageCount%"
CustomInfoSectionWidth="20%" FirstPageText="首页" LastPageText="末页" NextPageText="下一页"
NumericButtonCount="5" OnPageChanged="AspNetPager1_PageChanged" PageIndexBoxType="DropDownList"
PageSize="5" PrevPageText="上一页" ShowCustomInfoSection="Left" ShowPageIndexBox="Always"
UrlPaging="True" UrlPagingTarget="_self" Width="537px" TextAfterPageIndexBox="页" TextBeforePageIndexBox="前往-->" AlwaysShow="True" CustomInfoTextAlign="Left">
</webdiyer:AspNetPager>
燕飞7 2009-03-02
  • 打赏
  • 举报
回复
<div id="AspNetPager1" style="width:537px;">
<div align="left" style="float:left;width:20%;">
Page 2 / 2
</div>
<div style="width:80%;float:left;">
<a target="_self" href="DialogB.aspx?page=1" style="margin-right:5px;">首页</a>
<a target="_self" href="DialogB.aspx?page=1" style="margin-right:5px;">上一页</a>
<a href="DialogB.aspx?page=1" target="_self" style="margin-right:5px;">1</a>
<span style="margin-right:5px;font-weight:Bold;color:red;">2</span>
<a disabled="disabled" style="margin-right:5px;">下一页</a>
<a disabled="disabled" style="margin-right:5px;">末页</a>
  前往-->
<select name="AspNetPager1_input" id="AspNetPager1_input" onchange="ANP_goToPage(this)">
<option value="1">1</option>
<option value="2" selected="true">2</option>
</select>页
</div>
</div>
CutBug 2009-03-02
  • 打赏
  • 举报
回复
你运行页面后查看源代码把分页部分代码贴上来,看看,看样子只能通过js修改一下了
燕飞7 2009-03-02
  • 打赏
  • 举报
回复
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
this.BinderToDataGrid();
}
燕飞7 2009-03-02
  • 打赏
  • 举报
回复
分页使用aspnetpager来实现的
代码:
if (!IsPostBack)
{
AspNetPager1.RecordCount = SelectAll().Tables[0].Rows.Count;
this.BinderToDataGrid();
}
void BinderToDataGrid()
{
SqlConnection conn = new SqlConnection();
try
{
conn.ConnectionString = "Data Source=B;Initial Catalog=Northwind;Integrated Security=True";

conn.Open();
}
catch (Exception ex)
{ }
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand("select lastname,firstname,city,postalcode from employees", conn);
DataSet ds = new DataSet();
da.Fill(ds,AspNetPager1.StartRecordIndex,AspNetPager1.PageSize,"employees");

this.DataGrid1.DataSource = ds.Tables[0].DefaultView;
DataGrid1.DataBind();
}
CutBug 2009-03-02
  • 打赏
  • 举报
回复
看一看你的分页代码是不是用<a> onclick方式,是的话改成href
SANSWATER 2009-03-02
  • 打赏
  • 举报
回复
在HTML代码中加<base target="_self" /> 要放在head前面
燕飞7 2009-03-02
  • 打赏
  • 举报
回复
在<head>里面添加 <base target="_self" />
点击下一页,还是会打开新的页面

不过效果还是有的,之前在里面点击服务器端控件也会打开新的页面,现在不打开了.
chufuya 2009-03-02
  • 打赏
  • 举报
回复
楼上的办法没试过 我也遇见过 不过我妥协了……改用window.open了 在参数里面设置高宽,也能达到同样的效果
zhxhdean 2009-03-02
  • 打赏
  • 举报
回复
<head>
<base target="_self" />
</head>
  • 打赏
  • 举报
回复
CutBug's answer is perfect.
wanghao3616 2009-03-02
  • 打赏
  • 举报
回复
在弹出的页面html里需要加上<base target="_self"> 试试
路人乙e 2009-03-02
  • 打赏
  • 举报
回复
<head>
<base target="_self" />
</head>
加载更多回复(3)

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧