hour 86.doc

Upload: madhvamadhu

Post on 07-Jul-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/18/2019 Hour 86.doc

    1/3

    IMPART TECHNOLOGIES D. HARSHA

    View State

    • “View State” is a state that keeps the current state of the web page, during

    post back.

    • Post Backing:  The web page gets re-loaded automatically, whenever the

    user performs an event at run time. ere, the page will be submitted to the

    same page itself. This process is called as “!ost "acking”. #or e$ample, if the

    user clicks on a button, the page will be posted back.

    • %t the time of post backing, the web page will be closed and the same web

    page will be re-loaded. &n fact, the te$tbo$ values ' list bo$ selections etc.,

    would not be re-loaded, if “View State” concept is not implemented.

    • "ecause of “View State”, %S!.()T is able to get the web page to the previous

    state, as it is submitted at the time of post back.

    • %s a part of this “View State”, at the time of !ost "acking, %S!.()T

    automatically saves the current values of the controls in a separate string

    temporarily. %fter re-loading the page, the controls values will be re-stored to

    its previous state, based on the values in view state string.

    • &n fact, the “View State” is maintained automatically by %S!.()T, you don*t

    re+uire to implement it.

    Tans!eing In!o"ation #etween Pages$it% &'e( Sting

    •  The +uery string is the , displayed in the browser*s address bar.

    • /hen you want to pass one or more values from one page to another page as

    arguments, you can send them with the “0uery String”, in the following

    format.

    S(n: http1''localhost1portno'/ebSite(ame'/eb!age.asp$2

    parameter3value

    E): http1''localhost1portno'/ebSite(ame'/eb!age.asp$2n3455

    • /hen you want to pass multiple values with the +uery string, use the

    following format1

    S(n:  http1''localhost1portno'/ebSite(ame'/eb!age.asp$2

    parameter43value46 parameter73value7

    .()T 8.9 and Visual Studio 755: our :; - !age 4 of 8

  • 8/18/2019 Hour 86.doc

    2/3

    IMPART TECHNOLOGIES D. HARSHA

    E):  http1''localhost1portno'/ebSite(ame'/eb!age.asp$2

    n434“parameter name”?

    E): e+uest.!arams>“n”?

     The above synta$ gets the value of the given parameter, in string format.

    Li"itations o! Passing Va*'es wit% &'e( Sting:

    • (o security is available, because the argument names and values will be

    displayed in the browser*s title bar.

    •  The values can be sent from one page to another page only. "ut, the values

    can*t be retrieved from other pages, forwarded from the second page.

    •  @ou can share only string values or numerical values among multiple pages.

     @ou can*t share obAects.

    Note: To overcome the above two limitations, “Bookies” concept is introduced.

    .()T 8.9 and Visual Studio 755: our :; - !age 7 of 8

    A++*ication ,-: De"o on &'e( Sting wit%

    Paa"etes

    De!a'*t.as+).cs

      protected void "utton4CBlickDobAect sender, )vent%rgs eE  F  string name 3 Te$t"o$4.Te$tG  esponse.edirectDHdisplay.asp$2arg3H I nameEG  J

    /is+*a(.as+).cs

      protected void !ageCoadDobAect sender, )vent%rgs eE  F  string name 3 e+uest.!arams>HargH?G  abel4.Te$t 3 HBurrent ser1 H I nameG  J

  • 8/18/2019 Hour 86.doc

    3/3

    IMPART TECHNOLOGIES D. HARSHA

    Cookies

    • % cookie can be used to share values among multiple web pages.

    • % cookie will be created as a te$t Kle in the “Temporary &nternet #iles” folder

    on the client system. This folder location depends on the browser type.

    • /hen compared with “0uery String”, the advantage of cookies is, it doesn*t

    display the values in the address bar.

    • %nother advantage of “Bookies” is, cookies alive among multiple web pages,

    not only between one page to another page. That means you can access the

    values stored in the cookies from any other pages, navigated from the current

    page.

    I"+*e"entation:

    A. Assign 0a*'e to t%e Cookie:

    • Ceate cookie o#1ect:

    ttpBookie obA 3 new ttpBookieD“name”, “value”EG

    • Assign t%e cookie o#1ect to Res+onse:

    esponse.Bookies.%ddDobAEG

    B. Get 0a*'e !o" t%e Cookie:

    e+uest.Bookies>“name”?.Value

    .()T 8.9 and Visual Studio 755: our :; - !age 8 of 8

    A++*ication ,-,: De"o on

    Cookies

    De!a'*t.as+).cs

      protected void "utton4CBlickDobAect sender, )vent%rgs eE  F  string name 3 Te$t"o$4.Te$tG  ttpBookie ck 3 new ttpBookieDHusernameH, nameEG  esponse.Bookies.%ddDckEG  esponse.edirectDHdisplay.asp$HEG  J

    /is+*a(.as+).cs

      protected void !ageCoadDobAect sender, )vent%rgs eE  F  string name 3 e+uest.Bookies>HusernameH?.ValueG  abel4.Te$t 3 HBurrent ser1 H I nameG  J