50 likes | 196 Views
MIS 3200. Page Counter Session Variables Else If. Time to try it out- L1. The purpose of this L1 will be to create a page counter for your portfolio homepage Place a label on your page and name it “ lblCounter ” Before the label type “Page Counter: “
E N D
MIS 3200 Page Counter Session Variables Else If
Time to try it out- L1 The purpose of this L1 will be to create a page counter for your portfolio homepage • Place a label on your page and name it “lblCounter” • Before the label type “Page Counter: “ Now, switch to your code behind by right-clicking in an empty space on your page and selecting “view code.”
L1 #2 • Below the line: • declare an int variable to hold the page count and set its initial value to 0. • Now we will begin working with a session variable we will call Session[“CountCounter”] • In the Page_Load method, create an if statement to see if Session[“CountCounter”] is null. • If null, set your int variable to 0 • If not, convert your session to an int and place the value in your int variable
L1 #3 • After the if statement: • increase your variable by one • set • Now, using a series of else if statements, place your count in the label • If the count is under ten, include 000 in front of your count • If the count is under 100, include 00 in front of your count • If the count is under 1000, include 0 in front of your count • Add page level comments, create a link to this page from your MIS3200 page and copy everything to ASPNET and submit your MIS Portfolio URL to the drop box.