OOP Class10
Contents
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://iam.colum.edu/oop/classSource/class10/ApplicationCnt.aspx - source
GlobalAsax on c-sharp corner Session - The web server creates a session for each unique visitor
http://digg.com/programming/Web_3_0_Amazing_button_developed_by_Columbia_College_IAM_Department_Head
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 retrieve each browsers session array on each request.
Boxing and unboxing of session variables
All Session variables are of type object. This means that you can put whatever you like into the session array. The trouble starts when you remove and object from the array it will always 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.