OOP Class10

esse quam videri
Revision as of 16:54, 19 April 2006 by Jeff (talk | contribs)
Jump to: navigation, search

Response Object

Response.Write()

http://iam.colum.edu/oop/classsource/class10/Response/Response1.aspx Response1.aspx - source

Response.End()

http://iam.colum.edu/oop/classsource/class10/Response/Response2.aspx Response2.aspx - source

Response.Clear()

http://iam.colum.edu/oop/classsource/class10/Response/ResponseClear.aspx ResponseClear.aspx - source

Response.Flush()

http://iam.colum.edu/oop/classsource/class10/Response/ResponseFlush.aspx ResponseFlush.aspx - source


Debugging with response object

Using the response buffer can be extreemely usefull for debugging. Sometime you may have to setup a small debug system to help catch errors in object that do not inherit from System.UI.Page.

Response.Flush()

http://iam.colum.edu/oop/classsource/class10/Response/ResponseDebug.aspx ResponseDebug.aspx - source

Application State

Application - application level variables have application scope meaning they are avialible to the entire application.

example

http://iam.colum.edu/oop/classsource/class10/application/ApplicationSet.aspx ApplicationSet.aspx - source

http://iam.colum.edu/oop/classsource/class10/application/ApplicationSetUpdateFixed.aspx ApplicationSetUpdateFixed.aspx - source

file global.asax global.asax-source

http://imdev/infod/jeff/classSource/class6/ApplicationCnt.aspx - source

GlobalAsax on c-sharp corner Session - The web server creates a session for each unique visitor

Session State

Session is an array of objects that is help on the server for each unique user. Each time a browser requests an aspx page the sever sends back a unique id as a cookie called SESSIONID. This cookie is used to retrive each browsers session array on each request.

Boxing and unboxing of session varibales

All Session variables are of type object. This means that you can put whatevr you like into the session array. The trouble starts when you remove and object from the array it will alwayr be removed and be of type object. You then need to cast the object into its actual data type. This is known as boxing and unboxing.

<csharp>Session["Counter"] = 1; //set the session variable Counter equal to the integer 1 the int is boxed as an object

int i = (int)Session["Counter"] //cast the object Session["Counter"] bact to an int unboxing</csharp>

exmaple with boxing and unboxing of ints

http://iam.colum.edu/oop/classsource/class10/SessionCnt.aspx SessionCnt.aspx - source

Dog examples

The first page creates a dog objects and stores it as a session variable.

http://iam.colum.edu/oop/classsource/class10/dogsession/dog.aspx dog.aspx - source

http://iam.colum.edu/oop/classsource/class10/dogsession/dog_session_Page1.aspx dog_session_Page1.aspx - source

http://iam.colum.edu/oop/classsource/class10/dogsession/dog_session_Page2.aspx dog_session_Page2.aspx - source

http://iam.colum.edu/oop/classsource/class10/dogsession/dog_session_Page3.aspx dog_session_Page3.aspx - source

View State

ViewState is an instance of statebag todo demostate viewstate

look at guessing game

http://iam.colum.edu/oop/browser/browser.aspx?f=/classsource/class10/assign3

More Event Samples

A nice exmaple of a web page that uses exents to create and use our dog class. Notice hot the events and the dog class are only loosely coupled (the doesn't directly use the dog class).

http://iam.colum.edu/oop/classsource/class10/events/DogDelegateEvent.aspx DogDelegateEvent.aspx - source

http://iam.colum.edu/oop/browser/browser.aspx?f=/classsource/class10/events

Home Work

Make a web interface for your old console guessing game. Bonus points for using object and decoupling the interface form the logic.