Thursday, April 9, 2009
ViewState, Twins, and Triplets!
This is a great article on ViewState and how it works that I found after a co-worker made a comment about optimizing our project by disabling the ViewState property on some of our project's web page controls.
public string NavigateUrl
{
get
{
string text = (string) ViewState["NavigateUrl"];
if (text != null)
return text;
else
return string.Empty;
}
set
{
ViewState["NavigateUrl"] = value;
}
}
(You can view the decompiled source code for a .NET assembly by using a tool like Reflector.)
So when a page control's properties are accessed, as is the case with a HyperLink's NavigateUrl property, the ViewState is actually what gets checked because it saves a snapshot of each control's persisting data. The ViewState is of type System.Web.UI.StateBag, and it stores name-value pairs for all of the page's controls, and can be accessed syntactically the same way in which a Hashtable would.
The article also highlighted two (detestably adorable) classes, the Pair and Triplet classes!
"The Pair and Triplet are two classes found in the System.Web.UI namespace, and provide a single class to store either two or three objects. The Pair class has properties First and Second to access its two elements, while Triplet has First, Second, and Third as properties."
Although I personally would have named the Pair class as the Twin class instead. Oh well.
public string NavigateUrl
{
get
{
string text = (string) ViewState["NavigateUrl"];
if (text != null)
return text;
else
return string.Empty;
}
set
{
ViewState["NavigateUrl"] = value;
}
}
(You can view the decompiled source code for a .NET assembly by using a tool like Reflector.)
So when a page control's properties are accessed, as is the case with a HyperLink's NavigateUrl property, the ViewState is actually what gets checked because it saves a snapshot of each control's persisting data. The ViewState is of type System.Web.UI.StateBag, and it stores name-value pairs for all of the page's controls, and can be accessed syntactically the same way in which a Hashtable would.
The article also highlighted two (detestably adorable) classes, the Pair and Triplet classes!
"The Pair and Triplet are two classes found in the System.Web.UI namespace, and provide a single class to store either two or three objects. The Pair class has properties First and Second to access its two elements, while Triplet has First, Second, and Third as properties."
Although I personally would have named the Pair class as the Twin class instead. Oh well.
Thursday, April 2, 2009
incomparably simple compare to example because I can never remember
using System;
class Program
{
static void Main()
{
string a = "a"; // 1
string b = "b"; // 2
int c = 0;
// When a is SMALLER than b
c = a.CompareTo(b);
Console.WriteLine(c);
// -1
// When b is BIGGER than a
c = b.CompareTo(a);
Console.WriteLine(c);
// 1
}
}
Wednesday, March 4, 2009
Thursday, January 15, 2009
from Philadelphia to Boston
Bookmarks I might want to keep when I have to fork over my work laptop.
Recipe Ingredient Conversion Chart
GRE Practice Questions
Married To The Sea
passive-aggressive notes
Toothpaste For Dinner
Eva's blog
hiperspace lab
MS SQL Server 2000 Online Tutorials
50 Skills Every Real Geek Should Have
How to catch a mouse without a trap
MAKE: Blog: cake in a mug
15 Characteristics of Awesome People
How to be a Programmer
8 Free Ways to Learn a New Language
BBC Languages
Internet Polyglot
ChinesePod
Ethnologue
the most flattering skirt pattern
Quilt Sizes for Full Bed
Television Without Pity
Poetry Free For All
Douglas Crockford: The JavaScript Programming Language
Recipe Ingredient Conversion Chart
GRE Practice Questions
Married To The Sea
passive-aggressive notes
Toothpaste For Dinner
Eva's blog
hiperspace lab
MS SQL Server 2000 Online Tutorials
50 Skills Every Real Geek Should Have
How to catch a mouse without a trap
MAKE: Blog: cake in a mug
15 Characteristics of Awesome People
How to be a Programmer
8 Free Ways to Learn a New Language
BBC Languages
Internet Polyglot
ChinesePod
Ethnologue
the most flattering skirt pattern
Quilt Sizes for Full Bed
Television Without Pity
Poetry Free For All
Douglas Crockford: The JavaScript Programming Language
Tuesday, December 23, 2008
oh yelp...
"You may or may not end up with someone's tongue down your throat when the clock strikes midnight,..."
Friday, December 19, 2008
Subscribe to:
Posts (Atom)