Friday, February 27, 2015

REMAINDER SCHEDULAR ALERT USING JQUERY TIMER

Add the following jquery files 

You need to  download the following files

  <link type="text/css" rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>

    <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

    <script src="jquery.timers.js"></script>
    
    <script type="text/javascript">

        $(document).everyTime(10000, function (i) {
            $.ajax({
                type: "POST",
                url: "popup.aspx/GetUserInfoData",
                data: '{}',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                failure: function (response) {
                    alert("Failure Details : " + response.d);
                },
                error: function (response) {
                    alert("Error Details: " + response.d);
                }
            });
        });
        function OnSuccess(response) {
            var xmlDoc = $.parseXML(response.d);
            var xml = $(xmlDoc);
            var users = xml.find("Table");
            if (users.length >= 1) {
                $("#div1").dialog({
                    title: "Hi Welcome",
                    width: 600,
                    height: 400,
                    modal: true,
                    buttons: {
                        Close: function() {
                            $(this).dialog('close');
                        }
                    }
                });
            }
        }

    </script>









Design:


<body>
    <form id="form1" runat="server">
        <div>
            <div id="div1" style="display: none">
                <b>Welcome to this World</b>
            </div>
        </div>
    </form>

</body>


protected void Page_Load(object sender, EventArgs e)
    {

    }

    [WebMethod]
    public static string GetUserInfoData()
    {

        SqlConnection con = new SqlConnection("    ");
        SqlCommand cmd = new SqlCommand("select * from fdfd", con);
        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(ds);
        return ds.GetXml();

    }






Output:

Wait for 15 seconds, then the pop up will be displayed automatically.




Thursday, February 26, 2015

Test Browser Supports Cookies Are Not

Design the form as follows:

<head runat="server">
    <title></title>
    <script type="text/javascript">
        function checkcookies() {
            if (navigator.cookieEnabled)
                alert("Cookies are Enabled");
            else
                alert("Cookies are Disabled");
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="checkcookies();" />
    </div>
    </form>

</body>








Output:





Creating ZIP File

First download the dll Ionic.Zip from the following URL.

https://dotnetzip.codeplex.com/releases/view/68268

And, then add the dll( by Using Add Reference)

Design the form as follows:



<body>
    <form id="form1" runat="server">
    <div>
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="btnFileUpload" runat="server" Text="ZipFile" OnClick="btnFileUpload_Click" />
        <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
    </div>
    </form>
</body>


Add, the following Namespace:

using Ionic.Zip;


protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnFileUpload_Click(object sender, EventArgs e)
    {
        try
        {
            string FileName = string.Empty;
            if (FileUpload1.HasFile)
            {
                FileName = FileUpload1.FileName;
                string path = Server.MapPath("~/Files/" + FileName);
                FileUpload1.SaveAs(path);
                ZipFile obj = new ZipFile();
                obj.AddFile(path);
                obj.Save(Server.MapPath("~/Files/File.zip"));
                lblMessage.Text = "Upload Successfully";
            }
        }
        catch (Exception)
        {
            throw;
        }

    }





output:





Wednesday, February 25, 2015

Gridview using jQuery in ASP.NET

Design the form the as follows:



<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="grdActivation" runat="server" AutoGenerateColumns="False">
            <Columns>
                <asp:BoundField DataField="Userid" HeaderText="Userid" />
                <asp:BoundField DataField="Name" HeaderText="Name" />
                <asp:BoundField DataField="Emailid" HeaderText="Emailid" />
            </Columns>
        </asp:GridView>
    </div>
    </form>

</body>


javascript Function:

<script src="jquery-1.7.min.js"></script>
   
    <script type="text/javascript">
        $(function () {
            $.ajax({
                type: "POST",
                url: "Default9.aspx/GetUserInfoData",
                data: '{}',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccess,
                failure: function (response) {
                    alert("Failure Details : " + response.d);
                },
                error: function (response) {
                    alert("Error Details: " + response.d);
                }
            });
        });

        function OnSuccess(response) {
            var xmlDoc = $.parseXML(response.d);
            var xml = $(xmlDoc);
            var users = xml.find("Table");
            var row = $("[id*=grdActivation] tr:last-child").clone(true);
            $("[id*=grdActivation] tr").not($("[id*=grdActivation] tr:first-child")).remove();
          
            $.each(users, function () {
                $("td", row).eq(0).html($(this).find("Userid").text());
                $("td", row).eq(1).html($(this).find("Name").text());
                $("td", row).eq(2).html($(this).find("Emailid").text());
                $("[id*=grdActivation]").append(row);
                row = $("[id*=grdActivation] tr:last-child").clone(true);
            });
        }

    </script>










.cs Page:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindEmptyRow();
        }
    }


    private void BindEmptyRow()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("Userid");
        dt.Columns.Add("Name");
        dt.Columns.Add("Emailid");
        dt.Rows.Add();
        grdActivation.DataSource = dt;
        grdActivation.DataBind();
    }

    [WebMethod]
    public static string GetUserInfoData()
    {
        SqlConnection con = new SqlConnection("------------");
        SqlCommand cmd = new SqlCommand("select * from sdfsf", con);
        DataSet ds = new DataSet();
        SqlDataAdapter da=new SqlDataAdapter(cmd);  
        da.Fill(ds);
        return ds.GetXml();

    }









output:




in case if , you want to apply styles to the rows alternative color than add below lines of javascript code.


var index= 1;
         $.each(users, function () {
                $("td", row).eq(0).html($(this).find("Userid").text());
                $("td", row).eq(1).html($(this).find("Name").text());
                $("td", row).eq(2).html($(this).find("Emailid").text());
                $("[id*=grdActivation]").append(row);
                row = $("[id*=grdActivation] tr:last-child").clone(true);
         
            if index= == 1 || index= % 2 != 0)) {
                $(row).css("background-color", "colorcode");
            }
            else {
                $(row).css("background-color", "colorcode");
            }
            indexindex+ 1;
            row = $("[id*=grdActivation] tr:last-child").clone(true);
        });





CALLING JQUERY CODE FROM SERVER SIDE

Design the form as follows:

<head runat="server">
    <title></title>
    <script src="jquery-1.7.min.js"></script>
</head>

<form id="form1" runat="server">
    <div>
        <asp:Button ID="btnjquery" runat="server" Text="callingjquerycode" OnClick="btnjquery_Click" />
    </div>
    </form>

.cs page:

protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnjquery_Click(object sender, EventArgs e)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("$(document).ready(function(){");
        sb.Append("alert('hi welcome to this world.');");
        sb.Append("});");
       Page.ClientScript.RegisterStartupScript(this.GetType(), "Script",sb.ToString(), true);
    }


Output:



Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...