0

Using UserControl.RenderControl()

Posted by Tim on June 7, 2011 in ASP.NET, Visual Basic

Perhaps you want to reuse a usercontrol in a email? or you need to generate the html from a usercontrol for a specific purpose? Firstly, here is the code to render the html from a user control to a string builder object:    Dim sb As New StringBuilder()    Using sw As New StringWriter(sb)   [...]

Tags: , ,

 
1

Detect when a session has ended ASP.NET

Posted by Tim on June 30, 2010 in .NET Framework, ASP.NET, Visual Basic

A problem that I have had in the past is trying to find out when a session has expired within ASP.NET and how to deal with the expired session.   One solution is to add the following code into the Page_Init event.   You can add this event into a class that inherits the Page class so [...]

Tags: ,

 
0

Match Whole Words Regular Expressions

Posted by Tim on January 12, 2010 in .NET Framework, Visual Basic

Example: Dim regExp As New Regex(String.Format(“\b{0}\b”, keyword), RegexOptions.IgnoreCase) This is the same as doing the following: note.note_content.StartsWith(InputKeyword & " ") OR _ note.note_content.EndsWith(" " & InputKeyword) OR _ note.note_content.Contains(" " & InputKeyword & " ") References: http://answers.oreilly.com/topic/217-how-to-match-whole-words-with-a-regular-expression/ http://stackoverflow.com/questions/810078/search-for-whole-word-with-linq-to-sql

Tags:

 
0

Unable to cast object of type ‘ Issue

Posted by Tim on December 22, 2009 in .NET Framework, Visual Basic

I came across this error: System.InvalidCastException: Unable to cast object of type ‘<TakeIterator>d__3a`1[Class]‘ to type ‘System.Collections.Generic.List`1[Class]‘. This occured when trying to use the Take extension (list.Take(n)) from a generic list of objects.   The problem is when you use the Take extension, it returns a new sequence ( IEnumerable). I got around this issue by using: [...]

Tags: ,

Copyright © 2008-2012 Codelab Blog All rights reserved.
Desk Mess Mirrored version 1.9.1 theme from BuyNowShop.com.