Intro Week 13

esse quam videri
Jump to: navigation, search

View State

ASP.NET controls are statefull. They save their state in a collection called viewstate. This collection is serialized (fancy word for turned into text) and sent with the HTML to the web browser as a hidden form value. When this value is posted to the web server each web control can persist it's value

Demo HTML form and ASPX Web Form

Session

An aspx session is a collection of values that is stored on the server. This allows use to save information on the server that can be retrieved when a client requests make additional requests.

App_Code

App code is a special folder that can hold cs files. Any classes in the CS files are available to all the pages on the ASPX site. You can only have one App_code folder per site and it needs to be in the root of the site. You need to make an app_code folder in the root of your pub folder. Then aspx files in your ITP can access the classes from your app_code folder

demo with dog

Web Forms

Examples of Web Forms

http://iam.colum.edu/oop/classsource/class9/aspForms.aspx aspForms.aspx - Source

http://iam.colum.edu/oop/classsource/class9/htmlForms.htmlhtmlForms.aspx - Source

Persisting Data

POST and GET

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

an asps page posting to itself

GET

Simple get page http://iam.colum.edu/oop/classsource/class9/simpleGet.html source

http://iam.colum.edu/oop/classsource/class9/simpleGet.aspx source

POST

Simple post page http://iam.colum.edu/oop/classsource/class9/simplePost.html source

http://iam.colum.edu/oop/classsource/class9/simplePost.aspx source

Simple post page http://iam.colum.edu/oop/classsource/class9/simplePostValues.html source

http://iam.colum.edu/oop/classsource/class9/simplePostValues.aspx source


ASP POSTBACK

http://iam.colum.edu/oop/classsource/class9/postBack.aspx source

Events in c# and aspx

Event handlers

OnClick

http://iam.colum.edu/oop/classsource/class9/events/events1.aspx events1.aspx - source

OnCommand

http://iam.colum.edu/oop/classsource/class9/events/events2.aspx events2.aspx - source

http://iam.colum.edu/oop/classsource/class9/events/events3.aspx events3.aspx - source

<csharp>

<%@ Page language="c#" debug="True" trace="false"%>

<script language="c#" runat="server">

   Dog fido;
   
   public void Page_Load()
   {
       fido = new Dog();
       
       
   }
   public void Button1_OnClick(Object sender, EventArgs e)
   {
       Response.Write("Hello from Button1_OnClick");
       lblBark.Text = fido.Bark();
   }


   public class Dog 
   {
       public string Name;		// the dog's name
       public int Age;			// the dog's age
       public int Weight;			// the dog's weight
       public string BarkSound;	// the sound of the dog's bark
       public Dog()
       {
           BarkSound = "Woof!!!";
       }
       public string Bark()
       {
           return this.BarkSound;
       }
       public void Eat()
       {
           //put eat code here 
       }
   }	

</script>

Test

test
Hello in div

</csharp>

Home Work

Create a final proposal.

your final project needs to be either a website or a windows form.

It must use at least one class and a have a usable interface. It should solve some type of problem.

Your proposal should include:

  • Rationale
why are you building what you are building and a basic introduction of product features
  • Audience
Description of target audience who will use you software
  • Requirements Summary:
Key Areas and Features elaborate on requirements above
  • Design Documents
UML of your class screen shot or drawing of your UI