[英]Toast notification is not displaying on a web page
My code is as follows: 我的代码如下:
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");
}
AND JAVASRICPT FUNCTION IS : 和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();
});
});
}
What is the problem? 问题是什么? notification is not seen on a button click. 单击按钮时看不到通知。 i hv written css file. 我已经写了css文件。
Your javascript function name is toast
? 您的JavaScript函数名称是toast
?
Try this one , 试试这个,
ScriptManager.RegisterStartupScript(this, this.GetType(), "toast()", sb.ToString(), false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.