Wednesday, 28 December 2016

Data validation using Java script with event handling.

HTML
--------------------------------------------------------------------------------------------------------------------
<html>

<head>
    <title>Registration</title>
    <link rel="stylesheet" href="Custom.css">
</head>

<body>
    <h1 class="heading">Our Financial Status</h1>

    <table class="frm">

        <tr>
            <td>
                   First Name  
            </td>
            <td>
                <input type="text" placeholder="First Name" id="txtFirstName">
            </td>
        </tr>


        <tr>
            <td>
                   Last Name  
            </td>
            <td>
                <input type="text" placeholder="Last Name" id="txtLastName">
            </td>
        </tr>


        <tr>
            <td>
                   Email Id  
            </td>
            <td>
                <input type="text" placeholder="Email" id="txtEmail">
            </td>
        </tr>


        <tr>
            <td>
                    Password  
            </td>
            <td>
                <input type="password" placeholder="Password" id="txtPassword">
            </td>
        </tr>


        <tr>
            <td>
                    Mobile No  
            </td>
            <td>
                <input type="text" placeholder="Mobile" id="txtMobileNo">
            </td>
        </tr>


        <tr>
            <td>
                    Pan Card No  
            </td>
            <td>
                <input type="text" placeholder="PanCard" id="txtPancard">
            </td>
        </tr>


        <tr>
            <td>
                   Aadhar Card No  
            </td>
            <td>
                <input type="text" placeholder="Aadhar Card" id="txtAadharCard">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="Submit" id="btnSubmit"  class="button">
            </td>
        </tr>
    <table>
          <script src="Registraion.js"></script>
</body>

</html>
----------------------------------------------------------------------------------------------------
CSS
------
body {
  font: 14px/20px 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: #404040;
  background: #2d4259;
}
.heading
{
width: 270px;
  line-height: 43px;
  margin: 50px auto 20px;
  font-size: 19px;
  font-weight: 500;
  color: white;
  color: rgba(white, .95);
  text-align: center;
  text-shadow: 0 1px rgba(black, .3);
  background: #d7604b;
  border-radius: 3px;
 }
 .frm{
  margin: 0 auto;
  width: 375px;
  padding: 20px;
  background: #f4f4f4;
  border-radius: 3px;
 }
 .input{
      display: block;
  width: auto;
  height: 50px;
  margin-top: 2px;
  font-weight: 500;
  background: none;
  border: 0;
  border-bottom: 1px solid #d8d8d8;
 }
 .label {
  float: left;
  width: 50%;
  line-height: 32px;
  color: white;
  text-align: center;
   cursor: pointer;
 }
.button {
  display: block;
  width: 100%;
  height: 42px;
  margin-top: 25px;
  font-size: 16px;
  font-weight: bold;
  color: #494d59;
  text-align: center;
  text-shadow: 0 1px rgba(white, .5);
  background: #fcfcfc;
  border: 1px solid;
  border-color: #d8d8d8 #d1d1d1 #c3c3c3;
  border-radius: 2px;
  cursor: pointer;

  }
---------------------------------------------------------------------------------------------------------------
Java Script
----------------------
function dataValidation()
{
    var firstName=document.getElementById("txtFirstName");
    var lastName=document.getElementById("txtLastName");
    var emailID=document.getElementById("txtEmail");
    var passward=document.getElementById("txtPassword")
    var mobileNo=document.getElementById("txtMobileNo");
    var panCard=document.getElementById("txtPanCard");
    var aadharCard=document.getElementById("txtAadharCard");
    var btnSubmit=document.getElementById("btnSubmit");
    btnSubmit.addEventListener("click",UserRegistration);
    firstName.addEventListener("keypress",alphabet);
    lastName.addEventListener("keypress",alphabet);
    emailID.addEventListener("keypress",alphanumeric);
    passward.addEventListener("keypress",alphanumeric);
    mobileNo.addEventListener("keypress",numeric);
    panCard.addEventListener("keypress",alphanumeric);
    aadharCard.addEventListener("keypress",numeric);
}
function UserRegistration()
{
  console.log(this);
}
function alphabet(evnt)
{
 console.log(this);
 console.log(evnt);
 var dataLength = this.value.length;
 console.log(dataLength);
    if((evnt.keyCode>=65 && evnt.keyCode<=90) ||
        (evnt.keyCode>=97 && evnt.keyCode<=122)){

    }
    else{
        alert("only alphabet[a-z or A-Z]");
        evnt.preventDefault();
    }

}
function numeric(evnt)
{
 var dataLength = this.value.length;
if((evnt.keyCode >=48 && evnt.keyCode<=57)&&(this.value.length !=10))
    {

    }        
       else
       {
            alert("only number and not than 10 digits");
      evnt.preventDefault();
         }
        }

function alphanumeric(evnt)
{

if(((evnt.keyCode >=65 && evnt.keyCode <=90) ||
   (evnt.keyCode >=48 && evnt.keyCodeode<=57) 
    &&(thi.value.length !=10)))
 {

   }
   else{
       alert("It allow not capital letter, [0-9 ] and not greather than 10 character");
        evnt.preventDefault();
   }
}

function alphnumericWithspecialcharacters(evnt)
{
        
        if(((
        (evnt.keyCode>=65 && evnt.keyCode<=90) ||
        (evnt.keyCode>=97 && evnt.keyCode<=122)||
        (evnt.keyCode >=48 && evnt.keyCodeode<=57)&&
        (this.value.length<=10 || this.value.length>=20)
       
        )))
        {

        }
        else{
             alert("It allow not [A-Z, a-z,0-9 ] and not <10 || >20 character");
             evnt.preventDefault();
        }
//Note: I want add following Special Characters in this function.
//  Ascii Value
//  45      -
//  46      .
//  64      @
//  95      _
}
dataValidation();  



Please give your comment

Tuesday, 27 December 2016

armstrong number in c

#include<stdio.h>
int main()
{
     int num, sum = 0;
         

    printf("Please enter a number: ");      
    scanf("%d",&num);

     for (int i = num; i > 0;)
            {
                sum += (i % 10) * (i % 10) * (i % 10);
                i = i / 10;

            }
 if ( sum==num)
        printf("%d is an armstrong number.",num);
    else
        printf("%d is not an armstrong number.",num);

    return 0;
}

Check Armstrong Number using C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
                       int num, sum = 0;
            num = Convert.ToInt32(Console.ReadLine());
            for (int i = num; i > 0;)
            {
                sum += (i % 10) * (i % 10) * (i % 10);
                i = i / 10;

            }
            if(sum==num)
                {
                    Console.WriteLine("No is armstrong");
                }
                else
                {
                    Console.WriteLine("No is not armstrong ");
                }
                Console.ReadLine();
            }

            }
}

Thursday, 2 April 2015

Date Time culture

  System.Threading.Thread.CurrentThread.CurrentCulture = Fmt
        System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy"
        DTF.ShortDatePattern = "dd/MM/yyyy"

Auto Serial generate in Grid view

type this line in Item Teplate
                           <%# Container.DataItemIndex + 1 %>

Saturday, 22 March 2014

REGISTRATION FORM POSTING BY AJAX

<title></title>
    <link href="css/table.css" rel="Stylesheet" type="text/css" />
//
    <script type="text/jscript">
        $(document).ready(function () {
            $("#btnRegister").click(function () {
                var Name = $("#txtName").val();
                var Password = $("#txtPassword").val();
                var sex = $("#txtSex").val();
                var Age = $("#txtAge").val();
                var ContactNo = $("txtContactNo").val();
      var country = $("#txtCountry").val();
                var Email = $("#txtEmail").val();
                var pattern = /^[a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)*@[a-z0-9]+(\-[a-z0-9]+)*(\.[a-z0-9]+(\-[a-z0-9]+)*)*\.[a-z]{2,4}$/;
                if (Name == "" || Password == "" || sex == "" || Age == "" || country == "" || Email == "")
                    alert('Pleas fill up all field:');
                else {
                    if (pattern.test(Email)) {

                        $.ajax({
                            type: "Post",
                            url: "Handler.ashx?Name=" + Name + "&Password=" + Password + "&Sex=" + sex + "&Age=" + Age + "&ContactNo=" +ContactNo+ "&Country=" + country + "&Email=" + Email + "",
                            data: "text/plain",
                            success: function (data) {
                                alert(data);
                                $("#txtName").val('');
                                $("#txtPassword").val('');
                                $("#txtSex").val('');
                                $("#txtAge").val('');
                                $("#txtContactNo").val('');
                                $("#txtCountry").val('');
                                $("#txtEmail").val('');
                            }
                        });
                    }
                    else
                        alert('please insert valid email Id:');
                }

            });
        });
    </script>
</head>
<body>
    <form id="form2" runat="server" method="post">
    <asp:ScriptManager ID="scptMgr" runat="server"></asp:ScriptManager>
    <div>
        <table class="tab">
            <tr>
                <td class="col">
                    <span>Name :</span>
                </td>
                <td class="col">
                    <input type="text" id="txtName" />
                </td>
            </tr>
            <tr>
                <td class="col">
                    <span>Password :</span>
                </td>
                <td class="col">
                    <input type="password" id="txtPassword" />
                </td>
            </tr>
            <tr>
                <td class="col">
                    <span>Sex :</span>
                </td>
                <td class="col">
                    <input type="text" id="txtSex" />
                </td>
            </tr>
            <tr>
                <td class="col">
                    <span>Age</span>
                </td>
                <td class="col">
                    <input type="text" id="txtAge" />
                </td>
            </tr>
            <tr>
                <td class="col">
                    <span>ContactNo:</span>
                </td>
                <td class="col">
                    <input type="text" id="txtContactNo" />
                </td>
            </tr>
            <tr>
                <td class="col">
                    <span>Country :</span>
                </td>
                <td class="col">
                    <input type="text" id="txtCountry" />
                </td>
            </tr>
            <tr>
                <td class="col">
                    <span>Email :</span>
                </td>
                <td class="col">
                    <input type="text" id="txtEmail" />
                </td>
            </tr>
            <tr>
                <td class="col">
                </td>
                <td class="col">
                    <input type="button" id="btnRegister" value="Register" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>


Css file:-
body {
}
.tab
    {
        width:400px;
        height:auto;
        background-color:#666;
        color:White;
        font-size:medium;
    }
    .col
    {
        width:200px;
        height:10px;
        background-color:Red;
        /*text-align:center;*/
    }
    .col1
    {
        width:100px;
        height:10px;
        background-color:Aqua;
        font-size:large;
        color:Blue;
    }
    .col2
    {
        width:100px;
        height:10px;
        background-color:#303030;
        border-color:Blue;
    }
 Data connection:-
public class DataConnection
{
    public DataConnection()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public static string constr = @"Data Source=AJIT\AJIT;Initial Catalog=Job;persist Security Info=True;User Id=sa;Password=sap";
}



Handler.ashx
<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public class Handler : IHttpHandler {

    SqlConnection con = new SqlConnection(DataConnection.constr);
    public void ProcessRequest(HttpContext context) {

        string Name = context.Request.QueryString["Name"].ToString();
        string Password = context.Request.QueryString["Password"].ToString();
        string Sex = context.Request.QueryString["Sex"].ToString();
        string Age = context.Request.QueryString["Age"].ToString();
        string ContactNo = context.Request.QueryString["ContactNo"].ToString();
        string Country = context.Request.QueryString["Country"].ToString();
        string Email = context.Request.QueryString["Email"].ToString();

        SqlCommand cmd = new SqlCommand("INSERT INTO Posting Values(@Name,@Password,@Sex,@Age,@ContactNo,@Country,@Email)", con);

        cmd.Parameters.AddWithValue("@Name", Name);
        cmd.Parameters.AddWithValue("@Password", Password);
        cmd.Parameters.AddWithValue("@Sex", Sex);
        cmd.Parameters.AddWithValue("@Age", Age);
        cmd.Parameters.AddWithValue("@ContactNo", ContactNo);
        cmd.Parameters.AddWithValue("@Country", Country);
        cmd.Parameters.AddWithValue("@Email", Email);
        con.Open();
        int i = cmd.ExecuteNonQuery();
        con.Close();
        if (i == 1)
        {

            context.Response.ContentType = "text/plain";
        context.Response.Write("Data is insert successfully");
        }
    }
       

    public bool IsReusable {
        get {
            return false;
        }
    }

}

//Handler:-ASP.NET handles all the HTTP requests coming from the user and generates the appropriate response for it. ASP.NET framework knows how to process different kind of requests based on extension, for example, It can handle request for .aspx, .ascx and .txt files, etc. When it receives any request, it checks the extension to see if it can handle that request and performs some predefined steps to serve that request.

ASP.NET Defination

ASP.NET IS A SERVER SIDE WEB APPLICATION FRAMEWORK DESIGNED FOR DEVELOPMENT TO PRODUCE DYNAMIC WEB SITE. IT DEVELOPED BY MICROSOFT TO ALLOW THE PROGRAMMER TO BUILT DYNAMIC WEB SITE, WEB APPLICATION  AND WEB SERVICES.ASP.NET IS BUILD ON COMMON LANGUAGE RUN-TIME  ALLOW PROGRAMMER TO WRITE ASP.NET CODE BY ANY SUPPORTED LANGUAGE SUCH AS C#,C++,JAVA,RUBY ETC.

Secure and Unsecure configuration in Dynamics CRM 365.

Overview : In Dynamics CRM, when we create a plugin, we sometimes need to pass data to that plugin, instead of writing this data inside the ...