3 Sept 2013

how to create variable in jquery

var name = 'india';
alert(name);

var name = $("#txtname").val();
alert(name);

How to create variable in c#

A variable can be compared to a storage room, and is essential for the programmer. In C#, a variable is declared like this: 

<data type> <name>; 

An example could look like this: 

string name; 

That's the most basic version. Usually, you wish to assign a visibility to the variable, and perhaps assign a value to it at the same time. It can be done like this: 

<visibility> <data type> <name> = <value>; 

And with an example:
private string name = "John Doe";
The visibility part is explained elsewhere in this tutorial, so let's concentrate on the variable part. We will jump straight to an example of actually using a couple of them:
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string firstName = "John";
            string lastName = "Doe";

            Console.WriteLine("Name: " + firstName + " " + lastName);

            Console.WriteLine("Please enter a new first name:");
            firstName = Console.ReadLine();

            Console.WriteLine("New name: " + firstName + " " + lastName);

            Console.ReadLine();
        }
    }
}
Okay, a lot of this has already been explained, so we will jump directly to the interesting part. First of all, we declare a couple of variables of the string type. A string simply contains text, as you can see, since we give them a value straight away. Next, we output a line of text to the console, where we use the two variables. The string is made up by using the + characters to "collect" the different parts. 

Next, we urge the user to enter a new first name, and then we use the ReadLine() method to read the user input from the console and into the firstName variable. Once the user presses the Enter key, the new first name is assigned to the variable, and in the next line we output the name presentation again, to show the change. We have just used our first variable and the single most important feature of a variable: The ability to change its value at runtime. 

What is Variables?

A variable is just a named area of storage that can hold a single value (numeric or character). The C language demands that you declare the name of each variable that you are going to use and its type, or class, before you actually try to do anything with it.
The Programming language C has two main variable types
  • Local Variables
  • Global Variables

Local Variables

  • Local variables scope is confined within the block or function where it is defined. Local variables must always be defined at the top of a block.
  • When a local variable is defined - it is not initalised by the system, you must initalise it yourself.
  • When execution of the block starts the variable is available, and when the block ends the variable 'dies'.
Check following example's output


main()
   {
      int i=4;
      int j=10;
   
      i++;
   
      if (j > 0)
      { 
         /* i defined in 'main' can be seen */
         printf("i is %d\n",i); 
      }
   
      if (j > 0)
      {
         /* 'i' is defined and so local to this block */
         int i=100; 
         printf("i is %d\n",i);      
      }/* 'i' (value 100) dies here */
   
      printf("i is %d\n",i); /* 'i' (value 5) is now visable.*/
   }
   
   This will generate following output
   i is 5
   i is 100
   i is 5

Here ++ is called incremental operator and it increase the value of any integer variable by 1. Thus i++ is equivalent to i = i + 1;
You will see -- operator also which is called decremental operator and it idecrease the value of any integer variable by 1. Thus i-- is equivalent to i = i - 1;

Global Variables

Global variable is defined at the top of the program file and it can be visible and modified by any function that may reference it.
Global variables are initalised automatically by the system when you define them!
Data TypeInitialser
int0
char'\0'
float0
pointerNULL
If same variable name is being used for global and local variable then local variable takes preference in its scope. But it is not a good practice to use global variables and local variables with the same name.


   int i=4;          /* Global definition   */
   
   main()
   {
       i++;          /* Global variable     */
       func();
       printf( "Value of i = %d -- main function\n", i );
   }

   func()
   {
       int i=10;     /* Local definition */
       i++;          /* Local variable    */
       printf( "Value of i = %d -- func() function\n", i );
   }

   This will produce following result
   Value of i = 11 -- func() function
   Value of i = 5 -- main function

i in main function is global and will be incremented to 5. i in func is internal and will be incremented to 11. When control returns to main the internal variable will die and and any reference to i will be to the global.

30 Aug 2013

How to Pan Card Validation in Asp.net.

Hello,

Below script helps to bind the user to enter the value in the textbox which
will validate pan card number in India.

In India Pan card no is 10 digit alpha numeric.
First 5 are alphabets only followed by 4 numeric and at last one alphabet.


To achieve this simply follow the following Steps

Write the below javascript function in the aspx page under head section :


<script type="text/javascript">
function Validation()
{
var txt_pan=document.getElementById('TextBox1').value;

var checkval=/^[A-Z]{5}\d{4}[A-Z]{1}$/;
if(checkval.test(txt_pan)== false)
{
  alert('Please enter valid pan number');
  return false;
}
}
</script>

In the Body Section of the .aspx page just bind the onClientclickevent of the button to the function above in the javascript to check the value of TextBox1
Take one texbox and button control on the page as shown below


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:return Validation();" />

29 Aug 2013

How do I disable/enable a form element?

enable or disable a form element using the .prop() method: // Disable #div1
$( "#div1" ).prop( "disabled", true );
// Enable #div1
$( "#div").prop( "disabled", false );

How to Change colour on mouseover.

Hello.
The code to change colour (textbox,button,cell,tr etc). You can make a class in HTML design form and then call that function on code file.
Step 1:-
First of all make a css class as shown below:



<style type="text/css">

.normalRow
{
background-color:Red;
cursor:pointer;

.highlightRow
{
background-color:white;
cursor:pointer;
}
</style>
Step 2:-
Now call this css in code file like (this is for table row TR):

 tr1.Attributes.Add("onmouseover", "this.className=('highlightRow');");
 tr1.Attributes.Add("onmouseout", "this.className=('normalRow');");

Write a 'C' program to animate a circle?

The program in ‘C’ Programming language to draw a circle on the screen and animate it is as follows:
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>

#define RADIUS 50
#define DELAY 20

void main()
{
            int x=0, y=0, gdriver=DETECT, gmode=4;
            clrscr();
            initgraph(&gdriver, &gmode, "C:\\TC\\BGI");
            while(!kbhit())
            {
                        for(x=0, y=0; x<getmaxy() && !kbhit();)
                        {
                                    circle(x++, y++, RADIUS);
                                    delay(DELAY);
                                    cleardevice();
                        }

                        cleardevice();
            }

            getch();
            closegraph();

}

How to Create WEBSITE DESIGN

Way2finder Technologies is a web design studio that offers corporate web design and custom web design. Our website designers offer cheap w...