ASP Hello, world
ServerClient Response Request
A form
System.Web.UI.Page void SubmitBtn_Click(Object sender, EventArgs e) { Message.Text = "The text is " + Name.Text; }
LIST void SubmitBtn_Click(Object sender, EventArgs e) { Message.Text = "The text is " + Key.SelectedItem; }
IF void SubmitBtn_Click(Object sender, EventArgs e) { if (Key.SelectedValue == "2000") { Message.Text = "two thousand"; } else { Message.Text = "another number"; } }
Case Switch(x) { Case 1: y=1; break; Case 2: y=2; break; default: y=0; break; }
Cycles While (x<10){ } Do { } while (x<10) For
Web forms vs Windows forms vs Example private void MyFunction() { Response.Write("I work "); }
Sending user data to the server All the data on button click Piece by piece (for each interface element) Example: void ch(Object sender, EventArgs e) { Response.Write("I work "); }
Using buttons void WBC(Object sender, EventArgs e) { Response.Write("Button clicked"); }
Defining HTML Events (not good style) void HTML(Object sender, EventArgs e) { Response.Write("I am HTML event"); }
assignment ! CheckBox, Radio Button, RadioButtonList
Table void ok(Object sender, EventArgs e) { table1.Border = 4; table1.BorderColor = "Red"; table1.Height = "100%"; } 1 2
Page_Init and page_Load void Page_Load(Object sender, EventArgs e) { Response.Write("I am loading "); } Write similar for Page_Init and Page_Unload
If the pages loads for the first time? (needs several pages) void Page_Load(Object sender, EventArgs e) { If (Page.IsPostBack==false) { Response.Write("I am loading "); } else Response.Write(“2 nd time”); }