// Step 01: Copy this CSS in your code as "jquery.toastmessage-min.css"
/*Start
Notification CSS*/
.toast-container{width:280px;z-index:9999;}
* html .toast-container{position:absolute;}
.toast-item{height:auto;background:#0C4F9E;opacity:.9;-moz-border-radius:10px;-webkit-border-radius:10px;color:#eee;padding-top:20px;padding-bottom:20px;padding-left:6px;padding-right:6px;font-family:Arial;font-size:13px;border:2px solid #999;display:block;position:relative;margin:0 0 12px 0;}
.toast-item p{text-align:left;margin-left:50px; color: White;}
.toast-item-close{background:url(../../images/close.gif);width:22px;height:22px;position:absolute;top:7px;right:7px;}
.toast-item-image{width:32px;height:32px;margin-left:10px;margin-top:10px;margin-right:10px;float:left;}
.toast-item-image-notice{background:url(../images/notice.png);}
.toast-item-image-success{background:url(../../images/success.png);}
.toast-item-image-warning{background:url(../images/twarning.png);}
.toast-item-image-error{background:url(../images/terror.png);}
.toast-type-notice{color:white;}
.toast-type-success{color:white;}
.toast-type-warning{color:white;border-color:#FCBD57;}
.toast-type-error{color:white;border-color:#B32B2B;}
.toast-position-top-left{position:fixed;left:20px;top:20px;}
.toast-position-top-center{position:fixed;top:20px;left:50%;margin-left:-140px;}
.toast-position-top-right{position:fixed;top:20px;right:20px;}
.toast-position-middle-left{position:fixed;left:20px;top:50%;margin-top:-40px;}
.toast-position-middle-center{position:fixed;left:50%;margin-left:-140px;margin-top:-40px;top:50%;}
.toast-position-middle-right{position:fixed;right:20px;margin-left:-140px;margin-top:-40px;top:50%;}
/*End
Notification CSS*/
// Step 03: Copy this JS in your code as "jquery.toastmessage-min.js"
/*Start Notification JS*/
(function (c) {
var b = {
inEffect: { opacity: "show" },
inEffectDuration: 600, stayTime: 5000, text: "",
sticky: false, type: "notice",
position: "top-right", closeText: "", close: null
};
var a = {
init: function (d) {
if (d)
{
c.extend(b, d)
}
}, showToast: function
(f) {
var g =
{};
c.extend(g, b, f);
var j,
e, d, i, h;
j = (!c(".toast-container").length)
? c("<div></div>").addClass("toast-container").addClass("toast-position-" + g.position).appendTo("body") : c(".toast-container");
e = c("<div></div>").addClass("toast-item-wrapper");
d = c("<div></div>").hide().addClass("toast-item toast-type-" +
g.type).appendTo(j).html(c("<p>").append(g.text)).animate(g.inEffect,
g.inEffectDuration).wrap(e);
i = c("<div></div>").addClass("toast-item-close").prependTo(d).html(g.closeText).click(function () {
c().toastmessage("removeToast", d, g)
});
h = c("<div></div>").addClass("toast-item-image").addClass("toast-item-image-" +
g.type).prependTo(d);
if
(navigator.userAgent.match(/MSIE 6/i)) {
j.css({ top:
document.documentElement.scrollTop })
} if
(!g.sticky) {
setTimeout(function
() {
c().toastmessage("removeToast", d, g)
}, g.stayTime)
} return
d
}, showNoticeToast: function (e) {
var d =
{ text: e, type: "notice" };
return
c().toastmessage("showToast", d)
}, showSuccessToast: function (e) {
var d =
{ text: e, type: "success" };
return
c().toastmessage("showToast", d)
}, showErrorToast: function
(e) {
var d =
{ text: e, type: "error" };
return
c().toastmessage("showToast", d)
}, showWarningToast: function (e) {
var d =
{ text: e, type: "warning" };
return
c().toastmessage("showToast", d)
}, removeToast: function
(e, d) {
e.animate({ opacity: "0" }, 600, function
() {
e.parent().animate({ height: "0px" }, 300, function
() {
e.parent().remove()
})
});
if (d
&& d.close !== null) {
d.close()
}
}
};
c.fn.toastmessage = function (d) {
if
(a[d]) {
return
a[d].apply(this,
Array.prototype.slice.call(arguments, 1))
} else
{
if
(typeof d === "object"
|| !d) {
return
a.init.apply(this, arguments)
} else
{
c.error("Method " + d + " does
not exist on jQuery.toastmessage")
}
}
}
})(jQuery);
/*End Notification JS*/
// Step
04: Declare the central class to callout every page from the web easily
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
/// <summary>
/// Summary description for Notifications
/// </summary>
public static class Notifications
{
public static string getNotification(string
Message, int notificationType)
{
StringBuilder sb = new
StringBuilder();
switch (notificationType)
{
case NotificationType.SuccessToast:
sb.AppendLine("$().toastmessage('showSuccessToast',
'" + Message + "');");
break;
case NotificationType.SuccessSticky:
sb.AppendLine("$().toastmessage('showToast',
{");
sb.AppendLine(" text: '" + Message + "',");
sb.AppendLine(" sticky: true,");
sb.AppendLine(" position: 'top-right',");
sb.AppendLine(" type: 'success',");
sb.AppendLine(" closeText: '',");
sb.AppendLine(" });");
break;
case NotificationType.NoticeToast:
sb.AppendLine("$().toastmessage('showNoticeToast',
'" + Message + "');");
break;
case NotificationType.NoticeSticky:
sb.AppendLine("$().toastmessage('showToast',
{");
sb.AppendLine(" text: '" + Message + "',");
sb.AppendLine(" sticky: true,");
sb.AppendLine(" position: 'top-right',");
sb.AppendLine(" type: 'notice',");
sb.AppendLine(" closeText: '',");
sb.AppendLine("});");
break;
case NotificationType.WarningToast:
sb.AppendLine("$().toastmessage('showWarningToast',
'" + Message + "');");
break;
case NotificationType.WarningSticky:
sb.AppendLine("$().toastmessage('showToast',
{");
sb.AppendLine(" text: '" + Message + "',");
sb.AppendLine(" sticky: true,");
sb.AppendLine(" position: 'top-right',");
sb.AppendLine(" type: 'warning',");
sb.AppendLine(" closeText: '',");
sb.AppendLine("});");
break;
case NotificationType.ErrorToast:
sb.AppendLine("$().toastmessage('showErrorToast',
'" + Message + "');");
break;
case NotificationType.ErrorSticky:
sb.AppendLine("$().toastmessage('showToast',
{");
sb.AppendLine(" text:
'" + Message + "',");
sb.AppendLine(" sticky: true,");
sb.AppendLine(" position: 'top-right',");
sb.AppendLine(" type: 'error',");
sb.AppendLine(" closeText: '',");
sb.AppendLine("});");
break;
}
return sb.ToString();
}
}
public class NotificationType
{
public const int SuccessToast = 1;
public const int SuccessSticky = 2;
public const int NoticeToast = 3;
public const int NoticeSticky = 4;
public const int WarningToast = 5;
public const int WarningSticky = 6;
public const int ErrorToast = 7;
public const int ErrorSticky = 8;
}
// Step 05: Include the CSS and Javascript headers files for notification alert!
<!-- Notification CSS / JS -->
<link type="text/css" href="jquery.toastmessage-min.css" rel="stylesheet"/>
<script type="text/javascript" src=" jquery.toastmessage-min.js"></script>
<!-- End Notification CSS / JS -->
// Step 06: Method to show notification and
needs to be call from the page to show.
private void
DisplayNotification(string Message, int notificationType)
{
#region NotificationAlert
#region NotificationAlert
ScriptManager requestSM = ScriptManager.GetCurrent(this);
if (requestSM != null
&& requestSM.IsInAsyncPostBack)
{
ScriptManager.RegisterClientScriptBlock(this,
typeof(Page),
Guid.NewGuid().ToString(),
Notifications.getNotification(Message,
notificationType),
true);
}
else
{
ClientScript.RegisterStartupScript(typeof(Page),
Guid.NewGuid().ToString(),
Notifications.getNotification(Message,
notificationType),
true);
}
#endregion
#endregion
}





This comment has been removed by a blog administrator.
ReplyDeletethank you for helping me...
ReplyDeletei made some changes in code but it works...