C# – IsNumeric
Use the TryParse method to determine if a value is numeric int retNum; if (Int32.TryParse(BookId, System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out...
View ArticleSort Collection
Here is a simple solution based on this article to implement a sort of a generic collection. public ContentCollection Sort() { List items = (List)Items; items.Sort(); return this; } The Content class...
View ArticleSessionId – keeping it the same
If you don’t populate a value in the session of a page then the session Id will reset everytime the page is loaded. protected void Page_PreInit(object sender, EventArgs e) { //Need this line otherwise...
View ArticleServer Control Remove Span
Normally when you write a server control, .Net automatically wraps the output with a span and the Id of the control. Depending on your CSS this can cause rendering issues. You can use the following...
View ArticleCreating Event Handler Signatures
In Visual Studio 2008 you’ve lost the abillity to click on the drop down in the code behind and see all the event signatures that are available but haven’t handled yet. To get the signature you are...
View ArticleIterate a Dictionary
Following code iterates through each entry in a dictory For Each keyPair As KeyValuePair(Of String, Int32) In aDepot.PostcodeCounters builder.Append("<tr><td>") builder.Append(keyPair.Key)...
View Article?? Operator (C# Reference)
This operator allows you to supply an alternative value if the value being supplied is null. It only works on nullable datatypes but with a bit of googling came accross this article. public int...
View ArticleSpecify file name for file from handler
When returning content to a user from a generic handler use the the AddHeader method to specify the filename context.Response.ContentType = "text/comma-separated-values";...
View ArticleXSL/T Transform from String to String
The following example transforms the supplied xml string, using XSL/T and outputs to another string using (StringReader rdr = new StringReader(selectedLine.AdditionalInformation)) { XPathDocument doc =...
View ArticleVS2005 ASP.Net not stopping on breakpoints
If you have IE 8 installed and your ASP.Net project won’t stop on the breakpoints you’ve set they you probably need to read this article You basically need to add an entry to your registry to stop...
View Article