<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sam Beauvois &#187; Development</title>
	<atom:link href="http://www.sambeauvois.be/blog/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sambeauvois.be/blog</link>
	<description>general dev, .net and other stuff</description>
	<lastBuildDate>Fri, 03 Sep 2010 14:11:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A few online books</title>
		<link>http://www.sambeauvois.be/blog/2010/09/a-few-online-books/</link>
		<comments>http://www.sambeauvois.be/blog/2010/09/a-few-online-books/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 06:09:33 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=554</guid>
		<description><![CDATA[There are terrific books you can find on the web for free :
If you have some links, please add them in the comments
]]></description>
			<content:encoded><![CDATA[<p>There are terrific books you can find on the web for free :</p>
<div id='linklist3' class='linklist'>
<div class=""><div id="online-books"><div class="linklistcatname">Online books<span class='linklistcatnamedesc'></span></div></div>
	<ul>
<li><a href="http://designingfortheweb.co.uk/book/" title=" (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/designingfortheweb.co.uk/book/?referer=');">Designing for the Web</a>
<br/>&nbsp;&nbsp;<br/></li>
<li><a href="http://diveintohtml5.org/" title="Dive Into HTML5 seeks to elaborate on a hand-picked Selection of features from the HTML5  specification and other fine Standards. The final manuscript has been published on paper by O’Reilly, under the Google Press imprint (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/diveintohtml5.org/?referer=');">Dive Into HTML5</a>
<br/>&nbsp;&nbsp;Dive Into HTML5 seeks to elaborate on a hand-picked Selection of features from the HTML5  specification and other fine Standards. The final manuscript has been published on paper by O’Reilly, under the Google Press imprint<br/></li>
<li><a href="http://jqfundamentals.com/book/book.html" title=" (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/jqfundamentals.com/book/book.html?referer=');">jQuery Fundamentals</a>
<br/>&nbsp;&nbsp;<br/></li>
<li><a href="http://msdn.microsoft.com/en-us/library/dd673617.aspx" title="Microsoft Application Architecture Guide online book (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/dd673617.aspx?referer=');">Microsoft Application Architecture Guide, 2nd Edition</a>
<br/>&nbsp;&nbsp;Microsoft Application Architecture Guide online book<br/></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ff953181%28PandP.50%29.aspx" title=" (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/ff953181_28PandP.50_29.aspx?referer=');">Microsoft Enterprise Library 5.0 - Developer Guide</a>
<br/>&nbsp;&nbsp;<br/></li>
<li><a href="http://wp7guide.codeplex.com/" title=" (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/wp7guide.codeplex.com/?referer=');">patterns &amp; practices - Windows Phone 7 Developer Guide</a>
<br/>&nbsp;&nbsp;<br/></li>
<li><a href="http://speckyboy.com/2010/03/19/12-must-have-free-downloadable-web-design-books/" title=" (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/speckyboy.com/2010/03/19/12-must-have-free-downloadable-web-design-books/?referer=');">speckyboy.com : 12 Useful and Free Downloadable Web Design Books</a>
<br/>&nbsp;&nbsp;<br/></li>
<li><a href="http://speckyboy.com/2010/09/02/20-useful-free-pdf-ebooks-for-designers-and-bloggers/" title=" (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/speckyboy.com/2010/09/02/20-useful-free-pdf-ebooks-for-designers-and-bloggers/?referer=');">speckyboy.com : 20 Useful Free PDF ebooks for Designers and Bloggers</a>
<br/>&nbsp;&nbsp;<br/></li>
<li><a href="http://speckyboy.com/2010/07/13/9-more-useful-and-free-downloadable-web-design-books/" title=" (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/speckyboy.com/2010/07/13/9-more-useful-and-free-downloadable-web-design-books/?referer=');">speckyboy.com : 9 More Useful and Free Downloadable Web Design Books</a>
<br/>&nbsp;&nbsp;<br/></li>
<li><a href="http://stackoverflow.com/questions/194812/list-of-freely-available-programming-books" title=" (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/questions/194812/list-of-freely-available-programming-books?referer=');">stackoverflow.com : List of freely available programming books</a>
<br/>&nbsp;&nbsp;<br/></li>
<li><a href="http://www.the-web-book.com/browse/index.html" title="The Web Book is a free 350-page book that tells you everything you need to know in order to create a home or business Web site from scratch. It covers everything from registering a domain name and renting some hosting space, to creating your first HTML pa (Last updated  January 1, 1970 2:00 am)" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.the-web-book.com/browse/index.html?referer=');">The Web Book</a>
<br/>&nbsp;&nbsp;The Web Book is a free 350-page book that tells you everything you need to know in order to create a home or business Web site from scratch. It covers everything from registering a domain name and renting some hosting space, to creating your first HTML pa<br/></li>
	</ul>
</div></div>

<!-- End of Link Library Output -->


<h4>If you have some links, please add them in the comments</h4>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/09/a-few-online-books/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging ADO.NET Datatables</title>
		<link>http://www.sambeauvois.be/blog/2010/05/debugging-ado-net-datatables/</link>
		<comments>http://www.sambeauvois.be/blog/2010/05/debugging-ado-net-datatables/#comments</comments>
		<pubDate>Fri, 14 May 2010 13:32:54 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=246</guid>
		<description><![CDATA[Do you ever had the famous error message :
&#8220;Failed to enable constraints. One or more rows  contain values violating non-null, unique, or foreign-key  constraints.&#8221;
when using ADO.NET Datasets ?
Tthis is an incredibly useful message isn&#8217;t it ?
So what can you do to spare you some headaches ? Retrieve a more useful message sure !
You have to [...]]]></description>
			<content:encoded><![CDATA[<p>Do you ever had the famous error message :</p>
<blockquote><p>&#8220;Failed to enable constraints. One or more rows  contain values violating non-null, unique, or foreign-key  constraints.&#8221;</p></blockquote>
<p>when using ADO.NET Datasets ?</p>
<p>Tthis is an incredibly useful message isn&#8217;t it ?</p>
<p>So what can you do to spare you some headaches ? Retrieve a more useful message sure !</p>
<p>You have to know that a Datatable object have a &#8220;HasError&#8221; property, this property allows you to know if the datatable has one ore more rows in error.</p>
<p>When HasError is true, you can retrieve the rows havin an error with the DataTable&#8217;s &#8220;GetErrors()&#8221; method wich return an array with all datarow having an error.</p>
<p>The &#8220;in errror&#8221; rows can inform you about errors with the &#8220;RowError&#8221; property.</p>
<p>Here is a simple helper class which can be used to debug a single DataTable or an entire DataSet:</p>
<pre class="brush: csharp;">
using System;
using System.Data;

public class DataSetErrorRevealer
{

   /// &lt;summary&gt;
   /// Get errors on rows of a DataTable
   /// &lt;/summary&gt;
   /// &lt;param name=&quot;errorDataTable&quot;&gt;The DataTable to be checked&lt;/param&gt;
   public static void RevealTableErrors(DataTable errorDataTable)
   {
      if (errorDataTable == null)
      {
         Console.WriteLine(&quot;The provided DataTable object is null&quot;);
         return;
      }

      if (errorDataTable.HasErrors)
      {
         DataRow[] rowsInError = errorDataTable.GetErrors();
         if (rowsInError.Length &lt;= 0)
         {
            Console.WriteLine(&quot;There is no problem with table {0}&quot;, errorDataTable.TableName);
         }
         else
         {
            foreach (DataRow errorRow in rowsInError)
            {
               Console.WriteLine(errorRow.RowError);
            }
         }
      }
   }

   /// &lt;summary&gt;
   /// Get errors on row for all tables of a DataSet
   /// &lt;/summary&gt;
   /// &lt;param name=&quot;errorDataSet&quot;&gt;The Dataset to be checked&lt;/param&gt;
   public static void RevealDataSetErrors(DataSet errorDataSet)
   {
         if (errorDataSet == null)
         {
            Console.WriteLine(&quot;The provided DataSet is null&quot;);
            return;
         }

         foreach (DataTable errorTable in errorDataSet.Tables)
         {
            RevealTableErrors(errorTable);
         }
      }
   }
</pre>
<p>Use it this way :</p>
<pre class="brush: csharp;">

   TestDataSet dataset = new TestDataSet();
   try
   {
      using (SqlConnection sqlCon = new SqlConnection(&quot;MyConnectionString&quot;))
      {
         SqlCommand sqlComm = sqlCon.CreateCommand();
         sqlComm.CommandType = CommandType.StoredProcedure;
         sqlComm.CommandText = &quot;Select Stored procedure&quot;;
         SqlDataAdapter sqlDa = new SqlDataAdapter(sqlComm);
         sqlDa.Fill(dataset);
      }
   }
   catch (Exception ex)
   {
   // Will provide the error message :
   // &quot;Failed to enable constraints. One or more rows
   // contain values violating non-null, unique,
   // or foreign-key  constraints.&quot;
   Console.WriteLine(&quot;Error : {0}&quot;, ex);

   // will provide a more helpful message
   DataSetErrorRevealer.RevealDataSetErrors(dataset);
   }
</pre>
<p>If you prefer, you can use an extension method :</p>
<pre class="brush: csharp;">

using System.Data;
using System;

public static class DataSetExtensions
{
   public static void RevealErrors(this DataSet errorDataSet)
   {
      if (errorDataSet == null)
      {
         Console.WriteLine(&quot;The provided DataSet is null&quot;);
         return;
      }

      foreach (DataTable errorTable in errorDataSet.Tables)
      {
         errorTable.RevealErrors();
      }
   }

   public static void RevealErrors(this DataTable errorDataTable)
   {
      if (errorDataTable == null)
      {
         Console.WriteLine(&quot;The provided DataTable object is null&quot;);
         return;
      }

      if (errorDataTable.HasErrors)
      {
         DataRow[] rowsInError = errorDataTable.GetErrors();
         if (rowsInError.Length &lt;= 0)
         {
            Console.WriteLine(&quot;There is no problem with table {0}&quot;, errorDataTable.TableName);
         }
         else
         {
            foreach (DataRow errorRow in rowsInError)
            {
               Console.WriteLine(errorRow.RowError);
            }
         }
      }
   }
}
</pre>
<p>use :</p>
<pre class="brush: csharp;">

catch (Exception ex)
{
   // will provide an helpful message
   dataset.RevealErrors();
}
</pre>
<p>Hope this helps !</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 211px; width: 1px; height: 1px; overflow: hidden;">using System;<br />
using System.Data;public class DataSetErrorRevealer<br />
{</p>
<p>/// &lt;summary&gt;<br />
/// Get errors on rows of a DataTable<br />
/// &lt;/summary&gt;<br />
/// &lt;param name=&#8221;errorDataTable&#8221;&gt;The DataTable to be checked&lt;/param&gt;<br />
public static void RevealTableErrors(DataTable errorDataTable)<br />
{<br />
if (errorDataTable == null)<br />
{<br />
Console.WriteLine(&#8221;The provided DataTable object is null&#8221;);<br />
return;<br />
}</p>
<p>if (errorDataTable.HasErrors)<br />
{<br />
DataRow[] rowsInError = errorDataTable.GetErrors();<br />
if (rowsInError.Length &lt;= 0)<br />
{<br />
Console.WriteLine(&#8221;There is no problem with table {0}&#8221;, errorDataTable.TableName);<br />
}<br />
else<br />
{<br />
foreach (DataRow errorRow in rowsInError)<br />
{<br />
Console.WriteLine(errorRow.RowError);<br />
}<br />
}<br />
}<br />
}</p>
<p>/// &lt;summary&gt;<br />
/// Get errors on row for all tables of a DataSet<br />
/// &lt;/summary&gt;<br />
/// &lt;param name=&#8221;errorDataSet&#8221;&gt;The Dataset to be checked&lt;/param&gt;<br />
public static void RevealDataSetErrors(DataSet errorDataSet)<br />
{<br />
if (errorDataSet == null)<br />
{<br />
Console.WriteLine(&#8221;The provided DataSet is null&#8221;);<br />
return;<br />
}</p>
<p>foreach (DataTable errorTable in errorDataSet.Tables)<br />
{<br />
RevealTableErrors(errorTable);<br />
}<br />
}<br />
}</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/05/debugging-ado-net-datatables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use ASP.NET Validators with the SharePoint:DateTimeControl</title>
		<link>http://www.sambeauvois.be/blog/2010/03/use-asp-net-validators-with-the-sharepointdatetimecontrol/</link>
		<comments>http://www.sambeauvois.be/blog/2010/03/use-asp-net-validators-with-the-sharepointdatetimecontrol/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 09:54:21 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sharepoint]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=222</guid>
		<description><![CDATA[If you want to use asp.net validation system with the SharePoint’s DateTimeControl, the first thing you need to know is that this control is “just” a wrapper around simple ASP.NET controls (textbox, dropdownlist).
If you want to set the ControlToValidate property of an ASP.NET validator to the DateTimeControl’s ID, it will throw an error!
As you can [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to use asp.net validation system with the SharePoint’s DateTimeControl, the first thing you need to know is that this control is “just” a wrapper around simple ASP.NET controls (textbox, dropdownlist).</p>
<p>If you want to set the ControlToValidate property of an ASP.NET validator to the DateTimeControl’s ID, it will throw an error!<br />
As you can guess, you have to target the controls inside the DateTimeControl.</p>
<p>Since the DateTimeControl set the name of the controls programmatically, you can retrieve the id of the control:</p>
<ul>
<li>Textbox date: DateTimeControl.ID +”Date”</li>
<li>Dropdownlist hours: DateTimeControl.ID +”DateHours”</li>
<li>Dropdownlist minutes: DateTimeControl.ID +”DateMinutes”</li>
</ul>
<h3>Example:</h3>
<p>If you use the SharePoint:DateTimeControl with the TimeOnly property set to “true”</p>
<pre class="brush: xml;">

&lt;SharePoint:DateTimeControl runat=&quot;server&quot; ID=&quot;TheTime&quot; TimeOnly=&quot;true&quot;/&gt;
</pre>
<p>You’ll have two dropdownlists, one for the hours and one for the minutes<br />
The DateTimeControl set the name:</p>
<p>Dropdownlist hours: DateTimeControl.ID +”DateHours”</p>
<p>Html will be:</p>
<pre class="brush: xml;">
&lt;select name=&quot;ctl00$PlaceHolderMain$ctl07$ctl02$TheTime$TheTimeDateHours&quot; id=&quot;ctl00_PlaceHolderMain_ctl07_ctl02_TheTime_TheTimeDateHours&quot; dir=&quot;ltr&quot;&gt;
 &lt;option value=&quot;00:&quot;&gt;00:&lt;/option&gt;
 &lt;option value=&quot;01:&quot;&gt;01:&lt;/option&gt;
 &lt;option value=&quot;02:&quot;&gt;02:&lt;/option&gt;
 &lt;option value=&quot;03:&quot;&gt;03:&lt;/option&gt;
 &lt;option value=&quot;04:&quot;&gt;04:&lt;/option&gt;
 &lt;option value=&quot;05:&quot;&gt;05:&lt;/option&gt;
 &lt;option value=&quot;06:&quot;&gt;06:&lt;/option&gt;
 &lt;option value=&quot;07:&quot;&gt;07:&lt;/option&gt;
 &lt;option value=&quot;08:&quot;&gt;08:&lt;/option&gt;
 &lt;option value=&quot;09:&quot;&gt;09:&lt;/option&gt;
 &lt;option value=&quot;10:&quot;&gt;10:&lt;/option&gt;
 &lt;option value=&quot;11:&quot;&gt;11:&lt;/option&gt;
 &lt;option value=&quot;12:&quot;&gt;12:&lt;/option&gt;
 &lt;option value=&quot;13:&quot;&gt;13:&lt;/option&gt;
 &lt;option value=&quot;14:&quot;&gt;14:&lt;/option&gt;
 &lt;option value=&quot;15:&quot;&gt;15:&lt;/option&gt;
 &lt;option value=&quot;16:&quot;&gt;16:&lt;/option&gt;
 &lt;option value=&quot;17:&quot;&gt;17:&lt;/option&gt;
 &lt;option value=&quot;18:&quot;&gt;18:&lt;/option&gt;
 &lt;option value=&quot;19:&quot;&gt;19:&lt;/option&gt;
 &lt;option value=&quot;20:&quot;&gt;20:&lt;/option&gt;
 &lt;option value=&quot;21:&quot;&gt;21:&lt;/option&gt;
 &lt;option value=&quot;22:&quot;&gt;22:&lt;/option&gt;
 &lt;option value=&quot;23:&quot;&gt;23:&lt;/option&gt;
&lt;/select&gt;
</pre>
<p>Dropdownlist minutes: DateTimeControl.ID +”DateMinutes”<br />
Html will be:</p>
<pre class="brush: xml;">
&lt;select name=&quot;ctl00$PlaceHolderMain$ctl07$ctl02$TheTime$TheTimeDateMinutes&quot; id=&quot;ctl00_PlaceHolderMain_ctl07_ctl02_TheTime_TheTimeDateMinutes&quot; dir=&quot;ltr&quot;&gt;
 &lt;option value=&quot;00&quot;&gt;00&lt;/option&gt;
 &lt;option value=&quot;05&quot;&gt;05&lt;/option&gt;
 &lt;option value=&quot;10&quot;&gt;10&lt;/option&gt;
 &lt;option value=&quot;15&quot;&gt;15&lt;/option&gt;
 &lt;option value=&quot;20&quot;&gt;20&lt;/option&gt;
 &lt;option value=&quot;25&quot;&gt;25&lt;/option&gt;
 &lt;option value=&quot;30&quot;&gt;30&lt;/option&gt;
 &lt;option value=&quot;35&quot;&gt;35&lt;/option&gt;
 &lt;option value=&quot;40&quot;&gt;40&lt;/option&gt;
 &lt;option value=&quot;45&quot;&gt;45&lt;/option&gt;
 &lt;option value=&quot;50&quot;&gt;50&lt;/option&gt;
 &lt;option value=&quot;55&quot;&gt;55&lt;/option&gt;
&lt;/select&gt;
</pre>
<p><strong>So you can retrieve the ASP.NET controls by using :</strong></p>
<ul>
<li>For the date: TheTime$TheTimeDate</li>
<li>For the hours: TheTime$TheTimeDateHours</li>
<li>For the minutes: TheTime$TheTimeDateMinutes</li>
</ul>
<h3>Real case example:</h3>
<p>I have two DateTimeControl, one named TheStartTime and one other named TheEndTime,</p>
<p>I want to validate that the end time is not before the start time.</p>
<p>So I’ll use the ASP.NET comparevalidator validator to compare the hours:</p>
<pre class="brush: xml;">
&lt;asp:CompareValidator id=&quot;valDate&quot; runat=&quot;server&quot; ControlToValidate=&quot;TheEndTime$TheEndTimeDateHours&quot; ControlToCompare=&quot;TheStartTime$TheStartTimeDateHours&quot;
 Type=&quot;Integer&quot;
 Operator=&quot;GreaterThanEqual&quot;
 ErrorMessage=&quot;The end time must be greater than the start time&quot;&gt;
 &lt;/asp:CompareValidator &gt;
</pre>
<p>Now, if you want to validate both hours and minutes, one option is to add an “asp:CustomValidator” and check conditions server side :<br />
Markup:</p>
<pre class="brush: xml;">
&lt;asp:CustomValidator runat=&quot;server&quot; ID=&quot;EndTimeMustBeLaterThanStartTimeCustomValidator&quot;
EnableClientScript=&quot;false&quot; ErrorMessage=&quot;Start time must be before end time&quot;/&gt;
</pre>
<p>Before the action, validate:</p>
<pre class="brush: csharp;">
if (!IsEndTimeLaterThanStartTime())
{
 EndTimeMustBeLaterThanStartTimeCustomValidator.IsValid = false;
 return;
}
</pre>
<p>Validation method:</p>
<pre class="brush: csharp;">

private bool IsEndTimeLaterThanStartTime()
{
 // retrieve the DropDownList
 DropDownList startHours = TheStartTime.FindControl(&quot;TheStartTimeDateHours&quot;) as DropDownList;
 DropDownList endHours = TheEndTime.FindControl(&quot;TheEndTimeDateHours&quot;) as DropDownList;

 // prevent from errors
 if (startHours == null ||
 endHours == null ||
 string.IsNullOrEmpty(startHours.SelectedValue) ||
 string.IsNullOrEmpty(endHours.SelectedValue))
 {
 return; // dont' do anything
 }

// the hour value is &quot;00:&quot;
 int startHour = Convert.ToInt32(startHours.SelectedValue.Replace(&quot;:&quot;,&quot;&quot;));
 int endHour = Convert.ToInt32(endHours.SelectedValue.Replace(&quot;:&quot;, &quot;&quot;));
 if (endHour &lt; startHour)
 {
 args.IsValid = false;
 }
 else
 {

 if (endHour == startHour)
 {
 // check the minutes
 DropDownList startMinutes = TheStartTime.FindControl(&quot;TheStartTimeDateMinutes&quot;) as DropDownList;
 DropDownList endMinutes = TheEndTime.FindControl(&quot;TheEndTimeDateMinutes&quot;) as DropDownList;
 // prevent from errors
 if (startMinutes == null ||
 endMinutes == null ||
 string.IsNullOrEmpty(startMinutes.SelectedValue) ||
 string.IsNullOrEmpty(endMinutes.SelectedValue))
 {
 return; // dont' do anything
 }

 int startMinute = Convert.ToInt32(startMinutes.SelectedValue);
 int endMinute = Convert.ToInt32(endMinutes.SelectedValue);

 if (endHour &lt;= startMinute)
 args.IsValid = false;

 }
 }

 args.IsValid = true;

 }
</pre>
<p>You can also validate the Date himself if you choose to display it,<br />
you can make a client side validation if you know javascript,<br />
you can do everything like in “classic” ASP.NET.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/03/use-asp-net-validators-with-the-sharepointdatetimecontrol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A few lists &#8230;</title>
		<link>http://www.sambeauvois.be/blog/2010/01/a-few-lists/</link>
		<comments>http://www.sambeauvois.be/blog/2010/01/a-few-lists/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 10:08:29 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=159</guid>
		<description><![CDATA[The Joel Test: 12 Steps to Better Code
Top 10 Things That Annoy Programmers
10 Programming proverbs every developer should know
101 Ways To Know Your Software Project Is Doomed
Top 100 Blogs for Developers
&#8211;&#62; Pragmatic Software Development Tips
]]></description>
			<content:encoded><![CDATA[<p><a title="The Joel Test: 12 Steps to Better Code" href="http://www.joelonsoftware.com/articles/fog0000000043.html" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.joelonsoftware.com/articles/fog0000000043.html?referer=');">The Joel Test: 12 Steps to Better Code</a></p>
<p><a title="Top 10 Things That Annoy Programmers" href="http://www.kevinwilliampang.com/post/Top-10-Things-That-Annoy-Programmers.aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.kevinwilliampang.com/post/Top-10-Things-That-Annoy-Programmers.aspx?referer=');">Top 10 Things That Annoy Programmers</a></p>
<p><a title="10 Programming proverbs every developer should know" href="http://www.kevinwilliampang.com/post/Programming-Proverbs.aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.kevinwilliampang.com/post/Programming-Proverbs.aspx?referer=');">10 Programming proverbs every developer should know</a></p>
<p><a title="101 Ways To Know Your Software Project Is Doomed" href="http://delimitdesign.com/inspirational/101-ways-to-know-your-software-project-management-is-doomed/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/delimitdesign.com/inspirational/101-ways-to-know-your-software-project-management-is-doomed/?referer=');">101 Ways To Know Your Software Project Is Doomed</a></p>
<p><a title="Top 100 Blogs for Developers" href="http://www.sambeauvois.be/blog/wp-admin/post-new.php" target="_blank">Top 100 Blogs for Developers</a></p>
<p>&#8211;&gt; <a title="Pragmatic Software Development Tips" href="http://pragprog.com/the-pragmatic-programmer/extracts/tips" target="_blank" onclick="pageTracker._trackPageview('/outgoing/pragprog.com/the-pragmatic-programmer/extracts/tips?referer=');">Pragmatic Software Development Tips</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2010/01/a-few-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C#, check if a string is null or empty</title>
		<link>http://www.sambeauvois.be/blog/2009/12/c-check-if-a-string-is-null-or-empty/</link>
		<comments>http://www.sambeauvois.be/blog/2009/12/c-check-if-a-string-is-null-or-empty/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 22:08:21 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=120</guid>
		<description><![CDATA[In C# you can check if a string is null or empty in many ways :

string String1 = &#34;testString&#34;;
if (String1== null &#124;&#124; String1 == &#34;&#34;)
{
// ...
}
else
{
// ...
}



string String1 = &#34;testString&#34;;
 if (String1 == null &#124;&#124; String1.Length==0)
 {
 // ...
 }
 else
 {
 // ...
 }


 string String1 = &#34;testString&#34;;
 if (string.IsNullOrEmpty(String1))
 {
 // ...
 }
 [...]]]></description>
			<content:encoded><![CDATA[<p>In C# you can check if a string is null or empty in many ways :</p>
<pre class="brush: csharp;">
string String1 = &quot;testString&quot;;
if (String1== null || String1 == &quot;&quot;)
{
// ...
}
else
{
// ...
}
</pre>
<pre class="brush: csharp;">

string String1 = &quot;testString&quot;;
 if (String1 == null || String1.Length==0)
 {
 // ...
 }
 else
 {
 // ...
 }
</pre>
<pre class="brush: csharp;">
 string String1 = &quot;testString&quot;;
 if (string.IsNullOrEmpty(String1))
 {
 // ...
 }
 else
 {
 // ...
 }
</pre>
<p>The last one is more readable.</p>
<p>But what about performances ?</p>
<p>Check this code :</p>
<pre class="brush: csharp;">
private void CheckForNullOrEmpty()
 {
 int maxIterations = 9999999;

 Console.WriteLine(&quot;if (string.IsNullOrEmpty(String1))&quot;);
 Stopwatch watch = Stopwatch.StartNew();
 for (int i = 0; i &lt; maxIterations; i++)
 {
 string String1 = &quot;testString&quot;;
 if (string.IsNullOrEmpty(String1))
 {
 // ...
 }
 else
 {
 // ...
 }
 }

 watch.Stop();
 Console.WriteLine(&quot;\tTime : &quot; + watch.Elapsed.TotalMilliseconds);
 Console.WriteLine(Environment.NewLine);

 Console.WriteLine(&quot;if (String1== null || String1 == \&quot;\&quot;&quot;);
 watch = Stopwatch.StartNew();
 for (int i = 0; i &lt; maxIterations; i++)
 {
 string String1 = &quot;testString&quot;;
 if (String1 == null || String1 == &quot;&quot;)
 {
 // ...
 }
 else
 {
 // ...
 }
 }

 watch.Stop();
 Console.WriteLine(&quot;\tTime : &quot; + watch.Elapsed.TotalMilliseconds);
 Console.WriteLine(Environment.NewLine);

 Console.WriteLine(&quot;if (String1 == null || String1.Length==0)&quot;);
 watch = Stopwatch.StartNew();
 for (int i = 0; i &lt; maxIterations; i++)
 {
 string String1 = &quot;testString&quot;;
 if (String1 == null || String1.Length == 0)
 {
 // ...
 }
 else
 {
 // ...
 }
 }

 watch.Stop();
 Console.WriteLine(&quot;\tTime : &quot; + watch.Elapsed.TotalMilliseconds);
 Console.WriteLine(Environment.NewLine);

 Console.WriteLine(Environment.NewLine);
 Console.WriteLine(&quot;Press any key to continue&quot;);
 Console.ReadLine();
 }
</pre>
<p>Output is :</p>
<p><a href="http://www.sambeauvois.be/blog/wp-content/uploads/2009/12/CheckStringForNullOrEmptyOutput.png"><img class="aligncenter size-full wp-image-122" src="http://www.sambeauvois.be/blog/wp-content/uploads/2009/12/CheckStringForNullOrEmptyOutput.png" alt="CheckStringForNullOrEmptyOutput" width="677" height="342" /></a></p>
<p>The difference between<strong> &#8220;String.IsNullOrEmpty&#8221;</strong> and <strong>&#8220;check for null then for lenght</strong>&#8221; is minimal, so prefer the String.IsNullOrEmpty() wich is more readable.</p>
<p>As you can guess, IsNullOrEmpty performs a check for null, then a check for lenght :</p>
<p>If you use Reflector to inspect the <a href="http://msdn.microsoft.com/en-us/library/system.string.aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/system.string.aspx?referer=');">String</a> class in the mscorlib, you can see that String.IsNullOrEmpty do the same thing we do in our test :</p>
<pre class="brush: csharp;">
public static bool IsNullOrEmpty(string value)
{
if (value != null)
{
return (value.Length == 0);
}
return true;
}
</pre>
<p>the &#8220;extra&#8221; time comes from the method call</pre>
<p>Note : In .Net Framework 4.0: string.IsNullOrWhiteSpace() method appears, but I've not tested yet (<a href="http://weblogs.asp.net/gunnarpeipman/archive/2009/10/25/net-framework-4-0-string-isnullorwhitespace-method.aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/weblogs.asp.net/gunnarpeipman/archive/2009/10/25/net-framework-4-0-string-isnullorwhitespace-method.aspx?referer=');">link</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2009/12/c-check-if-a-string-is-null-or-empty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How long need a portion of code to be executed ?</title>
		<link>http://www.sambeauvois.be/blog/2009/12/how-long-need-a-portion-of-code-to-be-executed/</link>
		<comments>http://www.sambeauvois.be/blog/2009/12/how-long-need-a-portion-of-code-to-be-executed/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 08:44:07 +0000</pubDate>
		<dc:creator>Sam Beauvois</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.sambeauvois.be/blog/?p=106</guid>
		<description><![CDATA[Use the Stopwatch object !

using System.Diagnostics;

// ...

Stopwatch myStopWatch = Stopwatch.StartNew();

// some code

myStopWatch.Stop();

Console.WriteLine(&#34;{0} ms - {1} ticks&#34;, myStopWatch.Elapsed.TotalMilliseconds, myStopWatch.ElapsedTicks);

// ...

]]></description>
			<content:encoded><![CDATA[<p>Use the Stopwatch object !</p>
<pre class="brush: csharp;">
using System.Diagnostics;

// ...

Stopwatch myStopWatch = Stopwatch.StartNew();

// some code

myStopWatch.Stop();

Console.WriteLine(&quot;{0} ms - {1} ticks&quot;, myStopWatch.Elapsed.TotalMilliseconds, myStopWatch.ElapsedTicks);

// ...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sambeauvois.be/blog/2009/12/how-long-need-a-portion-of-code-to-be-executed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
