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 :
<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.
Your javascript function name is toast
?
Try this one ,
ScriptManager.RegisterStartupScript(this, this.GetType(), "toast()", sb.ToString(), false);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.