我正在使用HTML模式,
HTML
<!-- Modal -->
<div class="modal fade" id="myModal" 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>
<h4 class="modal-title" id="myModalLabel">Server Message</h4>
</div>
<div class="modal-body">
<div class="table-responsive">
<table class="table mb30">
<thead>
<tr>
<th>#</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Return Message</td>
<td><asp:Label ID="Label1" class="col-sm-8 control-label" runat="server" Text="Label"></asp:Label></td>
</tr>
<tr>
<td>2</td>
<td>Return ID</td>
<td><asp:Label ID="Label2" class="col-sm-8 control-label" runat="server" Text="Label"></asp:Label></td>
</tr>
<tr>
<td>3</td>
<td>Return Status</td>
<td><asp:Label ID="Label3" class="col-sm-8 control-label" runat="server" Text="Label"></asp:Label></td>
</tr>
</tbody>
</table>
</div>
<!-- content1 end -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
<!-- modal-content -->
</div>
<!-- modal-dialog -->
</div>
<!-- modal -->
我试图使用
从函数后面的C#代码中打开这个模型ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script>$('#myModal').modal('show');</script>", false);
由于某种原因,它无法正常工作 我想在保存函数的末尾显示这个模态和返回值。这个模态可以在按钮点击时打开,但如何从C#函数打开这个模态?
答案 0 :(得分:1)
你可以这样做。
创建JavaScript函数
<script>
function ShowPopup()
{
$('#myModal').modal('show');
}
</script>
现在调用以下功能:
ScriptManager.RegisterStartupScript(this, this.GetType(), "none", "ShowPopup();", true);