Friday, June 12, 2009

Show Error/Succcess Messages like gmail,yahoo mail through JQuery

Hi All,
Recently i have applied new message system like what we have seen in gmail and yahoo , when we delete the message,the message come for 4-5 second and after that it just fade out. First i was thinking it is going to be though.But after i implement it,i was not all that diffcult.So below is the solution .

/******************************************************************/
First we have to place a div in the master page and have to assign id to it.
<div id="msgdiv"></div>

Make the body of the master page runat="server" and have a id for it as well.

<body id="MainBody" runat="server">

we also have to add jquery file of 1.2.1min.js file :
<script src="js/jquery-1.2.1.min.js" type="text/JavaScript"></script>

Now lets say you want to show message on deleting of message from inbox.
So add the following two functions in JavaScript:

function DeleteFromInbox() {
document.getElementById("msgdiv").className = "quick-alert";
document.getElementById("msgdiv").innerHTML = "<table border='0' align='center' cellpadding='0' cellspacing='0'><tr><td><img src='images/checked_new_icon.jpg' alt='' /></td><td width='8'> </td><td>message deleted from inbox successfully.</td></tr></table>";
setTimeout("FadeOutDiv()", 2000);
}
function ErrorInDeleteing() {
document.getElementById("msgdiv").className = "quick-alert";
document.getElementById("msgdiv").innerHTML = "<table border='0' align='center' cellpadding='0' cellspacing='0'><tr><td><img src='images/checked_new_icon.jpg' alt='' /></td><td width='8'> </td><td>message was not deleted from inbox.</td></tr></table>";
setTimeout("FadeOutDiv()", 2000);
}
function FadeOutDiv() {
$(".quick-alert").fadeOut("slow", function() {
$(".quick-alert").remove();
});
}

we should have following in our css file :
.quick-alert
{
width:66%;
background:#EE5A1E; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#fff; font-weight:bold; text-align:center; border:1px solid #727272; padding:5px; margin:3px;margin-left:100px;

}
here you can set BG-color and font size according to your design.

Now finally on the click of the delete button we have to call this function from server-side :
protected void btnDelete_Click(object sender, ImageClickEventArgs e)
{
int i = DeleteFromInbox();
// after this we can return any variable knowing if the message is deleted or not
HtmlGenericControl MasterPageBodyTag = (HtmlGenericControl)this.Page.Master.FindControl("MainBody");
if (i>0)
{
MasterPageBodyTag.Attributes.Add("Onload", "javascript:DeleteFromInbox();");
}
else
{
MasterPageBodyTag.Attributes.Add("Onload", "javascript:ErrorInDeleteing();");
}
}
/******************************************************************/

23 comments:

  1. Thank you, insightful. Shouldn't there be a jquery plugin for that by now?

    ReplyDelete
  2. The number can however represent some trouble for the individuals who are not exceptionally well known to the mail settings. As well as can be expected do in this circumstance is hunt the rundown of all the yahoo client administration helpline number via seeking the web and after that get the help that you are searching for.https://800support.net/yahoo-support/use-safe-search-yahoo-filter-adult-content/

    ReplyDelete

  3. 5 helpful tips to make you a better user for Skype. Contact Us@: Help Number

    ReplyDelete
  4. Facebook customer care team always available to solve critical issues of facebook account. Facebook help service team always try to their best easy and efficient solution of complex issues.Facebook Help Service Number

    ReplyDelete
  5. How To Add Animated Or Gif Images In Yahoo Mail

    While to add animated or GIF images, you get the errors on Yahoo mail. And receiving the errors messages on your screen. First thing on your mind that Yahoo will not accept attachment with special characters, and signs. You can take the helpful guidance via Yahoo Technical Support Toll Free Number.And get the all technical queries related to adding images problem in Yahoo mail.

    ReplyDelete
  6. You must disable the anti-virus, add-ons, and firewalls if you think they may be disrupting the Yahoo mail. If the problem still persists, then get in touch with our certified Yahoo technicians on our toll-free Yahoo customer care number for the complete solution to your Yahoo account.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Find attachment file in Yahoo mail

    In case you are not able the download attachment file;Contact a Yahoo customer care helpline phone number support.

    ReplyDelete
  9. Nice blog has been shared by you. before i read this blog i didn't have any knowledge about this but now i got some knowledge. McAfee Antivirus software then just go through the link here. Click Here:- McAfee Antivirus Helpline Number

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. Help! Sync Yahoo Calendar with Iphone Calendar

    Are you want Yahoo calendar and Iphone calendar to sync automatically? Here is easily set up Yahoo and Iphone calendar sync.Yahoo and Iphone calendar setting are check and sync both calendar.In case of any technical issues while sync Yahoo and Iphone calendar,call a certified toll free Yahoo customer service phone number anytime.

    ReplyDelete
  12. How to Install Multiple Skype on Mac

    If you want run multiple Skype accounts at a same time on System,Please contact online support expert just call Skype Customer Service Number 1-888-841-6062.

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Fix Authentication Failed Message for MSN Account

    Get the "Authentication failed error" message for msn mail for technical issues to your account,setting issues,network issues or change the password or username etc.If you find the fix error message to get solution via MSN customer support phone number 24/7 and get the fixed error for MSN account.

    ReplyDelete
  15. Very Nice Blog I Read Your Post Its Amazing It Is Very Interesting post Thank You For Post then just go through the click here :-Buying a Old Car

    ReplyDelete
  16. . Our endeavor is to introduce the to child to the joys of learning in a harmonious and eco-friendly environment and emphasize on the all round development of the child through age-appropriate learning activities. We stand committed to give our nursery school a few dimension to inculcate sanskaar in the nascent mind of the children and make them rise on the strong foundation achieve greater success in life.

    http://www.sanskaarkidskingdom.com/

    ReplyDelete
  17. This, joint venture-“Vision wisdom” will certainly attract the attention of families focusing on resident property requirement or ownership approach. Simultaneously it will facilitate the kid’s educational requirement with in the vicinity our relationship in the days to come.

    http://www.sanskaarkidskingdom.com/lucknow/

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. Quickbooks error code h202 usually appears on your screen when you try to open a file that requires QuickBooks, and it may appear for any reason, when QuickBooks is not connecting to the server.

    ReplyDelete
  20. Thank you for sharing such a really admire your post. Your post is great! Visit our site If you interested for Online betting.. Thank you.

    ReplyDelete