Saturday 9 August 2014

Add a notification bar to your website using jQuery in asp.net





notification bar in jquery

Description:-


In this example we explain that how to display notification or popup message in asp.net. Or how to create notification bar or prompt using query in asp.net.

Today we all show that Many websites display notifications bar or information bar in top of the pages when some functionality is performed by user. Notification bar or information bar is nothing but it contains some text information, graphics or any other HTML.

Notification bar are very useful to  remember the user's choice of closing the notification bar. you can substitute anything in Notificatin Bar or Information Bar like: Twitter or Facebook "follow us" buttons, custom graphics, or advertisements.

To show Example of How to Upload Multiple File in MVC Application then click here upload multiple File in MVC

How to upload File and Fetch file from SqlServer and bind to Gridview fetch file from Sqlserver and bind to Gridview



Code:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Display Notification or Prompt Bar in asp.net</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(window).scroll(function () {
                if (fetchcookie_val("ShowInfoBar") == null) {
                    $("#notification_pnl").css("marginTop", $(window).scrollTop());
                }
            });
            $(window).resize(function () {
                if ($(window).width() < 300) {
                    $("#notification_pnl").css('display', 'none');
                }
                else {
                    $("#notification_pnl").css('display', 'block');
                }
            });
            $("#closeBtn").click(function (evt) {
                $("#notification_pnl").slideUp('slow');
                document.cookie = "ShowInfoBar=false;path=/";
                evt.preventDefault();
            });
            if (fetchcookie_val("ShowInfoBar") == null) {
                $("#notification_pnl").css('display', 'block');
            }
            else {
                $("#notification_pnl").css('display', 'none');
            }


            var fetchcookie_val = function (name) {
                var cookieName = name + "=";
                var cookieArray = document.cookie.split(';');
                for (var i = 0; i < cookieArray.length; i++) {
                    var c = cookieArray[i];
                    while (c.charAt(0) == ' ')
                        c = c.substring(1, c.length);
                    if (c.indexOf(cookieName) == 0)
                        return c.substring(cookieName.length, c.length);
                }
                return null;
            }

        });
    </script>
    <style type="text/css">
        .InfoBar
        {
            background-color: silver;
            color: #333333;
            font-weight: bold;
            position: absolute;
            width: 100%;
            top: 0px;
            left: 0px;
            text-align: center;
            border-bottom-width: 2px;
            border-bottom-color: #666666;
            border-bottom-style: solid;
            text-align: center;
            padding: 10px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Panel ID="notification_pnl" runat="server" CssClass="InfoBar">
            <asp:Label ID="Label1" runat="server" ForeColor="Red">notification or prompt bar developed by aspsolutionkirit.blogspot.in in ASP.NET using jQuery.</asp:Label>
            <br />
            <asp:Button ID="closeBtn" runat="server" Text="Close" />
        </asp:Panel>
    </div>
    </form>
</body>
</html>


0 comments:

Post a Comment