asp.net 下 使用 showModalDialog 模式窗口 (记录)
2010-04-21 12:45
537 查看
经历些许破折... 终于搞出来 模式窗体了... 留作纪念...
① 页面放置 GirdView 控件 用来展示信息列表
页面截图: (操作列中的 "回复" 是个 超链接..点击之后打开模式窗口.并且传值过去)
页面源代码
源代码解释:
很普通的一个页面指向链接.. 传参数ID 过去... 后便添加了 window.location.reload()
这个 window.location.reload() 的意思是 .. 模式窗体关闭之后刷新父页面
ansmsg.aspx 就是要弹出来的 模式窗体咯..
在 ansmsg.aspx 页面添加如下代码:
这个意思是 禁止 模式窗体页面缓存..
如果不这样做的话... 地址栏ID不变.. 内容也不会变..
就比如..我的功能是这样的.. 如图:
这样的情况下..如果不添加禁止页面缓存..我需要回复 留言版信息.. 重新从 "回复" 链接打开的模式窗体..内容是不会变的.. 即使数据库中已经更新了...
如果这个页面紧紧是展示信息..而没有提交按钮...我想这样做已经OK 了...
但是我这个模式窗体有个 提交按钮..意思就是说我需要回发数据回去..
这个时候就出现一个问题....
当点击了 提交按钮之后... 这个模式窗体 会在新页面打开...
失去了模式窗体的意义...
这个不太好...但是怎么解决呢?
方法很简单..
在 作为模式窗体弹出的 那个页面 页面源代码中添加如下代码..
到这里...一切OK /./.大功告成.... 感谢各位看客...
① 页面放置 GirdView 控件 用来展示信息列表
页面截图: (操作列中的 "回复" 是个 超链接..点击之后打开模式窗口.并且传值过去)
页面源代码
<asp:GridView ID="gvnotReturn" runat="server" AutoGenerateColumns="False" AllowPaging="True" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" OnPageIndexChanging="gvnotReturn_PageIndexChanging1" PageSize="5" Width="100%"> <RowStyle BackColor="#EEEEEE" ForeColor="Black" /> <Columns> <asp:TemplateField HeaderText="选择"> <ItemTemplate> <asp:CheckBox ID="cbno" runat="server" /> </ItemTemplate> <ItemStyle Width="30px" /> </asp:TemplateField> <asp:TemplateField HeaderText="编号"> <ItemTemplate> <asp:Label ID="lblId" runat="server" Text='<%# Eval("gid") %>'></asp:Label> </ItemTemplate> <ItemStyle Width="40px" HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="标题"> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("gTitle") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="留言日期"> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Eval("gPubDate") %>'></asp:Label> </ItemTemplate> <ItemStyle Width="120px" HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="操作"> <ItemTemplate> <a href="javascript:showModalDialog('ansmsg.aspx?id=<%#Eval("gid")%>');window.location.reload()"> 回复</a> </ItemTemplate> <ItemStyle Width="50px" HorizontalAlign="Center" /> </asp:TemplateField> </Columns> <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="#DCDCDC" /> </asp:GridView>
源代码解释:
<a href="javascript:showModalDialog('ansmsg.aspx?id=<%#Eval("gid")%>');window.location.reload()"> 回复</a>
很普通的一个页面指向链接.. 传参数ID 过去... 后便添加了 window.location.reload()
这个 window.location.reload() 的意思是 .. 模式窗体关闭之后刷新父页面
ansmsg.aspx 就是要弹出来的 模式窗体咯..
在 ansmsg.aspx 页面添加如下代码:
protected void Page_Load(object sender, EventArgs e) { Response.Expires = 0; }
这个意思是 禁止 模式窗体页面缓存..
如果不这样做的话... 地址栏ID不变.. 内容也不会变..
就比如..我的功能是这样的.. 如图:
这样的情况下..如果不添加禁止页面缓存..我需要回复 留言版信息.. 重新从 "回复" 链接打开的模式窗体..内容是不会变的.. 即使数据库中已经更新了...
如果这个页面紧紧是展示信息..而没有提交按钮...我想这样做已经OK 了...
但是我这个模式窗体有个 提交按钮..意思就是说我需要回发数据回去..
这个时候就出现一个问题....
当点击了 提交按钮之后... 这个模式窗体 会在新页面打开...
失去了模式窗体的意义...
这个不太好...但是怎么解决呢?
方法很简单..
在 作为模式窗体弹出的 那个页面 页面源代码中添加如下代码..
</head> <base target="_self" /> <body>
到这里...一切OK /./.大功告成.... 感谢各位看客...
相关文章推荐
- asp.net 下 使用 showModalDialog 模式窗口 (记录)
- (转载)asp.net 下 使用 showModalDialog 模式窗口
- (转载)asp.net 下 使用 showModalDialog 模式窗口
- asp.net 下 使用 showModalDialog 模式窗口
- asp.net 模式窗口用法 window.showModalDialog()
- 在ASP.NET Web API中使用OData的单例模式
- 使用ASP.Net Forms模式实现WebService身份验证
- ASP.NET 2.0中用Gridview控件操作数据——使用Gridview插入新记录
- 在ASP.NET使用JavaScript显示信息提示窗口实现原理及代码
- [ASP.NET]在弹出窗口中使用超连接跳转父窗口中的内容
- Scott Mitchell 的ASP.NET 2.0数据教程之三十一::使用DataList来一行显示多条记录
- asp.net SessionState模式的配置及使用
- asp.net Web项目中使用Log4Net进行错误日志记录
- 【转】使用ASP.Net Forms模式实现WebService身份验证
- ASP.NET中使用log4net记录日志
- ASP.NET MVC - 使用Post, Redirect, Get (PRG)模式
- ASP.NET 使用StateServer 模式
- 关于:“无法序列化会话状态。在“StateServer”或“SQLServer”模式下,ASP.NET 将序列化会话状态对象,因此不允许使用无法序列化的对象或 MarshalByRef 对象。如果自定义会话状态存储在“Custom”模式下执行了类似的序列化
- 在 Windows Server 2003 上的 IIS 6.0 中使用 IIS 5 隔离模式时,如何为 ASP.NET 1.1 的 ASPNET 帐户配置进程标识