asprame页面未加载iframe单击按钮

时间:2013-07-15 10:44:01

标签: c# asp.net modalpopupextender

<asp:Button runat="server" ID="hiddenPopupPatientRegistration" Style="display: none" />
    <asp:ModalPopupExtender ID="popupPatientRegistration" runat="server" PopupControlID="panelPatientRegistration"
        TargetControlID="hiddenPopupPatientRegistration" BackgroundCssClass="cssmodalbackground"
        BehaviorID="modalBehaviour" CancelControlID="btnClose">
    </asp:ModalPopupExtender>
    <div id="panelPatientRegistration" class="cssmodalpopup" style="display: none">
        <iframe id="iframePatientRegistration"  class="csstable" runat="server" width="600px"
            height="485px" scrolling="auto"></iframe>
        <table>
            <tr>
                <td align="right">
                    <asp:Button ID="btnClose" runat="server" CssClass="cssbutton" Text="Close" />
                </td>
            </tr>
        </table>
    </div>

    protected void btn_Click(object sender, EventArgs e)
    {
          iframePatientRegistration.Attributes["src"] = "Patient_Registration.aspx?flowType=" + flowType + "&fromTime=" + hidFromTime.Value + "&toTime=" + hidToTime.Value + "&acqModalityID=" + hidAcqModalityID.Value + "&schLocationID=" + ddlScheduledProcedureStepLocation.SelectedValue;
            popupPatientRegistration.Show();
    }

我必须在模态弹出扩展器控件中显示aspx页面。  并通过查询字符串传递值  但是后面的Iframe.code中没有加载ASPX页面。

当我看到html源代码然后得到这两行

<HTML>
</HTML>

2 个答案:

答案 0 :(得分:0)

包含Div“panelPatientRegistration”的display属性设置为none。 iframe在里面,它永远不会被渲染。

答案 1 :(得分:0)

收集所有Querystring数据并将其保存在隐藏字段中并编写javascript函数,通过使用隐藏字段将值作为查询字符串传递来更改iframe的src。

    <script>
        function changeIframSrc(src) {
            document.getElementById('<%=iframePatientRegistration.ClientID %>').src = src;
        }
    </script>

我在代码中看到的问题是,您正在点击服务器端按钮,其中页面将被回发,即使您正在更改iframe的src,但由于回发而再次创建控件。所以使用上面的javascript函数调用该特定页面并使用隐藏字段传递查询字符串来解决问题。