Sunday, June 16, 2013

// // Leave a Comment

indexof in javascript contains example

Read More
// // Leave a Comment

show or hide div in jquery with example

 How to Show or Hide div's using jQuery

Show DIV in jquery


   jQuery('div').show();      --- Displays all the div's

   jQuery('#thisdiv').show();    ---- Displays a div having the id as thisdiv

   jQuery('#thisdiv div').show(); ---- Displays all the div's inside the div having the id thisdiv


Hide DIV in jquery


   jQuery('div').hide();      --- Hides all the div's

   jQuery('#thisdiv').hide();    ---- Hides a div having the id as thisdiv

   jQuery('#thisdiv div').hide(); ---- Hides all the div's inside the div having the id thisdiv



div outside thisdiv
thisdiv
div inside thisdiv

           
Read More

Monday, June 3, 2013

// // Leave a Comment

Get or Set Http Cookies in server side of C# on Asp.Net Website

Set and Get Cookies


get cookie in code behind of asp.net website


 Get Cookie 

Sample Code
      HttpCookie myCookie = new HttpCookie("sampleCookie");
      SampleCookie= Request.Cookies["sampleCookie"];

      // Read the cookie information and display it.
      if (SampleCookie!= null){
          string value= SampleCookie.Value;
          string name= SampleCookie.Name;

Explanation

1.Create an object for the HttpCookie Class

      HttpCookie myCookie = new HttpCookie("sampleCookie");

2. Get the Cookie from Request.Cookies Collection

      SampleCookie= Request.Cookies["view"];

3.Check whether the cookie object is null
      if (SampleCookie!= null)
4. Get the Cookie Value and Cookie Name
          string value= SampleCookie.Value;
          string name= SampleCookie.Name;


Set Cookie


Sample Code

HttpCookie SampleCookie= new HttpCookie("SampleCookie");
SampleCookie.Value="SampleName";
SampleCookie.Name="SampleValue";
myCookie.Domain="sampleDomain.com"
SampleCookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(SampleCookie);


Read More

Saturday, June 1, 2013

// // Leave a Comment

static vs instance members in C Sharp

Static Versus Instance Members in C#


  • By default, members are per instance
  • Each instance gets its own fields
  • Methods apply to a specific instance
  • Static members are per type
  • Static methods can’t access instance data
  • No this variable in static methods


  Static methods

     public class Area
  {
    private int side;

    public Rectangle(int side)
    {
        this.side= side;
    }

    public void Area()
    {
        Console.WriteLine("Area output: " + Area.CalculateArea(this.side));
    }

    public static int CalculateArea(int side)
    {
        return side* side;
     }
  }

Sample


Static menbers versus insatance members in C#
Read More