Bootstrap模式触发但未触发ASP按钮点击事件-更新问题
我按照教程从“Bootstrap Modal fires but not ASP Button Click event”on stack overflow,我复制并粘贴代码到我的asp.net core. and It not even loading up the modal at all.我尝试UseSubmitBehavior =“false”停止postback,我仍然不能让它工作.
home.aspx
<div id="example" class="modal hide fade in" style="display: none;">
<div class="modal-header">
<a class="close" data-dismiss="modal">x</a>
<h3>Enter Comments Below:</h3>
</div>
<div class="modal-body">
<h4>Comments</h4>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-success">Call to action</a>
<a href="#" class="btn" data-dismiss="modal">Close</a>
</div>
</div>
<script type="text/javascript">
$('input[name$="TestButton2"]').on("click", function () {
$('#example').modal('toggle');
return false;
});
</script>
答案中的C#代码。home.aspx.cs
protected void TestButton_Click(object sender, EventArgs e)
{
// do something then call modal
ClientScript.RegisterStartupScript(GetType(), "Show", "<script> $('#example').modal('toggle');</script>");
}
我尝试了UseSubmitBehavior =“false”,它在其他js函数如alert中工作得很好。我还是没有得到模态弹出来。
1条答案
按热度按时间9jyewag01#
ScriptManager.RegisterStartupScript(this,GetType(),“modal”,“$('#exampleModal').modal('show ');“,true); //show popup