Tuesday 21 June 2016

To add Loading animation while loading web pages or task

Showing Loading animation while page loading or task loading is simple just follow these steps...


Step 1: Put this code in style tag inside header tag

CSS code:

.windows8 { position: relative; width: 78px; height:78px; margin:auto; } .windows8 .wBall { position: absolute; width: 74px; height: 74px; opacity: 0; transform: rotate(225deg); -o-transform: rotate(225deg); -ms-transform: rotate(225deg); -webkit-transform: rotate(225deg); -moz-transform: rotate(225deg); animation: orbit 6.96s infinite; -o-animation: orbit 6.96s infinite; -ms-animation: orbit 6.96s infinite; -webkit-animation: orbit 6.96s infinite; -moz-animation: orbit 6.96s infinite; } .windows8 .wBall .wInnerBall{ position: absolute; width: 10px; height: 10px; background: rgb(0,0,0); left:0px; top:0px; border-radius: 10px; } .windows8 #wBall_1 { animation-delay: 1.52s; -o-animation-delay: 1.52s; -ms-animation-delay: 1.52s; -webkit-animation-delay: 1.52s; -moz-animation-delay: 1.52s; } .windows8 #wBall_2 { animation-delay: 0.3s; -o-animation-delay: 0.3s; -ms-animation-delay: 0.3s; -webkit-animation-delay: 0.3s; -moz-animation-delay: 0.3s; } .windows8 #wBall_3 { animation-delay: 0.61s; -o-animation-delay: 0.61s; -ms-animation-delay: 0.61s; -webkit-animation-delay: 0.61s; -moz-animation-delay: 0.61s; } .windows8 #wBall_4 { animation-delay: 0.91s; -o-animation-delay: 0.91s; -ms-animation-delay: 0.91s; -webkit-animation-delay: 0.91s; -moz-animation-delay: 0.91s; } .windows8 #wBall_5 { animation-delay: 1.22s; -o-animation-delay: 1.22s; -ms-animation-delay: 1.22s; -webkit-animation-delay: 1.22s; -moz-animation-delay: 1.22s; } @keyframes orbit { 0% { opacity: 1; z-index:99; transform: rotate(180deg); animation-timing-function: ease-out; } 7% { opacity: 1; transform: rotate(300deg); animation-timing-function: linear; origin:0%; } 30% { opacity: 1; transform:rotate(410deg); animation-timing-function: ease-in-out; origin:7%; } 39% { opacity: 1; transform: rotate(645deg); animation-timing-function: linear; origin:30%; } 70% { opacity: 1; transform: rotate(770deg); animation-timing-function: ease-out; origin:39%; } 75% { opacity: 1; transform: rotate(900deg); animation-timing-function: ease-out; origin:70%; } 76% { opacity: 0; transform:rotate(900deg); } 100% { opacity: 0; transform: rotate(900deg); } } @-o-keyframes orbit { 0% { opacity: 1; z-index:99; -o-transform: rotate(180deg); -o-animation-timing-function: ease-out; } 7% { opacity: 1; -o-transform: rotate(300deg); -o-animation-timing-function: linear; -o-origin:0%; } 30% { opacity: 1; -o-transform:rotate(410deg); -o-animation-timing-function: ease-in-out; -o-origin:7%; } 39% { opacity: 1; -o-transform: rotate(645deg); -o-animation-timing-function: linear; -o-origin:30%; } 70% { opacity: 1; -o-transform: rotate(770deg); -o-animation-timing-function: ease-out; -o-origin:39%; } 75% { opacity: 1; -o-transform: rotate(900deg); -o-animation-timing-function: ease-out; -o-origin:70%; } 76% { opacity: 0; -o-transform:rotate(900deg); } 100% { opacity: 0; -o-transform: rotate(900deg); } } @-ms-keyframes orbit { 0% { opacity: 1; z-index:99; -ms-transform: rotate(180deg); -ms-animation-timing-function: ease-out; } 7% { opacity: 1; -ms-transform: rotate(300deg); -ms-animation-timing-function: linear; -ms-origin:0%; } 30% { opacity: 1; -ms-transform:rotate(410deg); -ms-animation-timing-function: ease-in-out; -ms-origin:7%; } 39% { opacity: 1; -ms-transform: rotate(645deg); -ms-animation-timing-function: linear; -ms-origin:30%; } 70% { opacity: 1; -ms-transform: rotate(770deg); -ms-animation-timing-function: ease-out; -ms-origin:39%; } 75% { opacity: 1; -ms-transform: rotate(900deg); -ms-animation-timing-function: ease-out; -ms-origin:70%; } 76% { opacity: 0; -ms-transform:rotate(900deg); } 100% { opacity: 0; -ms-transform: rotate(900deg); } } @-webkit-keyframes orbit { 0% { opacity: 1; z-index:99; -webkit-transform: rotate(180deg); -webkit-animation-timing-function: ease-out; } 7% { opacity: 1; -webkit-transform: rotate(300deg); -webkit-animation-timing-function: linear; -webkit-origin:0%; } 30% { opacity: 1; -webkit-transform:rotate(410deg); -webkit-animation-timing-function: ease-in-out; -webkit-origin:7%; } 39% { opacity: 1; -webkit-transform: rotate(645deg); -webkit-animation-timing-function: linear; -webkit-origin:30%; } 70% { opacity: 1; -webkit-transform: rotate(770deg); -webkit-animation-timing-function: ease-out; -webkit-origin:39%; } 75% { opacity: 1; -webkit-transform: rotate(900deg); -webkit-animation-timing-function: ease-out; -webkit-origin:70%; } 76% { opacity: 0; -webkit-transform:rotate(900deg); } 100% { opacity: 0; -webkit-transform: rotate(900deg); } } @-moz-keyframes orbit { 0% { opacity: 1; z-index:99; -moz-transform: rotate(180deg); -moz-animation-timing-function: ease-out; } 7% { opacity: 1; -moz-transform: rotate(300deg); -moz-animation-timing-function: linear; -moz-origin:0%; } 30% { opacity: 1; -moz-transform:rotate(410deg); -moz-animation-timing-function: ease-in-out; -moz-origin:7%; } 39% { opacity: 1; -moz-transform: rotate(645deg); -moz-animation-timing-function: linear; -moz-origin:30%; } 70% { opacity: 1; -moz-transform: rotate(770deg); -moz-animation-timing-function: ease-out; -moz-origin:39%; } 75% { opacity: 1; -moz-transform: rotate(900deg); -moz-animation-timing-function: ease-out; -moz-origin:70%; } 76% { opacity: 0; -moz-transform:rotate(900deg); } 100% { opacity: 0; -moz-transform: rotate(900deg); } }

Step 2:Put this Div tag code in Body of html

HTML Code:

 <div class="windows8">
<div class="wBall" id="wBall_1">
<div class="wInnerBall">
</div>
</div>
<div class="wBall" id="wBall_2">
<div class="wInnerBall">
</div>
</div>
<div class="wBall" id="wBall_3">
<div class="wInnerBall">
</div>
</div>
<div class="wBall" id="wBall_4">
<div class="wInnerBall">
</div>
</div>
<div class="wBall" id="wBall_5">
<div class="wInnerBall">
</div>
</div>
</div>


 
Step 3:This will show the Loading button continuously if you want to show this at page  loading event, just use this jquery script

Friday 7 August 2015

How to send form details as mail in c#

Copy and paste below code inside the <div> tag of aspx file:

  <asp:Label ID="Label1" runat="server" Text=" Name:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName" ErrorMessage="Please Enter your name!!"></asp:RequiredFieldValidator>
        <br />
        <br />
        <asp:Label ID="Label2" runat="server" Text="Address:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
&nbsp;
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtAddress" ErrorMessage="Please Enter your Address!!"></asp:RequiredFieldValidator>
        <br />
        <br />
        <asp:Label ID="Label3" runat="server" Text="Mobile:"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>
&nbsp;&nbsp;
        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtMobile" ErrorMessage="Please enter your Mobile Number!!"></asp:RequiredFieldValidator>
        <br />
        <br />
        Date of Birth:
        <asp:TextBox ID="txtDob" runat="server"></asp:TextBox>
&nbsp;&nbsp;
        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtDob" ErrorMessage="Please Enter your Date of Birth!!"></asp:RequiredFieldValidator>
        <br />
        <br />
        E-Mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="txtMail" runat="server"></asp:TextBox>
&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtMail" ErrorMessage="Please enter your Mail ID!!"></asp:RequiredFieldValidator>
        <br />
        <br />
    <table>
         <tr>
                <td>
                    Enter Below Code :
                </td>
                <td>
                    <asp:TextBox ID="txtCaptcha" runat="server" Width="200px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <%--<asp:UpdatePanel ID="UP1" runat="server">--%>
                        <ContentTemplate>
                            <table>
                                <tr>
                                    <td style="height: 50px; width:100px;">
                                        <asp:Image ID="imgCaptcha" runat="server" />
                                    </td>
                                    <td >
                                        <asp:Button ID="btnRefresh" runat="server" Text="Refresh" OnClick="btnRefresh_Click" />
                                    </td>
                                </tr>
                            </table>
                        </ContentTemplate>
                    <%--</asp:UpdatePanel>--%>
                </td>
            </tr>
            <tr>
                <td colspan="2" >
                    <asp:Button ID="btnRegiser" runat="server" Text="Save" OnClick="btnRegister_Click" />
                </td>
            </tr>
        </table>

Paste below code in aspx.cs file:


   public static void SendGmail(string userName, string password,
 string mailFrom,string mailTo, string commaDelimCCs,
             string subject, string message, bool isBodyHtml)
         {
             System.Net.Mail.MailMessage msg = new
 System.Net.Mail.MailMessage(mailFrom, mailTo,
             subject, message);
             msg.IsBodyHtml = isBodyHtml;
             if (commaDelimCCs != "")
                 msg.CC.Add(commaDelimCCs);
             System.Net.NetworkCredential cred = new
             System.Net.NetworkCredential(userName, password);
             System.Net.Mail.SmtpClient mailClient = new
 System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
             mailClient.EnableSsl = true;
             mailClient.UseDefaultCredentials = false;
             mailClient.Credentials = cred;
             mailClient.Send(msg);

         }
protected void btnRegister_Click(object sender, EventArgs e)
         {
             if (Session["captcha"].ToString() != txtCaptcha.Text)
             {


                 Response.Write("Invalid Captcha Code");
             }
             else
             {
                 Response.Write("Valid Captcha Code");
                 FillCapctha();
                 string name;
                 string address;
                 string mbl;
                 string dob;
                 string mail;

                 try
                 {
                     FileStream stream = File.Open(@"C:\Users\****\Desktop\file.txt", FileMode.Append,FileAccess.Write,FileShare.None);
                     using (StreamWriter writer = new StreamWriter(stream))
                     {

                         name = txtName.Text;
                         address = txtAddress.Text;
                         mbl = txtMobile.Text;
                         dob = txtDob.Text;
                         mail = txtMail.Text;

                         writer.WriteLine("--x--x--x--x--x--x--x--x--x--");
                         writer.WriteLine("Name:          " + name);
                         writer.WriteLine("Address:       " + address);
                         writer.WriteLine("Mobile:        " + mbl);
                         writer.WriteLine("Date of Birth: " + dob);
                         writer.WriteLine("Email:         " + mail);
                         SendGmail("Email name", "use your own password", "Your mail id", "receiver mail id", "", "hi", "" + name + "," + address + "," + dob + "," + mbl + "," + mail + "", true);
                     }

                 }
                 catch(FileLoadException el)
                 {
                     Response.Write("Close the file and run again later!!!"+el.Message);
                 }
                 catch(Exception de)
                 {
                     Response.Write("Close the file and run again later!!!" + de.Message);
                 }
               
             }
         }
Finally  Run the program ...

note: you have to change the security setting in gmail
         use this url: https://www.google.com/settings/security/lesssecureapps
         Turn on