我查过密码了,但没发现什么问题。
<!-- language: lang-html -->
<div class="modal fade" id="loginModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div id="loginHeader" class="modal-header">
<h4 class="modal-title">Oops, something not right.</h4>
</div>
<div id="loginContent" class="modal-body" runat="server">
</div>
<div id="loginButton" class="modal-footer">
<button type="button" class="btn btn-warning" data-dismiss="modal">OK</button>
</div>
</div>
</div>
<button type="button" style="display: none;" id="btnShowLoginModal" data-toggle="modal" data-target="#loginModal">
</button>
</div>
<script src="../Scripts/javascripts/jquery.js"></script>
<script src="../Scripts/javascripts/bootstrap.min.js"></script>
<script type="text/javascript">
function ShowLoginDialog() {
$("#btnShowLoginModal").click();
}
</script>
函数是从OnClick事件背后的代码中调用的。还是不知道哪一部分是错的。
protected void Button1_Click(object sender, EventArgs e)
{
string result = ValidateLogin(Username.Value, Password.Value);
if(result == MessageConstants.MessageSuccess)
{
Response.Redirect("~/Webpages/Character.aspx");
}
else if(result == MessageConstants.MessageFail)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "ShowLoginDialog()", true);
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "ShowLoginDialog()", true);
}
}
来自元素检查器的错误
发布于 2017-05-13 11:27:44
RegisterStartupScript()在Web的末尾(就在</form>
标记之前)发出脚本块。来源
但是您的模态代码和ShowLoginDialog函数是在此之后定义的。试着把那个</form>
标签移到最后,在模态的东西之后。
发布于 2017-05-13 10:51:12
将您的代码放在document.ready()
函数中:
$( document ).ready(function() {
function ShowLoginDialog() {
$("#btnShowLoginModal").click();
}
});
发布于 2017-05-13 11:26:34
移动
<script src="../Scripts/javascripts/jquery.js"></script>
<script src="../Scripts/javascripts/bootstrap.min.js"></script>
<script type="text/javascript">
function ShowLoginDialog() {
$("#btnShowLoginModal").click();
}
</script>
进入head
块。然后,您需要更改ShowLoginDialog
函数,使其看起来如下:
function ShowLoginDialog() {
$(function() {
$("#btnShowLoginModal").click();
});
}
https://stackoverflow.com/questions/43956761
复制相似问题