【问题标题】:How to load a page in iframe which is in a modal popup extender on button click event?如何在按钮单击事件的模态弹出扩展器中加载 iframe 中的页面?
【发布时间】:2011-06-20 12:18:22
【问题描述】:

如何在 iframe 中加载一个页面,该页面位于按钮点击事件的模态弹出扩展器中?

您好,我在页面中有一个带有链接按钮的网格(例如:“page1”),当我单击链接按钮时,我需要通过传递一个加载页面(例如:“page2”)我在模态弹出扩展器控件中设置的 iframe 内的查询字符串。我可以通过在标记中添加这段代码来实现这一点

  <asp:TemplateField HeaderText="PO NUMBER" HeaderStyle-HorizontalAlign="Center" 
      ItemStyle-HorizontalAlign="Center" ItemStyle-Width="100px">
    <ItemTemplate>
      <asp:HiddenField ID="hfPOAID" runat="server" 
      Value='<%# Bind("POAtID") %>'></asp:HiddenField>
      <asp:LinkButton ID="lbtnPO" runat="server" ForeColor="Blue" 
      Text='<%# Bind("PONUM") %>' CommandName="POview" CommandArgument=
      '<%# ((GridViewRow) Container).RowIndex %>' AutoPostBack="True">
      </asp:LinkButton>
<cc1:ModalPopupExtender ID="mpeStatus" OnOkScript="__doPostBack('Ok','')"  
runat="server" TargetControlID="lbtnPO" PopupControlID="pnlPerson" DropShadow="true" 
CancelControlID="ibCancel1" >  </cc1:modalpopupextender>              
<asp:Panel ID="pnlPerson" runat="server" Style="display: none" 
 Width="900px" Height="550px" CssClass="modalPopup">
   <div style="float: right;">
      <asp:ImageButton ID="ibCancel1" runat="server" ImageUrl="~/Images/del.png" 
      Width="20px" Height="20px" /> 
   </div>
   <div>
    <table>
      <tr>
        <td align="center" style="font-size: 14px;">
          <b>View Purchase Order</b>
        </td>
     </tr>
     <tr>
        <td>
          <iframe name="FRAME1" width="800" height="500" frameborder="0" 
              src='<%#String.Format("ShowPO.aspx?Poid={0}", Eval("POAtID"))%>'>
          </iframe>
        </td>
       </tr>
     </table>
   </div>
  </asp:Panel>
  </ItemTemplate>
  <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
  <ItemStyle HorizontalAlign="Center"></ItemStyle>
  </asp:TemplateField>

在后台代码页面中----------------

   protected void gvPOCloseRpt_OnRowCommand(object sender, GridViewCommandEventArgs e)
   {
   try
   {
     if (e.CommandName == "POview")
     {
          int index = Int32.Parse(e.CommandArgument.ToString());
          HiddenField hfPOAID = (HiddenField)gvPOCloseRpt.Rows[index].FindControl
          ("hfPOAID");
          Session["POID"] = hfPOAID.Value;
          string Script = "window.open('http://mak-erp/deverp/Purchase/poprnt.aspx')";
          System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, 
          this.GetType(), "test", Script, true);
     }
   }
   catch (Exception ex)
   {
     Response.Write(ex);
   }
}

但是,如果网格中有批量数据,加载页面需要很长时间,所以,我只需要在网格中链接按钮的点击事件上加载页面吗?......

谁能帮我做这个.....

提前致谢...........

Dineshkumar R,

【问题讨论】:

    标签: c# asp.net iframe linkbutton modal-popup


    【解决方案1】:

    你可以试试ThickBox弹出page2。

    您可以使用url查询字符串来传递POID参数。

    查看有关厚盒的更多信息:http://jquery.com/demo/thickbox/

    或者你可以使用ajax来实现这个!

    【讨论】:

    • 感谢您对我的查询的关注........我对使用thickbox不太熟悉,如果您建议我使用ajax,我可以通过哪种方式做到这一点? ....
    • 首先,你应该在page1中包含jquery文件thickbox.css和thickbox-compressed.js。然后你可以使用类似&lt;a href="poprnt.aspx&amp;TB_iframe=true&amp;height=200&amp;width=300&amp;modal=true" title="the title you want" class="thickbox"&gt;Open iFrame Modal&lt;/a&gt;的代码来弹出page2。
    【解决方案2】:

    尝试使用引用 div 的 jQuery 模态弹出窗口,该 div 又包含一个 iframe 来显示页面。喜欢:

    $('#btnOpenPopup').click(function (e) {
        $('#frmLoadPage').attr('src','your_page_url');
        $('#divContainer').modal();
        return false;
    });
    
    <div id="divContainer" class="form-control">
      <iframe id="frmLoadPage" ></iframe>
    </div>
    

    【讨论】:

      猜你喜欢
      • 2011-03-18
      • 2012-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多