
July 21, 2009
“At Rocking R Ranch, Horses and Boarding are our specialty and priority. We offer a safe, quite and convenient facility that is family oriented, with a friendly atmosphere. If you are looking for a peaceful and quiet setting to enjoy your horse and get away from the hustle and bustle of everyday life Rocking R Ranch is the place you’re looking for.”
Check it out: http://www.rockingrranch.ca

July 3, 2009
I’ve created a climbing blog to keep track of what I’m up to in the rock climbing world. I basically need something for myself to remember what I have done and when, so this is it. Take a look, follow if you wish.
You can find it here: http://climbing.danbeland.com/

November 7, 2008
The topics listed below were deemed “important to know” for the Comp241 Midterm scheduled for Nov 13, 2008 by Rob Thorndyke.
Session Management
Client-side
- scalable – each client is storing its own state, you can have 1 or 1,000,000 clients and it’s all the same to the server
- distribute load to more servers
- easier to have persistent data
|
Server-side
- secure
- lower bandwidth requirements – state doesnt go back and forth with each request.
- sharing data between clients (careful though, session data is generally locked to one client)
|
Those are the advantages/disadvantages. How do you actually implement these?
Client
- Cookies
- persistent
- can be turned off / modified
- Query String (BAD, try not ever to use these if you want your site to rank in google)
- can’t be turned off
- user sees it, and curious people will change them
- search engines can’t deal with them very well
- browsers can limit the max length
- setting values is not supported in .NET
- GET only! does not work with POST
- View State (implemented using hidden fields)
- nice support in .NET
- supports POST
- with ViewState, watch the bandwidth – everything gets sent back and forth
- Hidden Fields
For all of the above, data must be key/value pairs and must also be serializable.
Server
- Sessions
- unique to each client “connection”
- time out after a while
- may depend on Cookies (the session id is generally stored in a cookie, this can be turned off but then the session id goes in the query string)
- Application
- global – share data between clients
- web servers can reset these at seemingly random moments
Data Management
Connected Objects
- DBCommand – SQL Statement
- DBConnection – interface to the DB
- DBDataReader
- read-only
- forward-only
- safer
- faster (lightweight)
- DBDataAdapter – read/write and bidirectional
Disconnected Objects
- DataSet
- DataTable
- DataTable.Select() – returns DataRow[] (array of DataRow’s)
- DataRow
- Field access (read overwrite)
- Acts as dictionary
int status = (int) ds.Tables["table"].Select("row = 7")[0]["status"];
Data-Bound Controls
- Control.Databind() – Refreshes the view with current DataSource
Input Validation
General Info
- gives you a chance to check user input and make sure it is valid
- generally you need to do the validation on BOTH the server and the client
- server
- needed in case client validation is bypassed
- has access to DB -> more complex validation
- client
- convenient – quick validation without PostBack
Validation Controls
- RequiredFieldValidator
- non-empty / not “default”
- CompareValidator
- compare two values (==, <=, >=, …etc)
- RangeValidator
- MinimumValue
- MaximumValue
- it checks for value between (inclusive)
- RegularExpressionValidator
- CustomValidator
- ClientFunctionName (javascript function)
- ServerValidate event handler
C# Properties
private int age;
public int Age {
get { return age; }
set { age = value; }
}

November 6, 2008
The following notes were taken during a lecture in COMP 241 .NET Web Applications at Camosun College by Rob Thorndyke. These notes are here mainly to help me study, but if you can find some guidance through them then all the better!
Remember Managing State?
Client-side state
- Hidden Fields
- String Queries
- View State
- Cookies
Server-side state
- Sessions
- Application (This is what we will be using for this step)
- Global dictionary for the entire application
- This is where we will attach our DataSet
DataSet ds = new DataSet();
// do stuff with the DataSet
Application["ds"] = ds; // To set it.
ds = (DataSet) Application["ds"]; // To retrieve it.
Lab Hints
Game Database Tables
games
game_id, name, status
board
game_id, row, col0, col1, col2, col3, col4, col5, col6
Creating and Joining Connect4 Games
- After you create a game:
- new game entries added to the tables
- new Guid “game_id”
- set status to JOINABLE
- add “blank.png” rows to the board table
- set my colour to “red”
- “red” always goes first on new game
- wait for someone to join the game
- Once you join an existing game:
- set my colour to blue
- hide new game controls
- set game status to RED_NEXT
“This is where it gets exciting because you can actually
beat your friends into submission!”
~ Rob Thorndyke
private int STATUS_RED_NEXT = 1;
private int STATUS_BLUE_NEXT = 2;
//...
private int getStatus() {
string filter = String.Format("game_id = Convert('{0}, System.Guid)", Session["game_id"]);
DataTable gamesTable = ds.Tables["games"];
return (int) gamesTable.Select(filter)[0]["status"];
}
private string getCellValue(int row, int col) {
string filter = String.Format("game_id = Convert('{0}', System.Guid)", Session["game_id"]);
DataTable board = ds.Tables["board"];
return (string) board.Select(filter + " and row = " + row)[0]["col" + col];
}
To Create a new game:
- use Guid.CreateNew() to make a new unique id
- add row to “games” table -> status = STATUS_JOINABLE;
- add 6 rows to “board” table -> row 0…5; colx = “blank.png”;
- hide the New Game controls
- set all ImageButtons to “blank.png”
- set “game_id” & “my_colour” Session vars
To Join a game:
- verify status is STATUS_JOINABLE
- set status to STATUS_RED_NEXT
- hide New Game controls
- set “game_id” & “my_colour” Session vars
- set all ImageButtons to “blank.png”
To “Refresh”:
- if client is in a game
- check status for my turn and if so
- set info label
- update ImageButtons to see where other guy moved
- check for game end and if so
- show New Game controls
- set info label
- if NOT in game
- repopulate Joinable Games List