Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 引导模式-添加服务器代码ASP.Net_C#_Asp.net_C# 4.0_Twitter Bootstrap 3 - Fatal编程技术网

C# 引导模式-添加服务器代码ASP.Net

C# 引导模式-添加服务器代码ASP.Net,c#,asp.net,c#-4.0,twitter-bootstrap-3,C#,Asp.net,C# 4.0,Twitter Bootstrap 3,Net webform应用程序实现引导。目前,我有一个标签和一个文本框显示在Bootstrap-model中,我正试图从服务器c#文件向其发送数据。由于某种原因,模式消失,在UI上没有显示任何内容 ASPx文件 <!-- Button to trigger modal --> <a href="#myModal" role="button" runat="server" class="btn btn-lg btn-success" data-toggle="modal">

Net webform应用程序实现引导。目前,我有一个标签和一个文本框显示在Bootstrap-model中,我正试图从服务器c#文件向其发送数据。由于某种原因,模式消失,在UI上没有显示任何内容

ASPx文件

<!-- Button to trigger modal -->
<a href="#myModal" role="button" runat="server" class="btn btn-lg btn-success" data-toggle="modal">Launch demo modal</a>
<%--<asp:Button ID="Button1" role="button" type="button" runat="server" Text="Modal" class="btn btn-lg btn-success"  data-toggle="modal" data-target="#myModal"/>--%>

<!-- Modal -->
<div id="myModal" class="modal fade" 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" aria-hidden="true">×</button>
                <h3 id="myModalLabel">Modal header</h3>
            </div>
            <div class="modal-body">

                <asp:Label ID="Label1" runat="server"></asp:Label>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
                <button class="btn btn-primary">Save changes</button>
            </div>
        </div>
    </div>
</div>
请指教


ps:我需要使用更新面板吗?

对于这一点,更新面板可能不是最好的解决方案,因为只更新了部分html,并且在部分回发后不会再次调用模式的Javascript/Jquery

在回发之后,您需要某种方式再次调用Javascript。您可以调用所需的Javascript在
Click\Me
事件上打开模式

    protected void Click_Me(object sender, EventArgs e)
    {
      // do stuff
      Label1.Text = "test label";
      TextBox1.Text = "text box text";
      modal_Img.Src = "test path";

      // make sure the modal opens
      ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "script", "<script type='text/javascript'>$( document ).ready(function() { $('#MyModal').modal('show')});</script>", false);
    }
protectedvoid单击我(对象发送方,事件参数e)
{
//做事
Label1.Text=“测试标签”;
TextBox1.Text=“文本框文本”;
modal_Img.Src=“测试路径”;
//请确保打开模式
ScriptManager.RegisterClientScriptBlock(this.Page,this.Page.GetType(),“script”,“$(document).ready(function(){$('#MyModal').modal('show'));”,false);
}

My answer假设您正在从模式中的按钮调用
Click\u Me
事件。否则,模式窗口的默认功能是在单击其外部时关闭。不管是哪种方式,您都希望它能在回发后打开备份并显示您的更新。您好,我修改了下面的代码-添加了一个按钮-然后在c#ScriptManager.RegisterClientScriptBlock(this.Page,this.Page.GetType(),“script”,“$(document).ready(function(){$('.#MyModal').modal('show'));,false);-但是我没有看到模态出现-???我错过什么了吗here@Vivekakk对你有用吗?很难说
数据切换
数据目标
在asp.net回发期间会起作用,但是添加
脚本管理器
代码基本上会注入在重新加载页面时打开或重新打开模式所需的javascript。这不起作用dude-我删除了触发器并删除了按钮上的注释我添加了onclick事件。然后我添加了c#中u建议的调用代码。似乎仍然不起作用。我还需要做什么吗?老兄,我添加了更新面板和脚本管理器。它现在可以工作了,但问题是模式在服务器逻辑运行之前和之后出现了两次。
    protected void Click_Me(object sender, EventArgs e)
    {
      // do stuff
      Label1.Text = "test label";
      TextBox1.Text = "text box text";
      modal_Img.Src = "test path";

      // make sure the modal opens
      ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "script", "<script type='text/javascript'>$( document ).ready(function() { $('#MyModal').modal('show')});</script>", false);
    }