来自C#背后代码的iframe src无法正常运行

时间:2018-11-29 22:08:40

标签: c# asp.net .net iframe

我在从代码后面设置我的框架src时出现问题,无法在我的模式单击按钮中使用。框架src正在获取值,但未在模式中显示页面。模态代码

    <asp:UpdatePanel ID="UpdatePanel3" runat="server">
        <ContentTemplate>
            <asp:Button runat="server" ID="btntest" Text="btntest" OnClick="btntest_Click"/>
        </ContentTemplate>
    </asp:UpdatePanel>

 <div class="modal fade" data-backdrop="static" data-keyboard="false" id="modalC" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">MODAL DESCRIPTION</h4>
                </div>
                <div class="modal-body no-padding" id="content">
                    <iframe id="frame1" scrolling="auto" runat="server"></iframe>
                </div>
            </div>
        </div>
    </div>


CODE BEHIND
    ==========


        protected void btntest_Click(object sender, EventArgs e)
        {
            var frame1 = (HtmlControl)this.FindControl("frame1");
            frame1.Attributes["src"] = "https://dotnet.microsoft.com/languages";

            //urIframe.Attributes.Add("src", "https://dotnet.microsoft.com/languages");
            ShowModal("modalC");
        }


        public void ShowModal(string name)
        {

            var sb = new StringBuilder();
            //sb.Append(@"<script type='text/javascript'>"); sb.Append("ShowModal('" + name + "');"); sb.Append(@"</script>");
            sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#" + name + "').modal('show');"); sb.Append(@"</script>");
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "EditModalScript", sb.ToString(), false);


        }

如果我从.aspx页面使用过,它将起作用

0 个答案:

没有答案