【问题标题】:jquery msgBox execution in code behind(c#)jquery msgBox 在代码后面执行(c#)
【发布时间】:2013-06-22 10:01:35
【问题描述】:

当用户输入错误的 ıd 或密码时,我想显示一个消息框。我将以下函数写入 .aspx 文件:

 <script type="text/javascript">
    function warningMessage() {
        $.msgBox({
            title: "Hatalı Giriş",
            content: "Kullanıcı numarası ya da şifre hatalı...",
            type: "error",
            buttons: [{ value: "Ok" }]              
        });
    }
</script>

我将以下代码写入 aspx.cs 文件:

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "warningMessage  ", "warningMessage()", false);

但此代码不起作用。你能帮帮我吗?

【问题讨论】:

    标签: c# javascript msgbox


    【解决方案1】:

    使用this plugin时需要包含3个文件:

    <script src="Scripts/jquery-2.0.0.js" type="text/javascript"></script>
    <script src="Scripts/jquery.msgBox.js" type="text/javascript"></script>
    <link href="Styles/msgBoxLight.css" rel="stylesheet" type="text/css">  
    

    我在客户端使用了这段代码:

    <script type="text/javascript">
        function warningMessage() {
            $.msgBox({
                title: "Hatalı Giriş",
                content: "Kullanıcı numarası ya da şifre hatalı...",
                type: "error",
                buttons: [{ value: "Okay"}]  
            });
        }
    </script>  
    

    在服务器端:

    Page.ClientScript.RegisterStartupScript(this.GetType(), null, "warningMessage();", true);  
    

    它很适合我

    【讨论】:

    • 这也不起作用。但是当我将 true 更改为 false 时,它​​会显示 warningMessage();在网页的顶部
    • 它确实如此.. 将函数warningMessage() 的代码更改为此{ alert('Check'); } 并评论其他所有内容.. 然后尝试..
    • 谢谢,但我知道。我想给消息框一个标题,我了解到我必须使用 jquery msgBox 内置方法来给标题。
    • 这意味着问题不在于代码隐藏调用......但在你创建的jQuery中......而且我不知道$.msgBox是否是一个函数......直到我理解你正在使用一些插件并且没有包含它的.js 文件
    • 我在 head 标签中添加了以下内容,并添加了项目所需的文件。 问题可能源于 $.msgBox
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多