(转载)asp.net 下 使用 showModalDialog 模式窗口

经历些许破折... 终于搞出来 模式窗体了... 留作纪念...

①  页面放置 GirdView 控件 用来展示信息列表

页面截图:  (操作列中的 "回复" 是个 超链接..点击之后打开模式窗口.并且传值过去)

页面源代码

 

ExpandedBlockStart.gif 页面源代码
 
   
1 < asp:GridView ID ="gvnotReturn" runat ="server" AutoGenerateColumns ="False" AllowPaging ="True"
2 BackColor ="White" BorderColor ="#999999" BorderStyle ="None" BorderWidth ="1px"
3 CellPadding ="3" GridLines ="Vertical" OnPageIndexChanging ="gvnotReturn_PageIndexChanging1"
4 PageSize ="5" Width ="100%" >
5   < RowStyle BackColor ="#EEEEEE" ForeColor ="Black" />
6   < Columns >
7   < asp:TemplateField HeaderText ="选择" >
8   < ItemTemplate >
9   < asp:CheckBox ID ="cbno" runat ="server" />
10   </ ItemTemplate >
11   < ItemStyle Width ="30px" />
12   </ asp:TemplateField >
13   < asp:TemplateField HeaderText ="编号" >
14 < ItemTemplate >
15 < asp:Label ID ="lblId" runat ="server" Text ='<%# Eval("gid") % > '> </ asp:Label >
16 </ ItemTemplate >
17 < ItemStyle Width ="40px" HorizontalAlign ="Center" />
18 </ asp:TemplateField >
19 < asp:TemplateField HeaderText ="标题" >
20 < ItemTemplate >
21 < asp:Label ID ="Label1" runat ="server" Text ='<%# Eval("gTitle") % > '> </ asp:Label >
22 </ ItemTemplate >
23 </ asp:TemplateField >
24 < asp:TemplateField HeaderText ="留言日期" >
25 < ItemTemplate >
26 < asp:Label ID ="Label2" runat ="server" Text ='<%# Eval("gPubDate") % > '> </ asp:Label >
27 </ ItemTemplate >
28 < ItemStyle Width ="120px" HorizontalAlign ="Center" />
29 </ asp:TemplateField >
30 < asp:TemplateField HeaderText ="操作" >
31 < ItemTemplate >
32 < a href ="javascript:showModalDialog('ansmsg.aspx?id=<%#Eval(" gid")% > ');window.location.reload()">
33 回复 </ a >
34 </ ItemTemplate >
35 < ItemStyle Width ="50px" HorizontalAlign ="Center" />
36 </ asp:TemplateField >
37 </ Columns >
38 < FooterStyle BackColor ="#CCCCCC" ForeColor ="Black" />
39 < PagerStyle BackColor ="#999999" ForeColor ="Black" HorizontalAlign ="Center" />
40 < SelectedRowStyle BackColor ="#008A8C" Font-Bold ="True" ForeColor ="White" />
41 < HeaderStyle BackColor ="#000084" Font-Bold ="True" ForeColor ="White" />
42 < AlternatingRowStyle BackColor ="#DCDCDC" />
43 </ 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 /./.大功告成.... 感谢各位看客...

 

转载于:https://www.cnblogs.com/Donkey/archive/2010/06/24/1764296.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值