Toast通知未显示在网页上

时间:2013-12-20 05:44:36

标签: c# asp.net

我的代码如下:

 void CallToast(String msg, String cls)
{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.Append("<script language='javascript'>");
    sb.Append("toast(" + msg + "," + cls + ");");
    sb.Append("</script>");
    ScriptManager.RegisterStartupScript(this, this.GetType(), "ajax", sb.ToString(), false);
}

protected void Button1_Click(object sender, EventArgs e)
{
    CallToast("Oops... Some thing is wrong...", "toast-error");
}

和JAVASRICPT功能是:

<script type="text/javascript">
function toast(sMessage, sIco) {
    if ($('.toast').length <= 0) {
        var container = $(document.createElement("div"));
        container.addClass("toast");
        container.appendTo(document.body);
    }

    var message = $(document.createElement("div"));
    message.addClass(sIco);
    message.text(sMessage);
    message.appendTo($('.toast'));
    message.delay(100).fadeIn("slow", function () {
        $(this).delay(5000).fadeOut("slow", function () {
            $(this).remove();
        });
    });
}

有什么问题?单击按钮时看不到通知。我写了css文件。

1 个答案:

答案 0 :(得分:0)

您的javascript函数名称是toast
试试这个,

ScriptManager.RegisterStartupScript(this, this.GetType(), "toast()", sb.ToString(), false);