引导模式弹出C#代码隐藏 [英] bootstrap modal popup c# codebehind
问题描述
我用引导我的C#asp.net项目,我想显示显示从后面的代码模式弹出。
i am using bootstrap in my c# asp.net project and i want to show to show the modal popup from code behind.
在我的网页标题,我有一个javascript函数如下:
in my page header i have a javascript function as follows:
function LoginFail() {
$('#windowTitleDialog').modal('show');
}
和我按一下按钮我打电话的JavaScript如下:
and on the click of my button i am calling the javascript as follows
ScriptManager.RegisterClientScriptBlock(this, typeof(System.Web.UI.Page), "LoginFail", "LoginFail();", true);
这不显示模式弹出。不过,如果我使用像警报('登录失败')
,它工作正常。
this does not show the modal popup. however, if i use something like alert('login failed')
, it works fine.
任何人可以请与帮助呢?
can anybody please help with this?
推荐答案
在默认情况下引导的JavaScript文件只是在结束标记之前包括
By default Bootstrap javascript files are included just before the closing body tag
<script src="vendors/jquery-1.9.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="vendors/easypiechart/jquery.easy-pie-chart.js"></script>
<script src="assets/scripts.js"></script>
</body>
我把这些JavaScript文件到头部分身体标记之前,我写了一个小功能调用模式弹出:
I took these javascript files into the head section right before the body tag and I wrote a small function to call the modal popup:
<script src="vendors/jquery-1.9.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="vendors/easypiechart/jquery.easy-pie-chart.js"></script>
<script src="assets/scripts.js"></script>
<script type="text/javascript">
function openModal() {
$('#myModal').modal('show');
}
</script>
</head>
<body>
然后我可以调用从代码隐藏模式弹出与以下内容:
then I could call the modal popup from code-behind with the following:
protected void lbEdit_Click(object sender, EventArgs e) {
ScriptManager.RegisterStartupScript(this,this.GetType(),"Pop", "openModal();", true);
}
这篇关于引导模式弹出C#代码隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!