This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Friday, November 23, 2012

ASP.NET PAGE LIFE CYCLE


ASP.NET Page Life Cycle

        

A Page in an ASP.NET application consists of server controls. There  are the fundamentals building blocks of an ASP.NET application. The life cycle of an ASP.NET page, depends on whether the page is requested for the first time or it is postback. Postback is a process by which a page can request for itself.

When The Page Is Requested For The First Time 

The life cycle of a page when requested for the first time:
  • Initializing : 
                                   During this phase, the server creates an instance of the server control.
  • Loading : 
             During this phase, the instance of the control is loaded onto the page object in which it is   defined.

  • PreRendering : 
                           During this phase, the control is loaded with the changes made to it. This prepares the controls for rendering.

  • Saving : 

                          During this phase, the  state information of the control is saved. For example, if a value is set for the control during  the Load event, it is embedded in the HTML tag that will be returned to the browser.

  • Rendering : 

                           During this phase, the server creates the corresponding HTML tag for the control.

  • Disposing :

                           During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.

  • Unloading : 

                              During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is final event in the life cycle of server controls.

Life Cycle When The Page Processed During A Postback Event

The processing sequence in which a page is processed during a postback event is:

  • Initializing : 

                                   During this phase, the server creates an instance of the server control.

    • Loading View State: 

                                     During this phase, the view state of the control posted by the client is reloaded into the new instance of the control.

    • Loading : 

                             During this phase, the instance of the control is loaded onto the page object in which it is defined.

    • Loading The Postback Data: 

                                                        During this phase, the server searches any data corresponding to the control that is loaded in the posted by the client.

    • PreRendering: 

                                           During this phase, the control is updated with the changes made to it. This prepares the controls for rendring.
    •  Saving State :
                                        During this phase, the change in the state of control between the current request and the previous request of the page is saved. For each change, the corresponding event is raised. For example, if the text of a texbox is changed, the new text is saved and a text_change event is raised.
    • Rendering : 
                               During this phase, the server creates the corresponding HTML tag for the control.
    • Disposing :
                               During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.
    • Unloading : 
                                During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is final event in the life cycle of server controls.

    The Events Associated With The Relevant Page Cycle Phases Are :

                           Page Initialization  :  Page_Init
                           View State Loading  :  LoadViewState.
                           Postback data processing  :  LoadPostData
                           Page Loading  :  Page_Load
                           PostBack Change Notification  :  Raise PostDataChangedEvent
                           PostBack Event Handing  :  RaisePostBackEvent
                           Page Pre Rendring Phase  :  Page_PreRender
                           View State Saving  :  SaveViewState
                           Page Rendring :  Page_Render
                                  Page Unloading  :  Page_UnLoad



    Key Features of C-Sharp(C#)


    Key Features of C-Sharp(C#)

    • Simple :
                    It simplifies C++ by eliminating irk some operator such as ->, : : and pointers. 
    • Consistent : 
                       It support an unified type system which eliminates the problem of varying ranges of integer types. All types are treated as object and developers can extend the type system simply and easily.
    • Modern :
                          It supports, Automatic garbage collection, modern approach to debugging, rich intrinsic model for error handling, decimal data type for financial application and robust security model.
    • Object-Oriented:
                             It support all the three tenets of object-oriented system, namely Encapsulation, Inheritance and Polymorphism.
    • Type-Safe :
                            Type safety promotes robust programs, C# incorporates a number of type-safe measures :-
                                    All dynamically allocated object and arrays are initialized to zero.
                                    Use of any uninitialized variables produces an error message by the compilers
                                    Access to array are range checked and warned if it  goes out-of-bounds.
                                    C# does not permit unsafe casts.
                                    C# enforces overflow checking in arithmetic’s operation.
                                    Reference parameters that are passed are type-safe.
                                    C# supports automatic garbage collection.
    • Versionable:
                                   Making new versions of software modules work with the existing  applications is known as versioning with the help of new and override keywords, With this support, a programmer can guarantee that his new class library will maintain binary compatibility with the existing client application.
    • Compatible :
                               C# enforces the .NET common language specification and therefore allows interoperation with other .NET language.
    • Flexible :
                         Although C# does not support pointers we may declare certain classes and methods as ‘unsafe’ and then use pointers to manipulates them. These codes are not be type-safe.
    • Inter-Operability :
                                   C# provides support for using COM objects, no matter what language was used to author them. C# also supports a special features that enables a program to call out any native API.



    CLR Architecture

    CLR Architecture

             





    The source code that is written is compiled to an intermediate code called the byte code(in java) or the Common Intermediate Language(in .Net). Either the Java Virtual Machine or the Common Language Runtime (CLR) is used to compile the code to the intermediate form.

    While executing the program, i.e., the intermediate code, the Just-In-Time(JIT) compiler comes into the picture. The job of the JIT compiler is to convert intermediate code in to the machine code or the native code for execution. With the JIT the code can be optimized to a  particular operating system. This is one of the advantages of going for such code execution.

    The advantage of converting the source code to the intermediate code is that it can un or any operating system provided that the JIT for that operating system is present. This gives the portability of the code.
    In .Net the CLR which also has the JIT is used to convert the CIL code into the native code to be processed by the machine. It is also possible to convert the source code to the native code directly by bypassing the tasks done by the JIT. This helps to reduce the load in the JIT.

    Responsibility of CLR

    It is responsible for loading and running C# programs. The CLR provides a number of services :-

    Thanks :-Sumith

    Thursday, November 22, 2012

    C PROGRAM FOR REPLACING STRING


    /* C PROGRAM FOR  REPLACING STRING*/

    #include<stdio.h>
    #include<conio.h>
    #include<string.h>

     void main()
     {
              int slen,sublen,newlen,reslen,m,k,i,j,temp;
              char str[40],substr[20],newstr[20],resstr[25];
              clrscr();
              printf("\n\t\t STRING REPLACING");
              printf("\n\t\t ~~~~~~~~~~~~~~~~~");
              printf("\n Enter any string:");
              gets(str);
              slen=strlen(str);
              printf("\n Enter the substring:");
              gets(substr);
              sublen=strlen(substr);
              printf("\n Enter the replacement string:");
              gets(resstr);
              reslen=strlen(resstr);
              j=0;
              k=0;
    for(i=0;i<slen;i++)
    {
             newstr[k]=str[i];
             k++;
             if(str[i]==substr[j])
             j++;
    else
             j=0;
    if(j==sublen)
    {
             k=k-sublen;
             j=0;
    for(m=0;m<reslen;m++)
    {
             newstr[k]=resstr[m];
             k++;
         }
       }
    }
          newstr[k]='\0';
          printf("\n The replaced string is %s",newstr);
          getch();
    }


    OUTPUT:

                     STRING REPLACING
                     ~~~~~~~~~~~~~~~~~
     Enter any string: RAJ

     Enter the substring: R

     Enter the replacement string: T

     The replaced string is: TAJ





    C PROGRAM FOR SALES REPORT


    /*  C PROGRAM FOR  SALES REPORT */


    #include<stdio.h>
    #include<conio.h>
    #include<string.h>

    void main()
    {
         int sal[5][5],s,p,i,j,row,col,temp,per,avg;
         char s_men[10][30],pr[10][30],waste[33];
         clrscr();
         printf("\n\t\t SALES REPORT");
         printf("\n\t\t -------------");
         printf("Enter how many salesman:");
         scanf("%d",&s);
         printf("Enter how many products:");
         scanf("%d",&p);
         clrscr();
         gets(waste);
    for(i=1;i<=s;i++)
    {
         printf("\n Enter the %d name of salesman:",i);
         gets(s_men[i]);
     }
    for(j=1;j<=p;j++)
    {
         printf("\n Enter the %d name of products:",j);
         gets(pr[j]);
    }
    for(i=1;i<=s;i++)
    for(j=1;j<=p;j++)
         sal[i][j]=0;
         clrscr();
         printf("\n\t The salesman and products data:");
    while(1)
    {
         clrscr();
    for(i=1;i<=s;i++)
         printf("\n%d salesman :%s",i,s_men[i]);
    for(i=1;i<=p;i++)
    {
          gotoxy(35,i+1);
          printf("%d Products:%s",i,pr[i]);
    }
        


         gotoxy(5,10);
         printf("\n\n Enter which salesman connected with which products");
         printf("\n Enter the salesman no");
         scanf("%d",&row);
         printf("\n Enter the product no:");
         scanf("%d",&col);
         printf("\n Enter the sales rupees:");
         scanf("%d",&per);
         sal[row][col]=per;
         printf("\n\n Do you want to continue (1 for yes,2 for no):\n");
         scanf("%d",&temp);
         if(temp==1)
         continue;
         else
         break;
      }
      clrscr();
      printf("\n\n The salesman and products report:\n\n");
      gotoxy(8,5);
    for(i=1;i<=p;i++)
       printf("\t Products %d",i);
       printf("\n");
    for(i=1;i<=s;i++)
    {
        printf("Salesman %d",i);
    for(j=1;j<=p;j++)
        printf("\t%2d\t",sal[i][j]);
        printf("\n\n");
     }
        printf("\n\t Total details:");
    for(i=1;i<=s;i++)
    {
        avg=0;
    for(j=1;j<=p;j++)
        avg=avg+sal[i][j];
        printf("\n The total rupees sold by salesman %d is %d",i,avg);
       }
     getch();
    }







    OUTPUT:
    SALES REPORT
    Enter how many salesmen:

    Enter how many salesmen: 2
    Enter how many products: 2

     Enter the 1 name of salesman: Raj
     Enter the 2 name of salesman: krk

     Enter the 1 name of products: bat
     Enter the 2 name of products: ball

    1 salesman: raj                  1 Products: bat
    2 salesmen: krk                  2 Products: ball

     Enter which salesman connected with which products:
    Enter the salesman no: 1

    Enter the product no: 1

    Enter the sales rupees: 1000

    Do you want to continue (1 for yes, 2 for no): 1

     Enter which salesman connected with which products
     Enter the salesman no: 2

     Enter the product no: 2

     Enter the sales rupees: 500

    Do you want to continue (1 for yes, 2 for no): 2

     The salesman and products report:

                        Products 1           Product 2
    Salesman 1      1000                     0

    Salesman 2         0                       500


           

     Total details:

     The total rupees sold by salesman 1 is 1000

     The total rupees sold by salesman 2 is 500


    C PROGRAM FOR BOOK SEARCHING AND SORTING



    /* C PROGRAM FOR BOOK SEARCHING AND SORTING*/


    #include<stdio.h>
    #include<conio.h>
    #include<string.h>
    void newentry();
    void sort();
    void search();
    void list();
    struct books
    {
        char authname[50];
        char title[50];
    }b[10];
    int c=1;
    void main()
    {
    int k,i,ch,n;
    char w[30];
    clrscr();
    printf("\n\t\t\tBOOK OPERATION\n");
    printf("\n\t\t\t--------------\n");
    printf("\nEnter how many book you want to enter:");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    newentry();

    while(1)
    {
     clrscr();
     printf("\nMain Menu");
     printf("\n1.Newentry\n");
           printf("\n2.Search");
           printf("\n3.Sort");
           printf("\n4.List");
           printf("\n5.Exit\n");
           printf("\nEnter your choice:");
           scanf("%d",&ch);
    switch(ch)
    {
     case 1:
                       newentry();
                             break;
           case 2:
                       search();
                       break;
           case 3:
                       sort();
                       break;
           case 4:
                       list();
                       break;
           case 5:
                       exit();
                break;
    }
    }
    }


    void search()
    {
    char tit[44],w[22],d,authname[44];
    int i,a=0,z;
    clrscr();
    gets(w);
    printf("\nDo you want to search using author name(Y/N)!");
    scanf("%c",&d);

    if(d=='y'||d=='n')
    {
    gets(w);
    printf("\nEnter any author name you want to search:");
    gets(authname);

    for(i=0;i<=c;i++)
    {
    z=strcmp(authname,b[i].authname);
    if(z==0)
    {
    printf("\n\nThe book have been found");
    printf("\n\nThe book title is %s", b[i].title);
    printf("\n\nThe book author name is : %s",b[i].authname);
    a=1;
    }
    }
    if(a==0)
    printf("\n\nThe book was not found:");
    }
    getch();
    }


    void sort()
    {
    char temp[50],t_tit[44][44];
    int i,j,z;
    clrscr();
    printf("\nThe Sorted book are");
    for(i=0;i<=c;i++)
    strcpy(t_tit[i],b[i].title);
    for(i=0;i<=c;i++)
    {
    for(j=0;j<=c;j++)
    {
    z=strcmp(t_tit[i],t_tit[j]);





    if(z>0)
    {
    strcpy(temp,t_tit[i]);
    strcpy(t_tit[i],t_tit[j]);
    strcpy(t_tit[j],temp);
    }
    }
    }
    for(i=0;i<=c;i++)
    printf("%s\n",t_tit[i]);
    getch();
    }


    void newentry()
    {
    char titles[20],author[50],was[22];
    clrscr();
    gets(was);
    c++;
    printf("Enter any author:");
    gets(b[c].authname);
    printf("Enter any title:");
    gets(b[c].title);
    printf("%s",b[c].title);
    printf("\n%s",b[c].authname);
    printf("\n%s",b[c].authname);
    getch();
    }


    void list()
    {
    int i;
    clrscr();
    printf("AUTHOR NAME  \t\tTITLES");
    for(i=0;i<=c;i++)
    printf("\n\n%s\t\t%s",b[i].authname,b[i].title);
    getch();
    }






















    OUTPUT


    BOOK OPERATION

                                                   
    Enter how many book you want to enter: 2

    Enter any author: R.Balaguruswamy

    Enter any title: Programming in C

    Programming in C
    R.Balaguruswamy

    Enter any author: Morris Mano

    Enter any title: Computer System Architecture

    Computer System Architecture
    Morris Mano

    Main Menu

    1. New entry
    2. Search
    3. Sort
    4. List
    5. Exit

    Enter your choice: 1

    Enter any author: Problem Solving Techniques

    Enter any title:  R.G.Dromey


    Problem Solving Techniques
    R.G.Dromey


    Main Menu

    1. New entry
    2. Search
    3. Sort
    4. List
    5. Exit

    Enter your choice: 2

    Do you want to search using author name(Y/N)!  Y

    Enter any author name you want to search: R.Balaguruswamy

    The book have been found

    The book title is Programming in C

    The book author name is: R.Balaguruswamy

    Main Menu

    1. New entry
    2. Search
    3. Sort
    4. List
    5. Exit

    Enter your choice: 2

    Do you want to search using author name(Y/N)!  Y

    Enter any author name you want to search: Richard hall

    The book was not found

    Main Menu

    1. New entry
    2. Search
    3. Sort
    4. List
    5. Exit




    Enter your choice: 3

    The Sorted books are

    Programming in C
    Problem Solving Techniques
    Computer System Architecture



    Main Menu

    1. New entry
    2. Search
    3. Sort
    4. List
    5. Exit

    Enter your choice: 4


    AUTHOR NAME                              TITLES
    ----------------------                              ----------

    R.Balaguruswamy                      Programming in C

    Morris Mano                              Computer System Architecture

    R.G.Dromey                               Problem Solving Techniques

    Main Menu

    1. New entry
    2. Search
    3. Sort
    4. List
    5. Exit

    Enter your choice: 5




    C PROGRAM FOR BANK OPERATION USING FUNCTIONS


    /* C PROGRAM FOR  BANK OPERATION USING FUNCTIONS*/


    #include<stdio.h>
    #include<conio.h>
    int amt=10000,b,w,d,n;
    void deposit()
    {
         printf("Enter amount\n");
         scanf("%d",&d);
         amt=amt+d;
         printf("Your amount is:%d\n",amt);
     }

    void withdraw()
    {
         printf("Enter amount\n");
         scanf("%d",&w);
         if(amt>=100)
         {
          amt=amt-w;
          printf("Your amt is:%d\n",amt);
         }
         else
         printf("You have below 100 Rs\n");
    }

    void balance()
    {
          printf("The balance amount is :%d\n",amt);
     }
















    void main()
    {
          int ba;
          clrscr();
          printf("\t\t BANKING OPERATION USING FUNCTION \n\n");
          printf("1.Deposit\n2.Withdraw\n3.Balance\n4.Exit\n");
         do
        {

           printf("\n Enter any choice:");
            scanf("%d",&ba);
            switch(ba)
            {
              case 1:
                        deposit();
                        break;
              case 2:
                        withdraw();
                         break;
              case 3:
                        balance();
                        break;
              case 4:
                            getch();
                            break;
           }
        }while(ba!=4);
         getch();
    }
















    OUTPUT:


                     BANKING OPERATION USING FUNCTION


    1. Deposit
    2. Withdraw
    3. Balance
    4. Exit

     Enter any choice: 1
    Enter amount:
    1200
    Your amount is: 11200

     Enter any choice: 2
    Enter amount:
    11200
    Your amt is: 0

     Enter any choice: 2
    Enter amount:
    1000
    You have below 100 rs

     Enter any choice: 1
    Enter amount:
    15000
    Your amount is: 15000

     Enter any choice: 3
    The balance amount is: 15000

     Enter any choice: 4





    C PROGRAM FOR STUDENTS MARKSHEET USING STRUCTURES


    /*  C PROGRAM FOR STUDENTS MARKSHEET USING STRUCTURES */

    #include<stdio.h>
    #include<conio.h>

    struct stu
    {
          int rn,grade,a[5];
          float avg;
      }s[2];

    void main()
    {
          int i,j,sum,n;
          float avg;
          clrscr();
          printf("\t STUDENT MARKSHEET USING STRUCTURES\n\n");
          printf("Enter the no of students");
          scanf("%d",&n);

    for(i=0;i<n;i++)
    {
          scanf("%d",s[i].rn);

    for(j=0;j<=5;j++)
    {
          scanf("%d",&s[i].a[j]);
       }
     }

    for(i=0;i<n;i++)
    {
           sum=0;

    for(j=0;j<5;j++)
    {
            sum=sum+s[i].a[j];
            s[i].avg=(float)(sum/5);
            if(s[i].avg>=60)
            s[i].grade=1;
            else if(s[i].avg>50&&s[i].avg<60)
            s[i].grade=2;
    else
           s[i].grade=3;
      }
    }

           printf("****************************************\n");
           printf("rn\ts1\ts2\ts3\ts4\ts5\tavg\t grade\n");
           printf("*****************************************\n");

    for(i=0;i<n;i++)
    {
           printf("%d\t",s[i].rn);

    for(j=0;j<5;j++)
    {
           printf("%d\t",s[i].a[j]);
        }
          printf("%f\t%d\n",s[i].avg,s[i].grade);
      }
      getch();
    }































    OUTPUT:
    STUDENTS MARKSHEET USING STRUCTURES
     
    Enter the no of students: 5
    1
    89        90        90        99        82

    2
    67        73        77        60        88

    3
    56        54        59        76        66

    4
    45        44        56        34        65

    5
    56        76        90        85        64

    *********************************************************
    Rn       s1        s2         s3         s4         s5         avg                  grade
    *********************************************************
    1          89        90        90        99        82        90.000000           1
    2          67        73        77        60        88        71.000000           1
    3          56        54        53        76        66        62.000000           1
    4          45        44        56        34        65        48.000000           3
    5          56        76        90        35        64        74.000000           1