zoukankan      html  css  js  c++  java
  • asp.net 下 使用 showModalDialog 模式窗口 (记录) 西安

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

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

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

    页面源代码

    页面源代码
    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 /./.大功告成.... 感谢各位看客...

  • 相关阅读:
    八十四、SAP中的ALV创建之三,创建ALV表格
    八十三、SAP中的ALV创建之二,ALV相关的类型池定义
    八十二、SAP中的ALV创建之一,新建一个程序
    八十一、SAP中的ALV的简介(ABAP List Viewer)
    八十、SAP中数据库操作之 (FOR ALL ENTRIES IN )用法,比较难明白
    七十九、SAP中数据库操作之更新数据,UPDATE的用法
    七十八、SAP中数据库操作之查询条数限制
    七十七、SAP中数据库操作之多表联合查询
    七十六、SAP中数据库的查询用法之 COUNT(总数),SUM(求和),AVG(求平均),GROUP BY(分组)
    七十五、SAP中数据库的使用SQL
  • 原文地址:https://www.cnblogs.com/zhouzhaokun/p/1717115.html
Copyright © 2011-2022 走看看