【问题标题】:bootstrap modal popup is not display from code behind?Only shadow is displaybootstrap modal popup 不从后面的代码显示?只显示阴影
【发布时间】:2017-11-04 05:56:23
【问题描述】:

当我想在成功提交数据后调用它以显示成功消息时,后面的代码不显示模态弹出窗口的原因是什么。但只有阴影显示不是完整的模态

以下是我的html代码

                <div class="modal-content">

                    <div class="modal-header">
                        <h4 class="modal-title">Confirmation</h4>
                    </div>
                    <div class="modal-body ">
                        <label style="color: green">
                            Your data is saved successfully.
                        </label>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
                    </div>
                </div>
            </div>
        </div>

调用modal的c#代码如下

ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "$('#popup3').modal('show');", true);

【问题讨论】:

    标签: c# bootstrap-modal


    【解决方案1】:

    试试这个

    ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "clentscript", "$('#popup3').modal('show');", true);
    

    this.RegisterStartupScript("clentscript", "<script>$('#popup3').modal('show');</script>");
    

    【讨论】:

    • 是的,我使用更新面板。我也试过没有更新面板但没有运气
    • 还有一个控件用于这样做。 html部分&lt;asp:Literal ID="LiteralText" runat="server" Text="This is example of Literal"&gt;&lt;/asp:Literal&gt;和代码部分Literal1.Text = @"&lt;script&gt;$(function(){$('#popup3').modal('show');});&lt;/script&gt;";
    • 先生试着理解我的问题,模态被调用但不能正确显示,即它只显示阴影
    • 那么风格是问题而不是代码我建议你改变你的问题。
    【解决方案2】:
    1. 使用您需要的任何输入在更新面板中创建模式(文本框)

    <asp:Button runat="server" Text="Open Modal" ID="button1" OnClick="button1_click"/>
    
    <asp:UpdatePanel ID="updatePanel1" runat="server" UpdateMode="Conditional">
      <ContentTemplate>
        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header"></div>
              <div class="modal-body">
                <asp:TextBox ID="txtBox" runat="server"></asp:TextBox>
              </div>
            </div>
          </div>
        </div>
      </ContentTemplate>
    </asp:UpdatePanel>
    1. 点击后,更新您的模式面板并注册脚本

    protected void button1_click(object sender, EventArgs e) {
      txtBox.Text = "update text";
      updatePanel1.Update();
      ScriptManager.RegisterClientScriptBlock(updatePanel1, this.GetType(), "script", " $('#exampleModal').modal('show');", true);
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多