<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Dot Net Technologies -- MS Tech talk and more</title>
    <link>http://www.dotnettechnologies.com/</link>
    <description>Creating Solutions with Microsoft's .Net Technologies</description>
    <language>en-us</language>
    <copyright>© Copyright 2010 </copyright>
    <lastBuildDate>Tue, 10 Aug 2010 05:06:51 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>daryl@rubiconcomputing.com</managingEditor>
    <webMaster>daryl@rubiconcomputing.com</webMaster>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=7624b40d-72c0-4e7a-aa80-15e9ddbb0009</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,7624b40d-72c0-4e7a-aa80-15e9ddbb0009.aspx</pingback:target>
      <dc:creator>Daryl</dc:creator>
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,7624b40d-72c0-4e7a-aa80-15e9ddbb0009.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7624b40d-72c0-4e7a-aa80-15e9ddbb0009</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Today's tip is more than a tip. It's a
full project which contains a sample of a control I call the MessageCenter. When developing
interactive applications, it's important to provide the user convenient feedback in
a consistent location. In my current application I am working on, there are three
types of messages (which are typical for most applications) -- errors, informational
messages, and warnings. 
<br /><br />
I wanted to make sure each one appeared different enough so the user could quickly
determine which ones needed the most attention. There are a lot of ways I could have
accomplished this, such as a class/collection which maintained the type of message,
and each class has it's own CSS for displaying. However, I opted for a siumpler solution
which is available to every ASP.Net page -- The Validators collection (part of the
page object).<br /><br />
The Validators collection maintains a list of objects which implement the IValidator
interface. This collection is automatically bound to the ValidationSummary control
on the page before (for client-side validation) and after a postback. During a postback
for example, you can add a new error to the Page.Validators collection by calling
the Add method, and supply a class which implements the IValidator interface.<br /><br />
In the sample project, I implemented three classes -- ValidationError, ValidationNotification
and ValidationWarning -- to specify my three different types of messages. Each implements
the IValidator interface essentially the same way. I can use the ErrorMessage property
of the interface to display the message I want to convey to the end user.<br /><br />
In my page base class, I implemented members to easily add these messages to the Page.Validators
collection, as shown below:<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">void</span> DisplayError(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> message)
{ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span>.Validators.Add(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">new</span> ValidationError(message));
} <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">void</span> DisplayError(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> message, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">params</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span>[]
p) { DisplayError(String.Format(message, p)); } <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">void</span> DisplayMessage(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> message)
{ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span>.Validators.Add(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">new</span> NotificationValidator(message));
}</span></pre><br />
 Note in some of the methods, I can pass in a list of parameters, so I can format
the message displayed with a variety of details.   
<br /><br />
The MessageCenter.ascx control is where the work is done. When added to a page, it
provides a ValidationSummary control to handle the clientside validation, and a Repeater
which handles the postback messages. With some work, you could integrate the two,
but that is way beyond what I needed.<br /><br />
During the Page_Load event of the MessageCenter control, I bind the Page.Validators
collection to the Repeater. I also remove these from Page.Validators collection afterwards,
as I don't want them displaying in the ValidationSummary control I use for client
validation.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">protected</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">void</span> Page_Load(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">object</span> sender,
EventArgs e) { rptNotification.DataSource <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span>.Page.Validators;
rptNotification.DataBind(); rptNotification.Visible <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> (<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span>.Page.Validators.Count
!<span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> 0); <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">for</span> (<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">int</span> idx <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> (<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span>.Page.Validators.Count <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">-</span> 1);
idx &gt;= 0; idx--) { IValidator val <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span>.Page.Validators[idx]; <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span>.Page.Validators.Remove(val);
} }</span></pre><br /><br />
During the ItemDataBound event of the repeater, I determine the type of IValidator,
and set the appropriate image to the row of data. I bind the IValidator class ErrorMessage
property to the label inside the repeater row as well, and set the appropriate CSS
class so it displays in the color format I like.<br /><br />
        <pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">protected</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">void</span> rptNotification_ItemDataBound(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">object</span> sender,
RepeaterItemEventArgs e) { <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">try</span> { <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> ((e.Item.ItemType
== ListItemType.Item) || ((e.Item.ItemType == ListItemType.AlternatingItem))) { IValidator
val <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Page.Validators[e.Item.ItemIndex];
Image img <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> (Image)e.Item.FindControl(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"imgNotice"</span>); <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (img
!<span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">null</span>)
{ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (val <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">is</span> NotificationValidator)
img.ImageUrl <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"~/images/info.png"</span>; <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (val <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">is</span> ValidationError)
img.ImageUrl <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"~/images/error.png"</span>; <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (val <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">is</span> ValidationWarning)
img.ImageUrl <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"~/images/warning.png"</span>;
} Label lblInfo <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> (Label)e.Item.FindControl(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"lblDetails"</span>); <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (lblInfo
!<span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">null</span>)
{ lblInfo.Text <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> val.ErrorMessage; <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (val <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">is</span> NotificationValidator)
lblInfo.CssClass <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"NotificationItem"</span>; <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (val <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">is</span> ValidationError)
lblInfo.CssClass <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"ErrorItem"</span>; <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (val <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">is</span> ValidationWarning)
lblInfo.CssClass <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"WarningItem"</span>;
} } } <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">catch</span> (Exception
ex) { <span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">//TODO:
Log the error</span> } } } </span></pre><br />
The end result is a control which sits on top of the page (and is only visible when
there are messages to display) and looks like this:<br /><br /><br /><p></p><img src="http://www.dotnettechnologies.com/content/binary/Example.jpg" border="0" /><a href="http://www.dotnettechnologies.com/content/binary/Notification%5B1%5D.zip">Notification[1].zip
(38.27 KB)</a><br /><br />
UPDATE: Had a bug in the original file, so I updated the project (and cleaned out
all the ancillary junk in it as well) and posted it again.<br /><br /><img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7624b40d-72c0-4e7a-aa80-15e9ddbb0009" /></body>
      <title>Tip of the Day: Creating a control that displays multiple types of messages using the IValidator interface</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,7624b40d-72c0-4e7a-aa80-15e9ddbb0009.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/08/10/TipOfTheDayCreatingAControlThatDisplaysMultipleTypesOfMessagesUsingTheIValidatorInterface.aspx</link>
      <pubDate>Tue, 10 Aug 2010 05:06:51 GMT</pubDate>
      <description>Today's tip is more than a tip. It's a full project which contains a sample of a control I call the MessageCenter. When developing interactive applications, it's important to provide the user convenient feedback in a consistent location. In my current application I am working on, there are three types of messages (which are typical for most applications) -- errors, informational messages, and warnings. &lt;br&gt;
&lt;br&gt;
I wanted to make sure each one appeared different enough so the user could quickly
determine which ones needed the most attention. There are a lot of ways I could have
accomplished this, such as a class/collection which maintained the type of message,
and each class has it's own CSS for displaying. However, I opted for a siumpler solution
which is available to every ASP.Net page -- The Validators collection (part of the
page object).&lt;br&gt;
&lt;br&gt;
The Validators collection maintains a list of objects which implement the IValidator
interface. This collection is automatically bound to the ValidationSummary control
on the page before (for client-side validation) and after a postback. During a postback
for example, you can add a new error to the Page.Validators collection by calling
the Add method, and supply a class which implements the IValidator interface.&lt;br&gt;
&lt;br&gt;
In the sample project, I implemented three classes -- ValidationError, ValidationNotification
and ValidationWarning -- to specify my three different types of messages. Each implements
the IValidator interface essentially the same way. I can use the ErrorMessage property
of the interface to display the message I want to convey to the end user.&lt;br&gt;
&lt;br&gt;
In my page base class, I implemented members to easily add these messages to the Page.Validators
collection, as shown below:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; DisplayError(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; message)
{ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.Validators.Add(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; ValidationError(message));
} &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; DisplayError(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; message, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;params&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt;[]
p) { DisplayError(String.Format(message, p)); } &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; DisplayMessage(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; message)
{ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.Validators.Add(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; NotificationValidator(message));
}&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&amp;nbsp;Note in some of the methods, I can pass in a list of parameters, so I can format
the message displayed with a variety of details. &amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
The MessageCenter.ascx control is where the work is done. When added to a page, it
provides a ValidationSummary control to handle the clientside validation, and a Repeater
which handles the postback messages. With some work, you could integrate the two,
but that is way beyond what I needed.&lt;br&gt;
&lt;br&gt;
During the Page_Load event of the MessageCenter control, I bind the Page.Validators
collection to the Repeater. I also remove these from Page.Validators collection afterwards,
as I don't want them displaying in the ValidationSummary control I use for client
validation.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;object&lt;/span&gt; sender,
EventArgs e) { rptNotification.DataSource &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.Page.Validators;
rptNotification.DataBind(); rptNotification.Visible &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; (&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.Page.Validators.Count
!&lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; 0); &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;for&lt;/span&gt; (&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;int&lt;/span&gt; idx &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; (&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.Page.Validators.Count &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;-&lt;/span&gt; 1);
idx &amp;gt;= 0; idx--) { IValidator val &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.Page.Validators[idx]; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt;.Page.Validators.Remove(val);
} }&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
During the ItemDataBound event of the repeater, I determine the type of IValidator,
and set the appropriate image to the row of data. I bind the IValidator class ErrorMessage
property to the label inside the repeater row as well, and set the appropriate CSS
class so it displays in the color format I like.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;protected&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;void&lt;/span&gt; rptNotification_ItemDataBound(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;object&lt;/span&gt; sender,
RepeaterItemEventArgs e) { &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;try&lt;/span&gt; { &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; ((e.Item.ItemType
== ListItemType.Item) || ((e.Item.ItemType == ListItemType.AlternatingItem))) { IValidator
val &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Page.Validators[e.Item.ItemIndex];
Image img &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; (Image)e.Item.FindControl(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"imgNotice"&lt;/span&gt;); &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (img
!&lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;null&lt;/span&gt;)
{ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (val &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;is&lt;/span&gt; NotificationValidator)
img.ImageUrl &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"~/images/info.png"&lt;/span&gt;; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (val &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;is&lt;/span&gt; ValidationError)
img.ImageUrl &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"~/images/error.png"&lt;/span&gt;; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (val &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;is&lt;/span&gt; ValidationWarning)
img.ImageUrl &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"~/images/warning.png"&lt;/span&gt;;
} Label lblInfo &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; (Label)e.Item.FindControl(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"lblDetails"&lt;/span&gt;); &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (lblInfo
!&lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;null&lt;/span&gt;)
{ lblInfo.Text &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; val.ErrorMessage; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (val &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;is&lt;/span&gt; NotificationValidator)
lblInfo.CssClass &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"NotificationItem"&lt;/span&gt;; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (val &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;is&lt;/span&gt; ValidationError)
lblInfo.CssClass &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"ErrorItem"&lt;/span&gt;; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (val &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;is&lt;/span&gt; ValidationWarning)
lblInfo.CssClass &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"WarningItem"&lt;/span&gt;;
} } } &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;catch&lt;/span&gt; (Exception
ex) { &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;//TODO:
Log the error&lt;/span&gt; } } } &lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
The end result is a control which sits on top of the page (and is only visible when
there are messages to display) and looks like this:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/Example.jpg" border="0"&gt;&lt;a href="http://www.dotnettechnologies.com/content/binary/Notification%5B1%5D.zip"&gt;Notification[1].zip
(38.27 KB)&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
UPDATE: Had a bug in the original file, so I updated the project (and cleaned out
all the ancillary junk in it as well) and posted it again.&lt;br&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7624b40d-72c0-4e7a-aa80-15e9ddbb0009" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,7624b40d-72c0-4e7a-aa80-15e9ddbb0009.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=1aac1456-13df-443f-b660-27c38fd4eb49</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,1aac1456-13df-443f-b660-27c38fd4eb49.aspx</pingback:target>
      <dc:creator>Daryl</dc:creator>
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,1aac1456-13df-443f-b660-27c38fd4eb49.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1aac1456-13df-443f-b660-27c38fd4eb49</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I designed a control to filter data dynamically,
and I wanted to be able to be able to use it to filter either SQL Data (via a DataTable)
or a List&lt;T&gt; of objects. Sorting the DataTable dynamically is easy using the
DataTable, as you can create a DataView and perform case insensitive searches like
this:<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">DataView
dvData <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">new</span> DataView(data);
dvData.RowFilter <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> “SomeField=’Test’”; </span></pre>You
can also create widcard searches like this:<pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">DataView
dvData <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">new</span> DataView(data);
dvData.RowFilter <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> “SomeField
LIKE ’Te%’”; </span></pre>But providing that functionality with List&lt;T&gt; and
LINQ was going to be a challenge.  If you know the properties you want to find
in advance, the syntax is easy using Lambda functions:<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">List&lt;MyObject&gt;
objectResults <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> MyList.FindAdd(x
=&gt; x.MyProperty.ToLower() == “Value”);</span></pre>That’s well and good, but in
my filter control, I wanted to be able to specify a property by name for a comparison. 
Something like this:<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">List&lt;MyObject&gt;
objectResults <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> MyList.FindAdd(x
=&gt; “MyPropertyName” == “Value”);</span></pre>Unfortunately, that’s not going to
work. I needed something that would dynamically specify the property I want to search.
In a <a href="http://www.dotnettechnologies.com/2009/12/30/TipOfTheDayDynamicallySortingAListCollectionUsingLambdaExpression.aspx" target="_blank">previous
post</a> I described how I could use a defined Lambda Expression to dynamically sort
a list in a similar fashion.<br /><br />
So in my first attempt and doing a lot of searching on Google, I came up with this
method:<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"> public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">static</span> IEnumerable&lt;T&gt;
DynamicFilter&lt;T&gt;(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span> IEnumerable&lt;T&gt;
source, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> propertyOrFieldName, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> searchValue)
{ Func&lt;T, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bool</span>&gt;
predicate <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> CreatePredicate&lt;T&gt;(propertyOrFieldName,
searchValue); <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">return</span> source.Where(predicate);
} <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">static</span> Func&lt;T, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bool</span>&gt;
CreatePredicate&lt;T&gt;(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> propertyOrFieldName, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> searchValue)
{ var arg <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Parameter(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(T), <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"arg"</span>);
var body <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Equal(Expression.Property(arg,
propertyOrFieldName), Expression.Constant(searchValue)); <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">return</span> Expression.Lambda&lt;Func&lt;T, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bool</span>&gt;&gt;(body,
arg).Compile(); } </span></pre>Usage:  
<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">List&lt;Employee&gt;
emps <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Employee.LoadListCollection();
List&lt;Employee&gt; empList <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> emps.DynamicFilter(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"FirstName"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Angie"</span>).ToList(); </span></pre>This
worked great for a case-sensitive search, but I still didn’t have a way to do a case-insensitve
search or a wildcard search. So after some more searching and more trial-and-error,
I came up with this for a wildcard search:<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">static</span> IEnumerable&lt;T&gt;
ContainsString&lt;T&gt;(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span> IEnumerable&lt;T&gt;
data, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> propertyOrFieldName, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> searchValue)
{ var param <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Parameter(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(T), <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"x"</span>);
var body <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Call( <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(BusinessObjectBase).GetMethod(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Like"</span>,
BindingFlags.Static <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">|</span> BindingFlags.NonPublic <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">|</span> BindingFlags.Public),
Expression.PropertyOrField(param, propertyOrFieldName), Expression.Constant(searchValue, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span>)));
var lambda <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Lambda&lt;Func&lt;T, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bool</span>&gt;&gt;(body,
param); <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">return</span> data.Where(lambda.Compile());
} </span></pre>A couple things to note here. First, I needed  to add a method
“Like” to my base object (BusinessObjectBase in this case) of the collections I am
searching. It looks like this:<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
&lt;summary&gt;</span><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
comparison operator. Needed for dynamically filtering the objects</span><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
&lt;/summary&gt;</span><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
&lt;param name="a"&gt;A.&lt;/param&gt;</span><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
&lt;param name="b"&gt;The b.&lt;/param&gt;</span><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
&lt;returns&gt;&lt;/returns&gt;</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">static</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bool</span> Like(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> a, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> b)
{ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">return</span> a.ToLower().Contains(b.ToLower());
} </span></pre>Now I can do a search where I specify the property name, and it returns
and value of that property that contains any part of that string (and it is also case-insensitive).<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">List&lt;Employee&gt;
emps <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Employee.LoadListCollection();
List&lt;Employee&gt; empList <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> emps.ContainsString(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"FirstName"</span>, <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"An"</span>).ToList(); </span></pre>Then
it occurred to me that I was specifying the name of the static routine in the call.
What would happen if I specified the name of the operator dynamically? Would it work
right? 
<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">var
body <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Call( <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(BusinessObjectBase).GetMethod(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Like"</span>,
BindingFlags.Static <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">|</span> BindingFlags.NonPublic <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">|</span> BindingFlags.Public), 
<br /><font size="2" face="Verdana">Became this:</font><br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">var
body <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Call( <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(BusinessObjectBase).GetMethod(operatorName,
BindingFlags.Static <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">|</span> BindingFlags.NonPublic <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">|</span> BindingFlags.Public), </span></pre><font size="2" face="Verdana">Now
I could create two static operators (or as many as I might ever need) to provide this
dynamic functionality.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">static</span> IEnumerable&lt;T&gt;
RunOperator&lt;T&gt;(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span> IEnumerable&lt;T&gt;
data, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> operatorName, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> propertyOrFieldName, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> searchValue)
{ var param <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Parameter(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(T), <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"x"</span>);
var body <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Call( <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(BusinessObjectBase).GetMethod(operatorName,
BindingFlags.Static <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">|</span> BindingFlags.NonPublic <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">|</span> BindingFlags.Public),
Expression.PropertyOrField(param, propertyOrFieldName), Expression.Constant(searchValue, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span>)));
var lambda <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Lambda&lt;Func&lt;T, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bool</span>&gt;&gt;(body,
param); <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">return</span> data.Where(lambda.Compile());
} </span></pre>In my BusinessObjectBase class, I added the following methods (Like
for wildcard searches, and Equals for a case-insensitive search):<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">static</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bool</span> Like(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> a, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> b)
{ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">return</span> a.ToLower().Contains(b.ToLower());
} <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">static</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bool</span> Equals(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> a, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> b)
{ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">return</span> a.ToLower()
== b.ToLower(); } </span></pre>I can call both of these methods like this:<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">public</span> List&lt;T&gt;
FilterData&lt;T&gt;(List&lt;T&gt; data, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bool</span> wildcardSearch)
{ List&lt;T&gt; results <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> data; <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (wildcardSearch)
results <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> results.RunOperator(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Like"</span>,
fi.DataField, fi.FilterValue()).ToList(); <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">else</span>     results <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> results.RunOperator(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"Equals"</span>,
fi.DataField, fi.FilterValue()).ToList();     <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">return</span> results;
} </span></pre>So let’s break it down a little. First, the first parameter of a lambda
expression, which is what we are building here, is the input parameter, or in this
case, the x portion of x =&gt;.<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">var
param <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Parameter(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(T), <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"x"</span>);</span></pre>Next,
we’re setting up the call which is made to the right of the =&gt; of the Lambda expression.
The code below is saying “grab the method name provided by the operatorName variable,
which can be found in any class which implements the BusinessObjectBase class.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">typeof</span>(BusinessObjectBase).GetMethod(operatorName,</span></pre><br />
The result of the expression defined above will be returning a boolean, as defined
here:<br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">var
lambda <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> Expression.Lambda&lt;Func&lt;T, <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">bool</span>&gt;&gt;(body,
param);</span></pre>Finally, we return the data which evaluates in the lambda expression
as true via this line of code:<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">return</span> data.Where(lambda.Compile());</span></pre>Note
the delegate lambda expression is compiled into executrable code and produces a delegate
which represents the lambda expression.<br />
Obviously, understanding how to dynamically call methods and compare properties using
LINQ is extremely powerful and has many,many possibilities. I hope this helps someone
else trying to do the same thing!<br /><br /></font></span></pre><p></p><img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1aac1456-13df-443f-b660-27c38fd4eb49" /></body>
      <title>Tip of the Day: The evolution of dynamic, case insensitive LINQ to Object search</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,1aac1456-13df-443f-b660-27c38fd4eb49.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/08/09/TipOfTheDayTheEvolutionOfDynamicCaseInsensitiveLINQToObjectSearch.aspx</link>
      <pubDate>Mon, 09 Aug 2010 04:34:12 GMT</pubDate>
      <description>I designed a control to filter data dynamically, and I wanted to be able to be able to use it to filter either SQL Data (via a DataTable) or a List&amp;lt;T&amp;gt; of objects. Sorting the DataTable dynamically is easy using the DataTable, as you can create a DataView and perform case insensitive searches like this:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;DataView
dvData &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; DataView(data);
dvData.RowFilter &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; “SomeField=’Test’”; &lt;/span&gt;&lt;/pre&gt;You
can also create widcard searches like this:&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;DataView
dvData &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; DataView(data);
dvData.RowFilter &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; “SomeField
LIKE ’Te%’”; &lt;/span&gt;&lt;/pre&gt;But providing that functionality with List&amp;lt;T&amp;gt; and
LINQ was going to be a challenge.&amp;nbsp; If you know the properties you want to find
in advance, the syntax is easy using Lambda functions:&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;List&amp;lt;MyObject&amp;gt;
objectResults &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; MyList.FindAdd(x
=&amp;gt; x.MyProperty.ToLower() == “Value”);&lt;/span&gt;&lt;/pre&gt;That’s well and good, but in
my filter control, I wanted to be able to specify a property by name for a comparison.&amp;nbsp;
Something like this:&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;List&amp;lt;MyObject&amp;gt;
objectResults &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; MyList.FindAdd(x
=&amp;gt; “MyPropertyName” == “Value”);&lt;/span&gt;&lt;/pre&gt;Unfortunately, that’s not going to
work. I needed something that would dynamically specify the property I want to search.
In a &lt;a href="http://www.dotnettechnologies.com/2009/12/30/TipOfTheDayDynamicallySortingAListCollectionUsingLambdaExpression.aspx" target="_blank"&gt;previous
post&lt;/a&gt; I described how I could use a defined Lambda Expression to dynamically sort
a list in a similar fashion.&lt;br&gt;
&lt;br&gt;
So in my first attempt and doing a lot of searching on Google, I came up with this
method:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt;
DynamicFilter&amp;lt;T&amp;gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt;
source, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; propertyOrFieldName, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; searchValue)
{ Func&amp;lt;T, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bool&lt;/span&gt;&amp;gt;
predicate &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; CreatePredicate&amp;lt;T&amp;gt;(propertyOrFieldName,
searchValue); &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; source.Where(predicate);
} &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; Func&amp;lt;T, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bool&lt;/span&gt;&amp;gt;
CreatePredicate&amp;lt;T&amp;gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; propertyOrFieldName, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; searchValue)
{ var arg &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Parameter(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(T), &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"arg"&lt;/span&gt;);
var body &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Equal(Expression.Property(arg,
propertyOrFieldName), Expression.Constant(searchValue)); &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; Expression.Lambda&amp;lt;Func&amp;lt;T, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bool&lt;/span&gt;&amp;gt;&amp;gt;(body,
arg).Compile(); } &lt;/span&gt;&lt;/pre&gt;Usage:&amp;nbsp; 
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;List&amp;lt;Employee&amp;gt;
emps &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Employee.LoadListCollection();
List&amp;lt;Employee&amp;gt; empList &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; emps.DynamicFilter(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"FirstName"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Angie"&lt;/span&gt;).ToList(); &lt;/span&gt;&lt;/pre&gt;This
worked great for a case-sensitive search, but I still didn’t have a way to do a case-insensitve
search or a wildcard search. So after some more searching and more trial-and-error,
I came up with this for a wildcard search:&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt;
ContainsString&amp;lt;T&amp;gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt;
data, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; propertyOrFieldName, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; searchValue)
{ var param &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Parameter(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(T), &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"x"&lt;/span&gt;);
var body &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Call( &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(BusinessObjectBase).GetMethod(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Like"&lt;/span&gt;,
BindingFlags.Static &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;|&lt;/span&gt; BindingFlags.NonPublic &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;|&lt;/span&gt; BindingFlags.Public),
Expression.PropertyOrField(param, propertyOrFieldName), Expression.Constant(searchValue, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt;)));
var lambda &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Lambda&amp;lt;Func&amp;lt;T, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bool&lt;/span&gt;&amp;gt;&amp;gt;(body,
param); &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; data.Where(lambda.Compile());
} &lt;/span&gt;&lt;/pre&gt;A couple things to note here. First, I needed&amp;nbsp; to add a method
“Like” to my base object (BusinessObjectBase in this case) of the collections I am
searching. It looks like this:&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
comparison operator. Needed for dynamically filtering the objects&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;param name="a"&amp;gt;A.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;param name="b"&amp;gt;The b.&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bool&lt;/span&gt; Like(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; a, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; b)
{ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; a.ToLower().Contains(b.ToLower());
} &lt;/span&gt;&lt;/pre&gt;Now I can do a search where I specify the property name, and it returns
and value of that property that contains any part of that string (and it is also case-insensitive).&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;List&amp;lt;Employee&amp;gt;
emps &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Employee.LoadListCollection();
List&amp;lt;Employee&amp;gt; empList &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; emps.ContainsString(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"FirstName"&lt;/span&gt;, &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"An"&lt;/span&gt;).ToList(); &lt;/span&gt;&lt;/pre&gt;Then
it occurred to me that I was specifying the name of the static routine in the call.
What would happen if I specified the name of the operator dynamically? Would it work
right? 
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;var
body &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Call( &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(BusinessObjectBase).GetMethod(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Like"&lt;/span&gt;,
BindingFlags.Static &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;|&lt;/span&gt; BindingFlags.NonPublic &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;|&lt;/span&gt; BindingFlags.Public), 
&lt;br&gt;
&lt;font size="2" face="Verdana"&gt;Became this:&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;var
body &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Call( &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(BusinessObjectBase).GetMethod(operatorName,
BindingFlags.Static &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;|&lt;/span&gt; BindingFlags.NonPublic &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;|&lt;/span&gt; BindingFlags.Public), &lt;/span&gt;&lt;/pre&gt;&lt;font size="2" face="Verdana"&gt;Now
I could create two static operators (or as many as I might ever need) to provide this
dynamic functionality.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt;
RunOperator&amp;lt;T&amp;gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt;
data, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; operatorName, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; propertyOrFieldName, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; searchValue)
{ var param &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Parameter(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(T), &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"x"&lt;/span&gt;);
var body &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Call( &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(BusinessObjectBase).GetMethod(operatorName,
BindingFlags.Static &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;|&lt;/span&gt; BindingFlags.NonPublic &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;|&lt;/span&gt; BindingFlags.Public),
Expression.PropertyOrField(param, propertyOrFieldName), Expression.Constant(searchValue, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt;)));
var lambda &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Lambda&amp;lt;Func&amp;lt;T, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bool&lt;/span&gt;&amp;gt;&amp;gt;(body,
param); &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; data.Where(lambda.Compile());
} &lt;/span&gt;&lt;/pre&gt;In my BusinessObjectBase class, I added the following methods (Like
for wildcard searches, and Equals for a case-insensitive search):&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bool&lt;/span&gt; Like(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; a, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; b)
{ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; a.ToLower().Contains(b.ToLower());
} &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bool&lt;/span&gt; Equals(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; a, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; b)
{ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; a.ToLower()
== b.ToLower(); } &lt;/span&gt;&lt;/pre&gt;I can call both of these methods like this:&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; List&amp;lt;T&amp;gt;
FilterData&amp;lt;T&amp;gt;(List&amp;lt;T&amp;gt; data, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bool&lt;/span&gt; wildcardSearch)
{ List&amp;lt;T&amp;gt; results &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; data; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (wildcardSearch)
results &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; results.RunOperator(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Like"&lt;/span&gt;,
fi.DataField, fi.FilterValue()).ToList(); &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;else&lt;/span&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;results &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; results.RunOperator(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"Equals"&lt;/span&gt;,
fi.DataField, fi.FilterValue()).ToList(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; results;
} &lt;/span&gt;&lt;/pre&gt;So let’s break it down a little. First, the first parameter of a lambda
expression, which is what we are building here, is the input parameter, or in this
case, the x portion of x =&amp;gt;.&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;var
param &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Parameter(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(T), &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"x"&lt;/span&gt;);&lt;/span&gt;&lt;/pre&gt;Next,
we’re setting up the call which is made to the right of the =&amp;gt; of the Lambda expression.
The code below is saying “grab the method name provided by the operatorName variable,
which can be found in any class which implements the BusinessObjectBase class.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;typeof&lt;/span&gt;(BusinessObjectBase).GetMethod(operatorName,&lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
The result of the expression defined above will be returning a boolean, as defined
here:&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;var
lambda &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; Expression.Lambda&amp;lt;Func&amp;lt;T, &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;bool&lt;/span&gt;&amp;gt;&amp;gt;(body,
param);&lt;/span&gt;&lt;/pre&gt;Finally, we return the data which evaluates in the lambda expression
as true via this line of code:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; data.Where(lambda.Compile());&lt;/span&gt;&lt;/pre&gt;Note
the delegate lambda expression is compiled into executrable code and produces a delegate
which represents the lambda expression.&lt;br&gt;
Obviously, understanding how to dynamically call methods and compare properties using
LINQ is extremely powerful and has many,many possibilities. I hope this helps someone
else trying to do the same thing!&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1aac1456-13df-443f-b660-27c38fd4eb49" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,1aac1456-13df-443f-b660-27c38fd4eb49.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=7d2750ec-eecd-4aac-ac3b-0f09da032d74</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,7d2750ec-eecd-4aac-ac3b-0f09da032d74.aspx</pingback:target>
      <dc:creator>Daryl</dc:creator>
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,7d2750ec-eecd-4aac-ac3b-0f09da032d74.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7d2750ec-eecd-4aac-ac3b-0f09da032d74</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Ever need to HTML Encode a string? This
useful extension method will do it for you:<pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
&lt;summary&gt;</span><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
Extension method to HTML encode any string characters with ASCII &gt; 127</span><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
&lt;/summary&gt;</span><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
&lt;param name="str"&gt;string to be encoded&lt;/param&gt;</span><span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;">///
&lt;returns&gt;Encoded string&lt;/returns&gt;</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">public</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">static</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> ToHtml(<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">this</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span> str)
{ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">return</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">string</span>.Join(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">""</span>,
str.ToCharArray().Select(c =&gt; (<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">int</span>)c
&gt; 127 ? <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">"&amp;#"</span><span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">+</span> (<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">int</span>)c <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">+</span><span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;">";"</span> :
c.ToString()).ToArray()); } </span></pre><br /><br /><br /><br /><br /><p></p><img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7d2750ec-eecd-4aac-ac3b-0f09da032d74" /></body>
      <title>Tip of the Day: An extension method to HTML encode a string</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,7d2750ec-eecd-4aac-ac3b-0f09da032d74.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/08/05/TipOfTheDayAnExtensionMethodToHTMLEncodeAString.aspx</link>
      <pubDate>Thu, 05 Aug 2010 01:39:30 GMT</pubDate>
      <description>Ever need to HTML Encode a string? This useful extension method will do it for you:&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
Extension method to HTML encode any string characters with ASCII &amp;gt; 127&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;param name="str"&amp;gt;string to be encoded&amp;lt;/param&amp;gt;&lt;/span&gt; &lt;span style="color: Green; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;///
&amp;lt;returns&amp;gt;Encoded string&amp;lt;/returns&amp;gt;&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;public&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;static&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; ToHtml(&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;this&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt; str)
{ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;return&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;string&lt;/span&gt;.Join(&lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;""&lt;/span&gt;,
str.ToCharArray().Select(c =&amp;gt; (&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;int&lt;/span&gt;)c
&amp;gt; 127 ? &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;"&amp;amp;#"&lt;/span&gt; &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;+&lt;/span&gt; (&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;int&lt;/span&gt;)c &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;+&lt;/span&gt; &lt;span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: Courier New; font-size: 11px;"&gt;";"&lt;/span&gt; :
c.ToString()).ToArray()); } &lt;/span&gt;&lt;/pre&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7d2750ec-eecd-4aac-ac3b-0f09da032d74" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,7d2750ec-eecd-4aac-ac3b-0f09da032d74.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=204ee18d-4d55-41b1-8ad6-9cbbb083cd37</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,204ee18d-4d55-41b1-8ad6-9cbbb083cd37.aspx</pingback:target>
      <dc:creator>Daryl</dc:creator>
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,204ee18d-4d55-41b1-8ad6-9cbbb083cd37.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=204ee18d-4d55-41b1-8ad6-9cbbb083cd37</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">The project I am currently working on is
a port from a horribly over-engineered Oracle system to a much more manageable SQL
Server system. One of the things we needed to do was rename a lot of fields to something
more usable. For instance, every table had a field titled "Ended" but we felt it was
easier to think of that record as "Deleted". Rather than go through every table (and
it wasn't in every table, meaning you needed to manually check each one to verify),
I opted a scripting solution.<br /><br />
Below is a T-SQL script which will generate the sp_rename scripts for all the tables
where the target field is found. A job which would have taken hours and been prone
to errors is now a simple task taking a minute.<br /><br /><pre><span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">DECLARE</span> @OldFieldName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">VARCHAR</span>(50),
@NewFieldName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">VARCHAR</span>(50) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">SET</span> @OldFieldName
= <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'SomeOldFieldName'</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">SET</span> @NewFieldName
= <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'MyNewFieldName'</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">select</span><span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'sp_RENAME
'</span> + <span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">CHAR</span>(39)
+ <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'OFC.'</span> +
TABLE_NAME + <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'.'</span> +
@OldFieldName + <span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">CHAR</span>(39)
+ <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">',
'</span> + <span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">CHAR</span>(39)
+ @NewFieldName + <span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">CHAR</span>(39)
+ <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">','</span> + <span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">CHAR</span>(39)
+ <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'COLUMN'</span> + <span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">CHAR</span>(39)
+ <span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">CHAR</span>(10)
+ <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">'GO'</span> + <span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;">CHAR</span>(10) <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">from</span> INFORMATION_SCHEMA.COLUMNS <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">WHERE</span> COLUMN_NAME
= @OldFieldName <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">ORDER</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">BY</span> TABLE_NAME</span></pre>The
script above will generate the T-SQL code to rename any field SomeOldFieldName to
MyNewFieldName. Run it, and then run the generated script.<br /><br />
Given this and CodeSmith, can you tell I enjoy scripting work?<br /><p></p><img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=204ee18d-4d55-41b1-8ad6-9cbbb083cd37" /></body>
      <title>Tip of the Day: T-SQL Script to rename bulk columns</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,204ee18d-4d55-41b1-8ad6-9cbbb083cd37.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/08/04/TipOfTheDayTSQLScriptToRenameBulkColumns.aspx</link>
      <pubDate>Wed, 04 Aug 2010 04:22:15 GMT</pubDate>
      <description>The project I am currently working on is a port from a horribly over-engineered Oracle system to a much more manageable SQL Server system. One of the things we needed to do was rename a lot of fields to something more usable. For instance, every table had a field titled "Ended" but we felt it was easier to think of that record as "Deleted". Rather than go through every table (and it wasn't in every table, meaning you needed to manually check each one to verify), I opted a scripting solution.&lt;br&gt;
&lt;br&gt;
Below is a T-SQL script which will generate the sp_rename scripts for all the tables
where the target field is found. A job which would have taken hours and been prone
to errors is now a simple task taking a minute.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;DECLARE&lt;/span&gt; @OldFieldName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;VARCHAR&lt;/span&gt;(50),
@NewFieldName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;VARCHAR&lt;/span&gt;(50) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;SET&lt;/span&gt; @OldFieldName
= &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'SomeOldFieldName'&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;SET&lt;/span&gt; @NewFieldName
= &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'MyNewFieldName'&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;select&lt;/span&gt; &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'sp_RENAME
'&lt;/span&gt; + &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;CHAR&lt;/span&gt;(39)
+ &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'OFC.'&lt;/span&gt; +
TABLE_NAME + &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'.'&lt;/span&gt; +
@OldFieldName + &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;CHAR&lt;/span&gt;(39)
+ &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;',
'&lt;/span&gt; + &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;CHAR&lt;/span&gt;(39)
+ @NewFieldName + &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;CHAR&lt;/span&gt;(39)
+ &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;','&lt;/span&gt; + &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;CHAR&lt;/span&gt;(39)
+ &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'COLUMN'&lt;/span&gt; + &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;CHAR&lt;/span&gt;(39)
+ &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;CHAR&lt;/span&gt;(10)
+ &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;'GO'&lt;/span&gt; + &lt;span style="color: Fuchsia; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;CHAR&lt;/span&gt;(10) &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;from&lt;/span&gt; INFORMATION_SCHEMA.COLUMNS &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;WHERE&lt;/span&gt; COLUMN_NAME
= @OldFieldName &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ORDER&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;BY&lt;/span&gt; TABLE_NAME&lt;/span&gt;&lt;/pre&gt;The
script above will generate the T-SQL code to rename any field SomeOldFieldName to
MyNewFieldName. Run it, and then run the generated script.&lt;br&gt;
&lt;br&gt;
Given this and CodeSmith, can you tell I enjoy scripting work?&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=204ee18d-4d55-41b1-8ad6-9cbbb083cd37" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,204ee18d-4d55-41b1-8ad6-9cbbb083cd37.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=1b1a5647-ec5f-4480-9708-f51c7d6e1f05</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,1b1a5647-ec5f-4480-9708-f51c7d6e1f05.aspx</pingback:target>
      <dc:creator>Daryl</dc:creator>
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,1b1a5647-ec5f-4480-9708-f51c7d6e1f05.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1b1a5647-ec5f-4480-9708-f51c7d6e1f05</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today I was setting up a new template, and I needed to look at the unique constraints
as part of my task.
</p>
        <p>
The following CodeSmith script will load the columns that have unique constraints
(but not the primary key) into an ArrayList.
</p>
        <code>
          <pre>
            <span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;">ArrayList
uniqueColumns <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span><span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">new</span> ArrayList(); <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">for</span> (<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">int</span> i <span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;">=</span> 0;
i &lt; SourceTable.Indexes.Count; i++) { <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (SourceTable.Indexes[i].IsUnique)
{ <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">for</span> (<span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">int</span> y=0;
y &lt; SourceTable.Indexes[i].MemberColumns.Count; y++) { <span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;">if</span> (!SourceTable.Indexes[i].MemberColumns[y].IsPrimaryKeyMember)
uniqueColumns.Add(SourceTable.Indexes[i].MemberColumns[y].Name); } } }</span>
          </pre>
        </code>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1b1a5647-ec5f-4480-9708-f51c7d6e1f05" />
      </body>
      <title>Tip of the Day: CodeSmith - Retrieve the unique columns from a table</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,1b1a5647-ec5f-4480-9708-f51c7d6e1f05.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/08/03/TipOfTheDayCodeSmithRetrieveTheUniqueColumnsFromATable.aspx</link>
      <pubDate>Tue, 03 Aug 2010 05:13:07 GMT</pubDate>
      <description>&lt;p&gt;
Today I was setting up a new template, and I needed to look at the unique constraints
as part of my task.
&lt;/p&gt;
&lt;p&gt;
The following CodeSmith script will load the columns that have unique constraints
(but not the primary key) into an ArrayList.
&lt;/p&gt;
&lt;code&gt; &lt;pre&gt;&lt;span style="color: Black; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;ArrayList
uniqueColumns &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;new&lt;/span&gt; ArrayList(); &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;for&lt;/span&gt; (&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;int&lt;/span&gt; i &lt;span style="color: Red; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;=&lt;/span&gt; 0;
i &amp;lt; SourceTable.Indexes.Count; i++) { &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (SourceTable.Indexes[i].IsUnique)
{ &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;for&lt;/span&gt; (&lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;int&lt;/span&gt; y=0;
y &amp;lt; SourceTable.Indexes[i].MemberColumns.Count; y++) { &lt;span style="color: Blue; background-color: transparent; font-family: Courier New; font-size: 11px;"&gt;if&lt;/span&gt; (!SourceTable.Indexes[i].MemberColumns[y].IsPrimaryKeyMember)
uniqueColumns.Add(SourceTable.Indexes[i].MemberColumns[y].Name); } } }&lt;/span&gt;&lt;/pre&gt;&lt;/code&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1b1a5647-ec5f-4480-9708-f51c7d6e1f05" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,1b1a5647-ec5f-4480-9708-f51c7d6e1f05.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=10f8e5e3-811d-42d4-af1c-7e1243316a01</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,10f8e5e3-811d-42d4-af1c-7e1243316a01.aspx</pingback:target>
      <dc:creator>Daryl</dc:creator>
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,10f8e5e3-811d-42d4-af1c-7e1243316a01.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=10f8e5e3-811d-42d4-af1c-7e1243316a01</wfw:commentRss>
      <title>Upgraded das Blog and Hosts</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,10f8e5e3-811d-42d4-af1c-7e1243316a01.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/07/28/UpgradedDasBlogAndHosts.aspx</link>
      <pubDate>Wed, 28 Jul 2010 18:58:20 GMT</pubDate>
      <description>Recently, my shared hosting provider decided to "upgrade" their
system, and in the process it pretty much decimated my web sites. I
managed to get content back up, but nothing much works, and I just
haven't had time to rectify that, starting with switching hosts. I
have slowly started migrating things to the new host, and last night
finally got around to upgrading das Blog and moving that site over.
There were a few glitches, but my new host resolved them fairly
quickly, and now I can start taking care of my backlog of posts I have
earmarked for writing about.

&lt;br&gt;
&lt;br&gt;
It's been a busy few months, and the biggest achievement has been cashing at the WSOP
this year. I almost did it twice even! 
&lt;br&gt;
&lt;br&gt;
Now it's time to focus on the business and my technical skills again. The nice thing
is that I finally got around to setting it up to allow me to blog from email, which
makes it a LOT more convenient to post things, as I always have email handy. A lot
has been going on, and some of the things I need to update: 
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
Updating content from my main business site, &lt;a href="http://www.rubiconcomputing.com" target="_blank"&gt;Rubicon
Computing Solutions, LLC&lt;/a&gt;
&lt;http: www.rubiconcomputing.com=""&gt;
&lt;a href="http://tempuri.org/tempuri.html"&gt;&lt;/a&gt;(still need to migrate it so I can update
the content) 
&lt;br&gt;
&lt;/http:&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;http: www.rubiconcomputing.com=""&gt;Technical ScreeningsPossible technical interviewing skills seminar
(working with a local recruiting firm to help put something
together)&lt;/http:&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;http: www.rubiconcomputing.com=""&gt;Tips of the Day&lt;/http:&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;http: www.rubiconcomputing.com=""&gt;New tools and links which are cool (so need to
get the Rubicon site working again to post these) &lt;br&gt;
&lt;/http:&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;http: www.rubiconcomputing.com=""&gt;&lt;/http:&gt;
&lt;br&gt;
&lt;http: www.rubiconcomputing.com=""&gt;I am hoping this weekend I can make the time to get these moving
again. So welcome to the updated blog!&lt;/http:&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=10f8e5e3-811d-42d4-af1c-7e1243316a01" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,10f8e5e3-811d-42d4-af1c-7e1243316a01.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=f32c9c96-4f69-4cb0-8638-85ffbcb0f9ad</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,f32c9c96-4f69-4cb0-8638-85ffbcb0f9ad.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,f32c9c96-4f69-4cb0-8638-85ffbcb0f9ad.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f32c9c96-4f69-4cb0-8638-85ffbcb0f9ad</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently, I posted a <a href="http://www.dotnettechnologies.com/PermaLink,guid,8df6f658-9820-485e-a7f9-1a9a970bd4ce.aspx" target="_blank">script</a> which
would identify all the procedures which did not have appropriate permissions set,
which is great for last minute deployment checks. I realized I needed to explore INFORMATION_SCHEMA
closer as there is a LOT of useful metadata about the database available. Today's
tip is about some of that useful information.
</p>
        <p>
INFORMATION_SCHEMA is a specia schema which contains several views of the database
metadata. Previous to these views, database developers were forced to join on several
sys tables. Many of my earlier scripts for example rely on this method. However, in
SQL Server 2005 system views were provided which made this task significantly easier.
Here's some of the more useful views to look at. Explore them with code like this
and see what they contain.
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> * <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> INFORMATION_SCHEMA.COLUMNS</span>
        </p>
        <p>
I have found the following most useful, although in truth I suspect over time I will
have use for all of them.
</p>
        <p>
COLUMNS --&gt; I frequently use this to find what tables a particular column name
is found in
</p>
        <p>
CONSTRAINT_COLUMN_USAGE --&gt; identify what keys (primary, foreign) are defined,
and on what fields
</p>
        <p>
ROUTINES --&gt; allows me to explore procedures and functions using this
view
</p>
        <p>
TABLES --&gt; Get information about the various tables in the database
</p>
        <p>
VIEW_COLUMN_USAGE --&gt; obtain information on the fields the view contains
</p>
        <p>
Here's a good link where you can find more information on the <a href="http://msdn.microsoft.com/en-us/library/ms186778.aspx" target="_blank">INFORMATION_SCHEMA</a>.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=f32c9c96-4f69-4cb0-8638-85ffbcb0f9ad" />
      </body>
      <title>Tip of the Day: More useful information on INFORMATION_SCHEMA</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,f32c9c96-4f69-4cb0-8638-85ffbcb0f9ad.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/03/11/TipOfTheDayMoreUsefulInformationOnINFORMATIONSCHEMA.aspx</link>
      <pubDate>Thu, 11 Mar 2010 04:02:00 GMT</pubDate>
      <description>&lt;p&gt;
Recently, I posted a &lt;a href="http://www.dotnettechnologies.com/PermaLink,guid,8df6f658-9820-485e-a7f9-1a9a970bd4ce.aspx" target=_blank&gt;script&lt;/a&gt; which
would identify all the procedures which did not have appropriate permissions set,
which is great for last minute deployment checks. I realized I needed to explore INFORMATION_SCHEMA
closer as there is a LOT of useful metadata about the database available. Today's
tip is about some of that useful information.
&lt;/p&gt;
&lt;p&gt;
INFORMATION_SCHEMA is a specia schema which contains several views of the database
metadata. Previous to these views, database developers were forced to join on several
sys tables. Many of my earlier scripts for example rely on this method. However, in
SQL Server 2005 system views were provided which made this task significantly easier.
Here's some of the more useful views to look at. Explore them with code like this
and see what they contain.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; * &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; INFORMATION_SCHEMA.COLUMNS&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
I have found the following most useful, although in truth I suspect over time I will
have use for all of them.
&lt;/p&gt;
&lt;p&gt;
COLUMNS --&amp;gt; I frequently use this to find what tables a particular column name
is found in
&lt;/p&gt;
&lt;p&gt;
CONSTRAINT_COLUMN_USAGE --&amp;gt; identify what keys (primary, foreign) are defined,
and on what fields
&lt;/p&gt;
&lt;p&gt;
ROUTINES --&amp;gt;&amp;nbsp;allows me to explore&amp;nbsp;procedures and functions using this
view
&lt;/p&gt;
&lt;p&gt;
TABLES --&amp;gt; Get information about the various tables in the database
&lt;/p&gt;
&lt;p&gt;
VIEW_COLUMN_USAGE --&amp;gt; obtain information on the fields the view contains
&lt;/p&gt;
&lt;p&gt;
Here's a good link where you can find more information on the &lt;a href="http://msdn.microsoft.com/en-us/library/ms186778.aspx" target=_blank&gt;INFORMATION_SCHEMA&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=f32c9c96-4f69-4cb0-8638-85ffbcb0f9ad" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,f32c9c96-4f69-4cb0-8638-85ffbcb0f9ad.aspx</comments>
      <category>All Things</category>
      <category>Design</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=0d18348c-5a86-46e9-ac63-ec742f62a8b7</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,0d18348c-5a86-46e9-ac63-ec742f62a8b7.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,0d18348c-5a86-46e9-ac63-ec742f62a8b7.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0d18348c-5a86-46e9-ac63-ec742f62a8b7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">As
I was walking around today, I noticed one of the managers had a book about employee
retention and it really struck home with me.<span style="mso-spacerun: yes">  </span>This
particular book, at least from the title, looked to be about retaining key people
(and a follow up search in Amazon verified this) with “love”.</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">Way
back in early 2000’s, we had this thing called the “dot-com boom” followed up by the
“dot-com bust”.<span style="mso-spacerun: yes">  </span>I say way back because
so much has changed in the last 10 years, a lot of people may have forgotten how development
has changed in that time.<span style="mso-spacerun: yes">  </span>The market
went from people making exorbitant hourly wages and stock options to a dramatic shift
of struggling to even find a job. I was very fortunate as a contractor as I took less
than a 10% rate cut and didn’t have one day of bench time. </font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">Most
of the other independent contractors weren’t that fortunate. Many took catastrophic
pay cuts which dramatically altered their lifestyles. Others left IT altogether.<span style="mso-spacerun: yes">  </span>The
developer market was insane during the “dot-com boom”, so in my opinion it needed
a correction.</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">On
the flip side, I saw employers taking advantage of the situation. In one example,
a friend of mine gave up contracting, and took a contract-to-hire position. After
the end of three months, he was scheduled to hire at a certain wage. He worked his
contract, but when it came time to hire him, they revised his offer to about $10,000
less than the original offer. It wasn’t a performance issue, and they bluntly told
him that. When they revised the offer, they advised him they made the change because
the market was poor, and they knew it would be difficult for him to find another job.</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">The
manager who did this and I had a decent relationship, and I pulled him aside to discuss
it. He verified they were changing the original offer on all offers which had not
been completed “because they could”. My warning to him was that, while his reason
is correct, the market would eventually change, and those same people would be the
first to leave.<span style="mso-spacerun: yes">  </span>Time proved me correct.</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">I
am a student of history. One of my favorite quotes is as follows:</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">"Those
who cannot remember the past are condemned to repeat it." -- George Santayana</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">Fly
forward 10 years, and again we have a market with developers struggling to find jobs,
having to take large pay cuts, and management taking advantage of it. Last year, I
was the development manager for a large financial institution with a decent sized
team. We had a huge conversion going on, and we had to convert 58 applications in
six months. Since a lot of the applications were forward facing, we could afford no
errors. Fortunately, I had the right team to do it.</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">Through
incredible dedication our team was successful.<span style="mso-spacerun: yes">  </span>During
this conversion, I began to notice a disturbing trend from senior management. It began
by demanding reports of hours spent working by individual employees.<span style="mso-spacerun: yes">  </span>No
attention was paid to *what* they were working on or the results of their efforts,
but rather how much they were working.<span style="mso-spacerun: yes">  </span>It
was interesting to note that contract employees were not pressured about their hours,
as their hours were all billable. </font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font size="3">
            <font color="#000000">
              <span style="FONT-FAMILY: 'Calibri','sans-serif'">Fortunately,
I am very results driven. After my team submitted their reports, I “adjusted” their
reported time (note: this was not used for ANYTHING other than to see who is working
and who was not – I wrote the application that did this reporting) so it would keep
the team in good graces. My philosophy<span style="mso-spacerun: yes">  has proved
to </span>work every time </span>
              <span style="FONT-FAMILY: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-char-type: symbol; mso-symbol-font-family: Wingdings">
                <span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</span>
              </span>
              <span style="FONT-FAMILY: 'Calibri','sans-serif'"> do
your job, do it on time, and do it with quality. If it takes you 80 hours to do it,
so be it, but I will make sure you are taken care of. If you can do it in 40, all
the better. I know in Extreme programming they hold it to 8 hours maximum per day,
but I was never a huge advocate of XP.</span>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">The
trend with senior management continued, and they began monitoring network traffic.
Management now wanted reports, by department and employee, of where employees were
going on the internet and how long they spent there.<span style="mso-spacerun: yes">  </span>I
met daily with the other IT managers, and I was the only manager who openly opposed
this. The main reason they remained silent was because they had access to
the logs and could “filter” the reports to senior management. Senior management’s
stated belief is that every minute spent on the web was one minute lost of productivity.
Don't even get me started on the studies which disprove this.</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font size="3">
            <font color="#000000">
              <span style="FONT-FAMILY: 'Calibri','sans-serif'">Their
original strategy was going to block all internet activity (except senior management).
When I pointed out basic points like looking for code and solutions on the internet
was critical to development, this movement lost steam. However, that’s when the reports
started.<span style="mso-spacerun: yes">  </span>I knew my time was limited there
when I received my inquisition about my team's activites </span>
              <span style="FONT-FAMILY: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-char-type: symbol; mso-symbol-font-family: Wingdings">
                <span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</span>
              </span>
              <span style="FONT-FAMILY: 'Calibri','sans-serif'"> one
employee had watched CNN from his laptop at 9 PM (while working from home) and another
had paid his bills online (after working an 80+ hour week).</span>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">These
same managers would call all the employees in to tell them there would be no raises,
a decrease in benefits and reduced time off. Granted, the institution was taking some
charge-offs on loans, but from an accounting standpoint, the merit increases would
not have impacted the balance sheets significantly compared to other expenditures
being made.<span style="mso-spacerun: yes">  </span>In the same meetings, they’d
press for more hours of productivity (regardless of status of their projects).
In every case, the team was told “the market out there is rough. If you don’t like
it here, go ahead and look, you won’t find anything.”</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">My
department successfully completed the conversion with few problems, none of them critical.
Fortunately, I saw things were getting worse, and I left that company for another
immediately after the conversion, feeling I had met my obligation to my employer as
well as my team. I stay in touch, and I hear my team was singled out in a post-conversion
"pep rally". The team had been working 70+ hours on average for over six months for
the conversion, probably more than any other team, and most projects were complete
and things had slowed down. A senior manager told my old team directly: “If you’re
not working 65 hours every week, you’re not pulling your weight.<span style="mso-spacerun: yes">  </span>I
can hire replacements for you right now at 70% of your salaries.” </font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">I
wish that kind of attitude was isolated. The next company I went to had a worse attitude
towards employees. On my first day as their new development manager, I was told by
their very inexperienced VP of Technology “it’s good to fire people here and there
to keep the others on their toes. It’s healthy.” Although there is some distant truth
to that statement, it’s also dangerous and naïve as well.</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">The
point of all this background is that history is going to repeat itself. Take the financial
company I mentioned. Even in this economy, several key people have already left. Many
others have openly stated they will leave as soon as they can.</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">The
book I first mentioned had it right: if you want to keep your employees, you need
to show them your love. Regardless of the economy, your key team members will stay
as there is more to work than just salary. If you lose a GOOD employee, you stand
to lose a lot. For example:</font>
          </span>
        </p>
        <p class="MsoListParagraph" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <font size="3">·</font>
            </span>
            <span style="FONT-SIZE: 7pt; mso-fareast-font-family: Symbol">
              <font face="Times New Roman">         </font>
            </span>
            <span style="FONT-FAMILY: 'Calibri','sans-serif'">
              <font size="3">Cohesion
of the team</font>
            </span>
          </font>
        </p>
        <p class="MsoListParagraph" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <font size="3">·</font>
            </span>
            <span style="FONT-SIZE: 7pt; mso-fareast-font-family: Symbol">
              <font face="Times New Roman">         </font>
            </span>
            <span style="FONT-FAMILY: 'Calibri','sans-serif'">
              <font size="3">Legacy
knowledge that only time and experience can bring</font>
            </span>
          </font>
        </p>
        <p class="MsoListParagraph" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <font size="3">·</font>
            </span>
            <span style="FONT-SIZE: 7pt; mso-fareast-font-family: Symbol">
              <font face="Times New Roman">         </font>
            </span>
            <span style="FONT-FAMILY: 'Calibri','sans-serif'">
              <font size="3">Coding
standards – you can have these written, but it takes time and reviews to “train” employees
on how things should be done. They leave, you lose this.</font>
            </span>
          </font>
        </p>
        <p class="MsoListParagraph" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <font size="3">·</font>
            </span>
            <span style="FONT-SIZE: 7pt; mso-fareast-font-family: Symbol">
              <font face="Times New Roman">         </font>
            </span>
            <span style="FONT-FAMILY: 'Calibri','sans-serif'">
              <font size="3">Investment
– good employers invert in their team. This can include training, goodwill or any
of a number of tangible and intangible investments made on the team. When you lose
a team member, you lose that investment.</font>
            </span>
          </font>
        </p>
        <p class="MsoListParagraph" style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <font size="3">·</font>
            </span>
            <span style="FONT-SIZE: 7pt; mso-fareast-font-family: Symbol">
              <font face="Times New Roman">         </font>
            </span>
            <span style="FONT-FAMILY: 'Calibri','sans-serif'">
              <font size="3">Loyalty
&amp; trust</font>
            </span>
          </font>
        </p>
        <p class="MsoListParagraph" style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in">
          <font color="#000000" size="3">
            <span style="FONT-FAMILY: 'Calibri','sans-serif'">Sure
you can hire new developers, but finding good ones is an art. Will you be improving
by replacing your current team? There is certainly a cost associated with it.</span>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">It’s
not all about salary either. Many times I didn’t have the budget to pay my team what
I felt they were worth or even what they could get on the open market. I kept them
happy by allowing them the ability to create innovative solutions, be part of the
“bigger direction” of the team, and keeping their skills current as the technology
changed. All this is part of the “love” a good manager can easily give his team.</font>
          </span>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <span style="FONT-FAMILY: 'Calibri','sans-serif'">
            <font color="#000000" size="3">After
the first “dot-com bust” resolved itself, that first employer I mentioned lost 100%
of their team over the first year the economy recovered. I am afraid history will
be repeating itself just as harsh this time. </font>
          </span>
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0d18348c-5a86-46e9-ac63-ec742f62a8b7" />
      </body>
      <title>Opinion: Giving your employees some love (or else!)</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,0d18348c-5a86-46e9-ac63-ec742f62a8b7.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/03/10/OpinionGivingYourEmployeesSomeLoveOrElse.aspx</link>
      <pubDate>Wed, 10 Mar 2010 03:18:49 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;As I
was walking around today, I noticed one of the managers had a book about employee
retention and it really struck home with me.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;This
particular book, at least from the title, looked to be about retaining key people
(and a follow up search in Amazon verified this) with “love”.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;Way back
in early 2000’s, we had this thing called the “dot-com boom” followed up by the “dot-com
bust”.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I say way back because so much
has changed in the last 10 years, a lot of people may have forgotten how development
has&amp;nbsp;changed in that time.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The market
went from people making exorbitant hourly wages and stock options to a dramatic shift
of struggling to even find a job. I was very fortunate as a contractor as I took less
than a 10% rate cut and didn’t have one day of bench time. &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;Most
of the other independent contractors weren’t that fortunate. Many took catastrophic
pay cuts which dramatically altered their lifestyles. Others left IT altogether.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The
developer market was insane during the “dot-com boom”, so in my opinion it needed
a correction.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;On the
flip side, I saw employers taking advantage of the situation. In one example, a friend
of mine gave up contracting, and took a contract-to-hire position. After the end of
three months, he was scheduled to hire at a certain wage. He worked his contract,
but when it came time to hire him, they revised his offer to about $10,000 less than
the original offer. It wasn’t a performance issue, and they bluntly told him that.
When they revised the offer, they advised him they made the change because the market
was poor, and they knew it would be difficult for him to find another job.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;The manager
who did this and I had a decent relationship, and I pulled him aside to discuss it.
He verified they were changing the original offer on all offers which had not been
completed “because they could”. My warning to him was that, while his reason is correct,
the market would eventually change, and those same people would be the first to leave.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Time
proved me correct.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;I am
a student of history. One of my favorite quotes is as follows:&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;"Those
who cannot remember the past are condemned to repeat it." -- George Santayana&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;Fly forward
10 years, and again we have a market with developers struggling to find jobs, having
to take large pay cuts, and management taking advantage of it. Last year, I was the
development manager for a large financial institution with a decent sized team. We
had a huge conversion going on, and we had to convert 58 applications in six months.
Since a lot of the applications were forward facing, we could afford no errors. Fortunately,
I had the right team to do it.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;Through
incredible dedication our team was successful.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;During
this conversion, I began to notice a disturbing trend from senior management. It began
by demanding reports of hours spent working by individual employees.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;No
attention was paid to *what* they were working on or the results of their efforts,
but rather how much they were working.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;It
was interesting to note that contract employees were not pressured about their hours,
as their hours were all billable. &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;Fortunately,
I am very results driven. After my team submitted their reports, I “adjusted” their
reported time (note: this was not used for ANYTHING other than to see who is working
and who was not – I wrote the application that did this reporting) so it would keep
the team in good graces. My philosophy&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; has proved
to &lt;/span&gt;work every time &lt;/span&gt;&lt;span style="FONT-FAMILY: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;à&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt; do
your job, do it on time, and do it with quality. If it takes you 80 hours to do it,
so be it, but I will make sure you are taken care of. If you can do it in 40, all
the better. I know in Extreme programming they hold it to 8 hours maximum per day,
but I was never a huge advocate of XP.&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;The trend
with senior management continued, and they began monitoring network traffic. Management
now wanted reports, by department and employee, of where employees were going on the
internet and how long they spent there.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I
met daily with the other IT managers, and I was the only manager who openly opposed
this. The main reason they&amp;nbsp;remained silent&amp;nbsp;was because they had access to
the logs and could “filter” the reports to senior management. Senior management’s
stated belief is that every minute spent on the web was one minute lost of productivity.
Don't even get me started on the studies which disprove this.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;Their
original strategy was going to block all internet activity (except senior management).
When I pointed out basic points like looking for code and solutions on the internet
was critical to development, this movement lost steam. However, that’s when the reports
started.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I knew my time was limited there
when I received my inquisition about my team's activites&amp;nbsp;&lt;/span&gt;&lt;span style="FONT-FAMILY: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;à&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt; one
employee had watched CNN from his laptop at 9 PM (while working from home) and another
had paid his bills online (after working an 80+ hour week).&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;These
same managers would call all the employees in to tell them there would be no raises,
a decrease in benefits and reduced time off. Granted, the institution was taking some
charge-offs on loans, but from an accounting standpoint, the merit increases would
not have impacted the balance sheets significantly compared to other expenditures
being made.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;In the same meetings, they’d
press for more hours of productivity (regardless of&amp;nbsp;status of&amp;nbsp;their projects).
In every case, the team was told “the market out there is rough. If you don’t like
it here, go ahead and look, you won’t find anything.”&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;My department
successfully completed the conversion with few problems, none of them critical. Fortunately,
I saw things were getting worse, and I left that company for another immediately after
the conversion, feeling I had met my obligation to my employer as well as my team.
I stay in touch, and I hear my team was singled out in a post-conversion "pep rally".
The team had been working 70+ hours on average for over six months for the conversion,
probably more than any other team, and most projects were complete and things had
slowed down. A senior manager told my old team directly: “If you’re not working 65
hours every week, you’re not pulling your weight.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;I
can hire replacements for you right now at 70% of your salaries.” &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;I wish
that kind of attitude was isolated. The next company I went to had a worse attitude
towards employees. On my first day as their new development manager, I was told by
their very inexperienced VP of Technology “it’s good to fire people here and there
to keep the others on their toes. It’s healthy.” Although there is some distant truth
to that statement, it’s also dangerous and naïve as well.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;The point
of all this background is that history is going to repeat itself. Take the financial
company I mentioned. Even in this economy, several key people have already left. Many
others have openly stated they will leave as soon as they can.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;The book
I first mentioned had it right: if you want to keep your employees, you need to show
them your love. Regardless of the economy, your key team members will stay as there
is more to work than just salary. If you lose a GOOD employee, you stand to lose a
lot. For example:&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 7pt; mso-fareast-font-family: Symbol"&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font size=3&gt;Cohesion
of the team&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 7pt; mso-fareast-font-family: Symbol"&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font size=3&gt;Legacy
knowledge that only time and experience can bring&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 7pt; mso-fareast-font-family: Symbol"&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font size=3&gt;Coding
standards – you can have these written, but it takes time and reviews to “train” employees
on how things should be done. They leave, you lose this.&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraph style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 7pt; mso-fareast-font-family: Symbol"&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font size=3&gt;Investment
– good employers invert in their team. This can include training, goodwill or any
of a number of tangible and intangible investments made on the team. When you lose
a team member, you lose that investment.&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 7pt; mso-fareast-font-family: Symbol"&gt;&lt;font face="Times New Roman"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font size=3&gt;Loyalty
&amp;amp; trust&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraph style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;font color=#000000 size=3&gt;&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;Sure
you can hire new developers, but finding good ones is an art. Will you be improving
by replacing your current team? There is certainly a cost associated with it.&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;It’s
not all about salary either. Many times I didn’t have the budget to pay my team what
I felt they were worth or even what they could get on the open market. I kept them
happy by allowing them the ability to create innovative solutions, be part of the
“bigger direction” of the team, and keeping their skills current as the technology
changed. All this is part of the “love” a good manager can easily give his team.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-FAMILY: 'Calibri','sans-serif'"&gt;&lt;font color=#000000 size=3&gt;After
the first “dot-com bust” resolved itself, that first employer I mentioned lost 100%
of their team over the first year the economy recovered. I am afraid history will
be repeating itself just as harsh this time. &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0d18348c-5a86-46e9-ac63-ec742f62a8b7" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,0d18348c-5a86-46e9-ac63-ec742f62a8b7.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=8df6f658-9820-485e-a7f9-1a9a970bd4ce</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,8df6f658-9820-485e-a7f9-1a9a970bd4ce.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,8df6f658-9820-485e-a7f9-1a9a970bd4ce.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8df6f658-9820-485e-a7f9-1a9a970bd4ce</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Creating a script to grant execute to stored procedures where none exist<br />
 <br />
It’s very common to forget to script out permissions for a stored procedure when generating
the script. There’s nothing more frustrating than deploying some code changes, only
to have them not work because you have elevated security on your development SQL Server,
but not on QA or Production. If you find one, likely you’ll find it several places.
How do you quickly locate the procedures which don’t have the desired permission set?
Better yet, how do you fix it quickly without writing a lot of script or manually
setting the permissions in SQL Server Management Studio?
</p>
        <p>
          <br />
The script below is one I pulled off the internet (<a href="http://sqlfool.com/story/46/date-posted/06-06-0939/" target="blank">http://sqlfool.com/story/46/date-posted/06-06-0939/</a>)
and modified a little. Since the environment I am in now uses multiple schemas, I
added the ability to specify schema to search for. 
</p>
        <p>
          <br />
Here’s the script:
</p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <p>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @role <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(50) 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @targetSchema <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">VARCHAR</span>(50)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span> @targetSchema
= <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'dbo'</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span> @role
= <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'MyUser'</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'GRANT
EXECUTE ON '</span> + SPECIFIC_SCHEMA + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'.['</span> +
SPECIFIC_NAME + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">']
TO '</span> + @role + <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CHAR</span>(10)
+ <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'GO'</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> INFORMATION_SCHEMA.ROUTINES <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WITH</span> (NoLock)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> SPECIFIC_NAME <span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Not</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">In</span><br />
(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> o.name <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> sys.database_permissions
p <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WITH</span> (NoLock) 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">INNER</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Join</span> sys.objects
o <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WITH</span> (NoLock) 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ON</span> p.major_id
= o.<span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">OBJECT_ID</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">INNER</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Join</span> sys.database_principals
u <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WITH</span> (NoLock) 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ON</span> u.principal_id
= p.grantee_principal_id 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> u.name
= @role)<br /><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AND</span> ROUTINE_TYPE
= <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'PROCEDURE'</span><br /><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AND</span> SPECIFIC_NAME <span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">not</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">like</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'sp_%'</span><br /><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AND</span> SPECIFIC_SCHEMA
= @targetSchema<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ORDER</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BY</span> SPECIFIC_NAME
</p>
          <p>
            <font face="Verdana" size="2">Just change the @targetSchema and @role variables and
run it. The results will be a list of procedures on the current database which don’t
have execute permissions assigned to the indicated @role. You can then copy those
procs you want to grant execute on into the query window and execute them.<br /></font>
          </p>
        </span>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=8df6f658-9820-485e-a7f9-1a9a970bd4ce" />
      </body>
      <title>Tip of the Day: Locating scripts without execute permissions set</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,8df6f658-9820-485e-a7f9-1a9a970bd4ce.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/03/05/TipOfTheDayLocatingScriptsWithoutExecutePermissionsSet.aspx</link>
      <pubDate>Fri, 05 Mar 2010 04:36:29 GMT</pubDate>
      <description>&lt;p&gt;
Creating a script to grant execute to stored procedures where none exist&lt;br&gt;
&amp;nbsp;&lt;br&gt;
It’s very common to forget to script out permissions for a stored procedure when generating
the script. There’s nothing more frustrating than deploying some code changes, only
to have them not work because you have elevated security on your development SQL Server,
but not on QA or Production. If you find one, likely you’ll find it several places.
How do you quickly locate the procedures which don’t have the desired permission set?
Better yet, how do you fix it quickly without writing a lot of script or manually
setting the permissions in SQL Server Management Studio?
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
The script below is one I pulled off the internet (&lt;a href="http://sqlfool.com/story/46/date-posted/06-06-0939/" target=blank&gt;http://sqlfool.com/story/46/date-posted/06-06-0939/&lt;/a&gt;)
and modified a little. Since the environment I am in now uses multiple schemas, I
added the ability to specify schema to search for. 
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
Here’s the script:
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @role &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(50) 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @targetSchema &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;VARCHAR&lt;/span&gt;(50)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; @targetSchema
= &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'dbo'&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; @role
= &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'MyUser'&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'GRANT
EXECUTE ON '&lt;/span&gt; + SPECIFIC_SCHEMA + &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'.['&lt;/span&gt; +
SPECIFIC_NAME + &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;']
TO '&lt;/span&gt; + @role + &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CHAR&lt;/span&gt;(10)
+ &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'GO'&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; INFORMATION_SCHEMA.ROUTINES &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WITH&lt;/span&gt; (NoLock)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; SPECIFIC_NAME &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Not&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;In&lt;/span&gt; 
&lt;br&gt;
(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; o.name &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; sys.database_permissions
p &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WITH&lt;/span&gt; (NoLock) 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;INNER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Join&lt;/span&gt; sys.objects
o &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WITH&lt;/span&gt; (NoLock) 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ON&lt;/span&gt; p.major_id
= o.&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;OBJECT_ID&lt;/span&gt; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;INNER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Join&lt;/span&gt; sys.database_principals
u &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WITH&lt;/span&gt; (NoLock) 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ON&lt;/span&gt; u.principal_id
= p.grantee_principal_id 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; u.name
= @role)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AND&lt;/span&gt; ROUTINE_TYPE
= &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'PROCEDURE'&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AND&lt;/span&gt; SPECIFIC_NAME &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;not&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;like&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'sp_%'&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AND&lt;/span&gt; SPECIFIC_SCHEMA
= @targetSchema&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ORDER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BY&lt;/span&gt; SPECIFIC_NAME
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Verdana size=2&gt;Just change the @targetSchema and @role variables and run
it. The results will be a list of procedures on the current database which don’t have
execute permissions assigned to the indicated @role. You can then copy those procs
you want to grant execute on into the query window and execute them.&lt;br&gt;
&lt;/font&gt;
&lt;/p&gt;
&lt;/span&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=8df6f658-9820-485e-a7f9-1a9a970bd4ce" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,8df6f658-9820-485e-a7f9-1a9a970bd4ce.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=99a406e0-5f34-4f29-9651-6b6b9fcd0545</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,99a406e0-5f34-4f29-9651-6b6b9fcd0545.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,99a406e0-5f34-4f29-9651-6b6b9fcd0545.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=99a406e0-5f34-4f29-9651-6b6b9fcd0545</wfw:commentRss>
      <title>Tip of the Day: Manipulating ASP.Net validators client side</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,99a406e0-5f34-4f29-9651-6b6b9fcd0545.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/03/02/TipOfTheDayManipulatingASPNetValidatorsClientSide.aspx</link>
      <pubDate>Tue, 02 Mar 2010 04:29:40 GMT</pubDate>
      <description>&lt;p&gt;
This tip will show how to get a reference to a validator using client-side script,
check the valid state of the validator control, and set a validator control active
state client-side as well.
&lt;/p&gt;
&lt;p&gt;
I ran across a situation today to validate two dates (txtStartDate, txtEndDate) with
the following criteria:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
txtStartDate is required (use RequiredFieldValidator)&lt;/li&gt;
&lt;li&gt;
txtEndDate is required (use RequiredFieldValidator)&lt;/li&gt;
&lt;li&gt;
txtStartDate must be a valid date (use RegularExpressionValidator)&lt;/li&gt;
&lt;li&gt;
txtEndDate must be a valid date (use RegularExpressionValidator)&lt;/li&gt;
&lt;li&gt;
txtStartDate must occur before txtEndDate (use CompareValidator)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Granted, I could write client script for doing this in one fell swoop, but I inherited
this page and these validators were already there, and I was just there to fix a bug.
&lt;/p&gt;
&lt;p&gt;
The QA person logged an issue like this: 
&lt;/p&gt;
&lt;p&gt;
txtStateDate value – 11/1/2009
&lt;/p&gt;
&lt;p&gt;
txtEndDate value – 11/31/2009 (invalid date)
&lt;/p&gt;
&lt;p&gt;
The “bug” was that in this case txtEndDate is not a valid date. The RegularExpression
Validator correctly caught this, but the Compare Validator still fired, indicating
a second error. The QA person felt that we should only display an “invalid date” error. 
&lt;/p&gt;
&lt;p&gt;
My options were to strip out the RegularExpressionValidator and CompareValidator and
use a CustomValidator and write some javascript. But really all I needed to do is
disable the CompareValidator if the txtBeginDate or txtEndDate is not a valid date.
&lt;/p&gt;
&lt;p&gt;
It took some doing, but I came up with a simple solution. I added a CustomValidator,
and called a client side function called ControlEndDateValidators(). You need one
for each date input.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;asp:CustomValidator
ID=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"valEndDateCheck"&lt;/span&gt; runat=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"server"&lt;/span&gt; ControlToValidate=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"txEndDate"&lt;/span&gt; ClientValidationFunction=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"ControlEndDateValidators"&lt;/span&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
The function obtains a reference to the validators, and the compare validator is only
made active if the data is valid per the RegularExpressionValidators. To check and
see if a validator is valid client-side, check the isvalid property for true/false.
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;script&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: red"&gt;language&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;="javascript"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;function&lt;/span&gt;&lt;font color=#000000&gt; ControlEndDateValidators(source,
arguments) 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt;&lt;font color=#000000&gt; regExpValidatorEndDate
= document.getElementById(&lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"&amp;lt;%=valEndDate.ClientID
%&amp;gt;"&lt;/span&gt;&lt;font color=#000000&gt;);&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt;&lt;font color=#000000&gt; regExpValidatorBeginDate
= document.getElementById(&lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"&amp;lt;%=valStartDate.ClientID
%&amp;gt;"&lt;/span&gt;&lt;font color=#000000&gt;);&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt;&lt;font color=#000000&gt; compareValidator
= document.getElementById(&lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"&amp;lt;%=valDate.ClientID
%&amp;gt;"&lt;/span&gt;&lt;font color=#000000&gt;);&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ValidationEnable(compareValidator,
(regExpValidatorBeginDate.isvalid) &amp;amp;&amp;amp; (regExpValidatorEndDate.isvalid));&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;function&lt;/span&gt;&lt;font color=#000000&gt; ValidationEnable(val,
enable)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;val.enabled
= (enable != &lt;/font&gt;&lt;span style="COLOR: blue"&gt;false&lt;/span&gt;&lt;font color=#000000&gt;);&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ValidatorValidate(val);&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ValidatorUpdateIsValid();&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;script&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
Again, we could write client-script code perform all this validation, but sometimes
time is of the essence. Using the functions above, we have shown how to get a reference
to a validator client-side,&amp;nbsp; check whether it is valid, and finally enable a
validator on the client-side.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=99a406e0-5f34-4f29-9651-6b6b9fcd0545" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,99a406e0-5f34-4f29-9651-6b6b9fcd0545.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=1a2f2fbb-86df-4e7f-b257-ee348f3f9d50</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,1a2f2fbb-86df-4e7f-b257-ee348f3f9d50.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,1a2f2fbb-86df-4e7f-b257-ee348f3f9d50.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1a2f2fbb-86df-4e7f-b257-ee348f3f9d50</wfw:commentRss>
      <title>Tip of the Day: How to register class based user controls in a web project</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,1a2f2fbb-86df-4e7f-b257-ee348f3f9d50.aspx</guid>
      <link>http://www.dotnettechnologies.com/2010/01/06/TipOfTheDayHowToRegisterClassBasedUserControlsInAWebProject.aspx</link>
      <pubDate>Wed, 06 Jan 2010 03:52:06 GMT</pubDate>
      <description>&lt;p&gt;
The latest project I am working on is a web site project, which differs significantly
from a web application project. If you need a little background on the difference,
here's some links:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.codersbarn.com/post/2008/06/ASPNET-Web-Site-versus-Web-Application-Project.aspx" target=_blank&gt;http://www.codersbarn.com/post/2008/06/ASPNET-Web-Site-versus-Web-Application-Project.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://reddnet.net/code/aspnet-web-site-vs-web-application/" target=_blank&gt;http://reddnet.net/code/aspnet-web-site-vs-web-application/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
We wanted to create some base controls, such as for the GridView so that common functionality
could be consistant across the web site. It's simple to create a user control to do
this (e.g. an .ascx file), but in this case we wanted to do it as a class.
&lt;/p&gt;
&lt;p&gt;
In the web application, that's no problem because we know what the assembly name is.
In a web site template, we don't, so how do we register the control for use? It took
a few minutes of digging around and trying a few things, but I finally got it, and
I decided to share it for the next person looking.
&lt;/p&gt;
&lt;p&gt;
Let's say I define my base GridView class like this:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Linq;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Web;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Web.UI.WebControls;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;namespace&lt;/span&gt; BaseControls&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Summary description for BaseGrid&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; BaseGrid
: GridView&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/span&gt; BaseGrid()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//
TODO: Add constructor logic here&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; SomeMethod(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; someString)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; someString;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
} 
&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;Note
the namespace. By default the web project may not have it, so you'll need to create
one.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;In
order to reference it on the page, you'll actually leave the assembly blank. Your
register tag will look something like this:&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;&lt;span style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&amp;lt;%&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;@&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;Register&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: red"&gt;Namespace&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="BaseControls"&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: red"&gt;TagPrefix&lt;/span&gt;&lt;span style="COLOR: blue"&gt;="wf"&lt;/span&gt;&lt;font color=#000000&gt; &lt;span style="BACKGROUND: yellow"&gt;%&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;Now,
to use the control, all you need to do is put this on the aspx page. &lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;font color=#000000&gt;&lt;span style="BACKGROUND: yellow"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
&lt;o:p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;wf&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;:&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;BaseGrid&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;ID&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;="grdReport"&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;runat&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;="server"&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;Width&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;="95%"…. &lt;font color=#003300&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Courier New'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;(use
it like a normal GridView)&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/span&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt;In
code, you can then use the properties/methods like this:&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#003300 size=2&gt; 
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;font color=#000000&gt;grdReport.SomeMethod(&lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"test"&lt;/span&gt;&lt;font color=#000000&gt;);&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Calibri','sans-serif'; mso-fareast-font-family: 'Times New Roman'"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;/font&gt; 
&lt;p&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;/span&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1a2f2fbb-86df-4e7f-b257-ee348f3f9d50" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,1a2f2fbb-86df-4e7f-b257-ee348f3f9d50.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=d0d65734-e1ba-458d-9080-eddd8a5d30ed</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,d0d65734-e1ba-458d-9080-eddd8a5d30ed.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,d0d65734-e1ba-458d-9080-eddd8a5d30ed.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d0d65734-e1ba-458d-9080-eddd8a5d30ed</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the past week, I created some CodeSmith templates for my client so we could quickly
generate the business objects for our web site. Since the project will be VS2008,
I decided to bing objects to List&lt;T&gt; collections of objects, so I could start
leveraging LINQ to Objects in the code.
</p>
        <p>
They wanted every field in the GridView sortable, and I always looks for an reusable
way to do things when possible. Since we were going to have many, many grids, this
was a great opportunity to use generics and LINQ to come up with a flexible solution.
</p>
        <p>
In this case, I wanted a way of taking in a field name, and sort direction, and sorting
the collection. It was easy to do using a Lambda expression if I knew in advance all
the field names, such as MyCollection.OrderBy(a =&gt; a.Name) to sort by name. Obviously,
that wasn't going to work. I needed to create a delegate for sorting on the right
field dynamically.
</p>
        <p>
Below is the result of that effort. By using the Lambda.Expression (provided by System.Core.dll),
I was able to dynamically set the Lambda expression to the property I wanted.
Depending on the direction, I used OrderBy or OrderByDescending with the dynamic sort
expression. I created it as an extension method to all List&lt;T&gt; objects for quick
and easy access, which every business object in my solution supports.
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;summary&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
Sorts a list of objects by passing in the parameter and direction.</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
Usage: List&lt;MyObject&gt; newList = oldList.SortList("SomeColumn", "SomeDirection");</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
Requires System.Core be included in the project.</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;/summary&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;typeparam name="T"&gt;&lt;/typeparam&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;param name="list"&gt;The list.&lt;/param&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;param name="sortColumn"&gt;The sort column.&lt;/param&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;param name="direction"&gt;The direction.&lt;/param&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">///
&lt;returns&gt;&lt;/returns&gt;</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">static</span> List&lt;T&gt;
SortList&lt;T&gt;(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span> List&lt;T&gt;
list, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> sortColumn, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> direction)<br />
{<br />
var param <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Expression.Parameter(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">typeof</span>(AutoClassParams),
sortColumn);<br />
var sortExpression <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Expression.Lambda&lt;Func&lt;T, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span>&gt;&gt;(Expression.Convert(Expression.Property(param,
sortColumn), <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">typeof</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span>)),
param);<br /><br />
List&lt;T&gt; newList <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">null</span>;<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (direction.ToUpper()
== <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"ASC"</span>)<br />
newList <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> list.AsQueryable&lt;T&gt;().OrderBy(sortExpression).ToList&lt;T&gt;();<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">else</span><br />
newList <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> list.AsQueryable&lt;T&gt;().OrderByDescending(sortExpression).ToList&lt;T&gt;();<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span> newList;<br />
}</span>
        </p>
        <p>
 
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=d0d65734-e1ba-458d-9080-eddd8a5d30ed" />
      </body>
      <title>Tip of the Day: Dynamically sorting a List&lt;T&gt; collection using Lambda.Expression</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,d0d65734-e1ba-458d-9080-eddd8a5d30ed.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/12/30/TipOfTheDayDynamicallySortingAListCollectionUsingLambdaExpression.aspx</link>
      <pubDate>Wed, 30 Dec 2009 04:58:02 GMT</pubDate>
      <description>&lt;p&gt;
In the past week, I created some CodeSmith templates for my client so we could quickly
generate the business objects for our web site. Since the project will be VS2008,
I decided to bing objects to List&amp;lt;T&amp;gt; collections of objects, so I could start
leveraging LINQ to Objects in the code.
&lt;/p&gt;
&lt;p&gt;
They wanted every field in the GridView sortable, and I always looks for an reusable
way to do things when possible. Since we were going to have many, many grids, this
was a great opportunity to use generics and LINQ to come up with a flexible solution.
&lt;/p&gt;
&lt;p&gt;
In this case, I wanted a way of taking in a field name, and sort direction, and sorting
the collection. It was easy to do using a Lambda expression if I knew in advance all
the field names, such as MyCollection.OrderBy(a =&amp;gt; a.Name) to sort by name. Obviously,
that wasn't going to work. I needed to create a delegate for sorting on the right
field dynamically.
&lt;/p&gt;
&lt;p&gt;
Below is the result of that effort. By using the Lambda.Expression (provided by System.Core.dll),
I was able to dynamically set the Lambda expression to the property&amp;nbsp;I wanted.
Depending on the direction, I used OrderBy or OrderByDescending with the dynamic sort
expression. I created it as an extension method to all List&amp;lt;T&amp;gt; objects for quick
and easy access, which every business object in my solution supports.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Sorts a list of objects by passing in the parameter and direction.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Usage: List&amp;lt;MyObject&amp;gt; newList = oldList.SortList("SomeColumn", "SomeDirection");&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Requires System.Core be included in the project.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;typeparam name="T"&amp;gt;&amp;lt;/typeparam&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="list"&amp;gt;The list.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="sortColumn"&amp;gt;The sort column.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="direction"&amp;gt;The direction.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; List&amp;lt;T&amp;gt;
SortList&amp;lt;T&amp;gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt; List&amp;lt;T&amp;gt;
list, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; sortColumn, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; direction)&lt;br&gt;
{&lt;br&gt;
var param &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Expression.Parameter(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;typeof&lt;/span&gt;(AutoClassParams),
sortColumn);&lt;br&gt;
var sortExpression &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Expression.Lambda&amp;lt;Func&amp;lt;T, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt;&amp;gt;&amp;gt;(Expression.Convert(Expression.Property(param,
sortColumn), &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;typeof&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt;)),
param);&lt;br&gt;
&lt;br&gt;
List&amp;lt;T&amp;gt; newList &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/span&gt;;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (direction.ToUpper()
== &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"ASC"&lt;/span&gt;)&lt;br&gt;
newList &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; list.AsQueryable&amp;lt;T&amp;gt;().OrderBy(sortExpression).ToList&amp;lt;T&amp;gt;();&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;else&lt;/span&gt;
&lt;br&gt;
newList &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; list.AsQueryable&amp;lt;T&amp;gt;().OrderByDescending(sortExpression).ToList&amp;lt;T&amp;gt;();&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; newList;&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=d0d65734-e1ba-458d-9080-eddd8a5d30ed" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,d0d65734-e1ba-458d-9080-eddd8a5d30ed.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=35527443-4621-4bec-a4b6-b853ecf6a880</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,35527443-4621-4bec-a4b6-b853ecf6a880.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,35527443-4621-4bec-a4b6-b853ecf6a880.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=35527443-4621-4bec-a4b6-b853ecf6a880</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am a big fan of Resharper, but right now I am at a client who doesn't use it. Today,
I accidentally reset my toolbar, so I was going through and adding my settings (yes,
I could have restored an old one..)
</p>
        <p>
As I was doing it, I ran across two items I relied on Resharper to handle. 
</p>
        <p>
One will remove unused "using" statements, and the other will sort them in your
class by namespace. 
</p>
        <p>
Here's what they look like:
</p>
        <p>
          <img src="http://www.dotnettechnologies.com/content/binary/usingShortcuts.png" border="0" />
        </p>
        <p>
They can be found in the Edit Menu items.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=35527443-4621-4bec-a4b6-b853ecf6a880" />
      </body>
      <title>Tip of the Day: Eliminating unused "using" statements and sorting them</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,35527443-4621-4bec-a4b6-b853ecf6a880.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/12/29/TipOfTheDayEliminatingUnusedUsingStatementsAndSortingThem.aspx</link>
      <pubDate>Tue, 29 Dec 2009 04:43:28 GMT</pubDate>
      <description>&lt;p&gt;
I am a big fan of Resharper, but right now I am at a client who doesn't use it. Today,
I accidentally reset my toolbar, so I was going through and adding my settings (yes,
I could have restored an old one..)
&lt;/p&gt;
&lt;p&gt;
As I was doing it, I ran across two items I relied on Resharper to handle. 
&lt;/p&gt;
&lt;p&gt;
One&amp;nbsp;will remove unused "using" statements, and the other will sort them in your
class by namespace. 
&lt;/p&gt;
&lt;p&gt;
Here's what they look like:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/usingShortcuts.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
They can be found in the Edit Menu items.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=35527443-4621-4bec-a4b6-b853ecf6a880" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,35527443-4621-4bec-a4b6-b853ecf6a880.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=70592587-7f7f-4d02-83b2-3c78023caa64</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,70592587-7f7f-4d02-83b2-3c78023caa64.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,70592587-7f7f-4d02-83b2-3c78023caa64.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=70592587-7f7f-4d02-83b2-3c78023caa64</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It's been a LONG time since I did any SSIS work, and I really enjoy it. I'm writing
an ETL process for importing general ledger transactions, and it's a fairly complex
task. To help notate what needs to be done as well as explain some of the complexities,
I am making sure to annotate the code in the Control Flow.
</p>
        <p>
I had forgotten how to add carriage returns in annotations, so this is more a reminder
again just in case I forget: Ctrl-Enter will do the trick!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=70592587-7f7f-4d02-83b2-3c78023caa64" />
      </body>
      <title>Tip of the Day: SSIS -- adding carriage returns to annotations</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,70592587-7f7f-4d02-83b2-3c78023caa64.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/11/11/TipOfTheDaySSISAddingCarriageReturnsToAnnotations.aspx</link>
      <pubDate>Wed, 11 Nov 2009 17:13:49 GMT</pubDate>
      <description>&lt;p&gt;
It's been a LONG time since I did any SSIS work, and I really enjoy it. I'm writing
an ETL process for importing general ledger transactions, and it's a fairly complex
task. To help notate what needs to be done as well as explain some of the complexities,
I am making sure to annotate the code in the Control Flow.
&lt;/p&gt;
&lt;p&gt;
I had forgotten how to add carriage returns in annotations, so this is more a reminder
again just in case I forget: Ctrl-Enter will do the trick!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=70592587-7f7f-4d02-83b2-3c78023caa64" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,70592587-7f7f-4d02-83b2-3c78023caa64.aspx</comments>
      <category>All Things</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=a0f5b464-8bcd-43d2-a17d-58c4bb7b392b</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,a0f5b464-8bcd-43d2-a17d-58c4bb7b392b.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,a0f5b464-8bcd-43d2-a17d-58c4bb7b392b.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a0f5b464-8bcd-43d2-a17d-58c4bb7b392b</wfw:commentRss>
      <title>New features of VS2010 which have me smiling (Part 2)</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,a0f5b464-8bcd-43d2-a17d-58c4bb7b392b.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/11/07/NewFeaturesOfVS2010WhichHaveMeSmilingPart2.aspx</link>
      <pubDate>Sat, 07 Nov 2009 03:45:19 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Session compression – For out-of-process session
maintenance, the session state is compressed using the &lt;i style="mso-bidi-font-style: normal"&gt;System.IO.Compression.GZipStream&lt;/i&gt; class.
It also looks like it will only do this when CPU cycles are available (but I need
to investigate this further).&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;If that’s
the case, you might want to set up some Performance indicators or alerts when it’s
not being compressed because that might indicate further problems.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #666666; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&amp;lt;&lt;a href="http://www.asp.net/learn/whitepapers/aspnet4/default.aspx"&gt;http://www.asp.net/learn/whitepapers/aspnet4/default.aspx&lt;/a&gt;&amp;gt; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Multi-Targeting – I’ve mentioned this before,
but it allows you to specify which .Net version you are writing for in the VS2010
IDE. This expands the support that VS2008 has by adaptively changing&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;the
IDE to the targeted environment. The IDE adjusts its Intellisense and compilation
towards the targeted version.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;The whitepaper
indicates ASP.Net, so I need to test and see if it applies to WPF and WinForm as well.
Some features:&lt;/font&gt;
&lt;/p&gt;
&lt;ul style="MARGIN-TOP: 0in" type=disc&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l3 level1 lfo2"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Specified in the .config file, defaults to
4.0 when not specified.&lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l3 level1 lfo2"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Compiles the code to the &lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l3 level1 lfo2"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Intellisense adapts to the current version
of the framework selected&lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #666666; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&amp;lt;&lt;a href="http://www.asp.net/learn/whitepapers/aspnet4/default.aspx"&gt;http://www.asp.net/learn/whitepapers/aspnet4/default.aspx&lt;/a&gt;&amp;gt; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx"&gt;&lt;font face=Calibri size=3&gt;http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Script Loading – The AJAX library includes
the ability to have better control of script loading in .Net 4.0. It loads the scripts
automatically, and in the order needed. From the whitepaper, here’s the features:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3; tab-stops: list .5in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 12.0pt"&gt;&lt;span style="mso-list: Ignore"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Automatically
loads all resources that are required by a script. &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3; tab-stops: list .5in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 12.0pt"&gt;&lt;span style="mso-list: Ignore"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Makes
sure that each script is loaded only once. &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3; tab-stops: list .5in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 12.0pt"&gt;&lt;span style="mso-list: Ignore"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Improves
performance by loading scripts in parallel and by combining scripts. &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3; tab-stops: list .5in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 12.0pt"&gt;&lt;span style="mso-list: Ignore"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Supports
loading scripts only when they are needed (“lazy loading”). &lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3; tab-stops: list .5in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 12.0pt"&gt;&lt;span style="mso-list: Ignore"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font size=3&gt;&lt;font face=Calibri&gt;Supports
loading third-party scripts like jQuery and your own scripts.&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt 0.75in; VERTICAL-ALIGN: middle; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo3; tab-stops: list .5in"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol; mso-bidi-font-size: 11.0pt"&gt;&lt;span style="mso-list: Ignore"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Supports
loading scripts from the Microsoft Ajax Content Delivery Network&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;One of the client features is the Sys.require.
When a component and a function is provided, the callback function is called when
the scripts are done loading.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #666666; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&amp;lt;&lt;a href="http://www.asp.net/learn/whitepapers/aspnet4/default.aspx"&gt;http://www.asp.net/learn/whitepapers/aspnet4/default.aspx&lt;/a&gt;&amp;gt; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;jQuery integration – Speaking of jQuery, it’s
now included&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;as part of the ASP.Net Web
forms and the MVC project.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #666666; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&amp;lt;&lt;a href="http://www.asp.net/learn/whitepapers/aspnet4/default.aspx"&gt;http://www.asp.net/learn/whitepapers/aspnet4/default.aspx&lt;/a&gt;&amp;gt; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;ClientID changes – I am mixed about this one,
simply because once In understood how ASP.Net set its clientIDs upon rendering, I
could generate my script accordingly&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;in
my code behind.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;However, it’s been simplified
in VS2010 to allow the user to have control over setting the client IDs. Be forewarned
though, this could open you up to naming issues within container controls as such.
Regardless, I am always supportive of giving the developer the option of more control.
There’s a new property at the configuration file, page and control level called &lt;i style="mso-bidi-font-style: normal"&gt;ClientIDMode&lt;/i&gt; which
has the following settings:&lt;/font&gt;
&lt;/p&gt;
&lt;ul style="MARGIN-TOP: 0in" type=disc&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l2 level1 lfo4"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;AutoID – mimics the previous version naming
scheme&lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l2 level1 lfo4"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Static – This specifies that the ClientID
value will be the same as the ID without concatenating the IDs of parent naming containers. &lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l2 level1 lfo4"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Predictable – useful for controls which will
be generated in template controls&lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l2 level1 lfo4"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Inherit – take the setting of the parent control
(lots of this in VS2010, which is great, since I have been a champion for UI inheritance
and control-centric programming).&lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #666666; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;&amp;lt;&lt;a href="http://www.asp.net/learn/whitepapers/aspnet4/default.aspx"&gt;http://www.asp.net/learn/whitepapers/aspnet4/default.aspx&lt;/a&gt;&amp;gt; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Improved “Add Reference” functionality – Over
the past couple of days, I found myself converting a project from VS2005 to VS2008.
As a result, I found myself needing to change some references as well as I changed
some of the related projects. This change in VS2008 is sort of a “nice to have”. While
it’s not a big win, it’s still nice as it can get painful at times changing the references.
Here are the changes with this:&lt;/font&gt;
&lt;/p&gt;
&lt;ul style="MARGIN-TOP: 0in" type=disc&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The .Net and COM tabs are loaded asynchronously&lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l1 level1 lfo1"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Defaults opening to the project tab (I find
myself using this a LOT anyways, but would have preferred this to start at the “Browse”
tab, or better, consider this like a MRU action and remember where I was last time)&lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link&lt;/font&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: #666666; FONT-FAMILY: 'Tahoma','sans-serif'"&gt;:
&amp;lt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/29/add-reference-dialog-improvements-vs-2010-and-net-4-0-series.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2009/10/29/add-reference-dialog-improvements-vs-2010-and-net-4-0-series.aspx&lt;/a&gt;&amp;gt; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;UML Support! Visual Studio 2010
will support the creation of UML diagrams via a modeling project. I like Visio and
all, but I look forward to being able to create UML diagrams right from the same IDE
I develop in. As of now, there’s no code generation support. I do think a clever developer
could possible do some code generation from the saved file via CodeSmith or IDE programming,
so I bet we’ll see something like that soon if Microsoft doesn’t provide it first.
Check out the link below and you can see some of the functionality.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;a href="http://weblogs.asp.net/gunnarpeipman/archive/2009/11/04/visual-studio-2010-uml-modeling-projects.aspx"&gt;&lt;font face=Calibri size=3&gt;http://weblogs.asp.net/gunnarpeipman/archive/2009/11/04/visual-studio-2010-uml-modeling-projects.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Although available in v3.5, VS2010/v4 will
have the chart control integrated into it. In the past, your options were a third-party
control for charting or to use Interop and Excel, or writing your own charting libraries
(gulp!). &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;The link below lists some details
on this impressive charting library if you’ve never used it.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx"&gt;&lt;font face=Calibri size=3&gt;http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Developers will have more deployment options
Web application &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Get it here: &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;&lt;font face=Calibri size=3&gt;http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a0f5b464-8bcd-43d2-a17d-58c4bb7b392b" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,a0f5b464-8bcd-43d2-a17d-58c4bb7b392b.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>Debugging</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=78d1354f-358c-4052-a2ab-9f7fd732d20b</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,78d1354f-358c-4052-a2ab-9f7fd732d20b.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,78d1354f-358c-4052-a2ab-9f7fd732d20b.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=78d1354f-358c-4052-a2ab-9f7fd732d20b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There comes a time when old code needs to be laid to rest. For example, as I migrate
applications to VS2008, I find myself converting common functions to extension methods
where it makes sense to take advantage of the new language functionality. Lately,
I have been doing this a LOT.  I don’t want to have to maintain separate libraries
for each version, but I am also not doing much development in older versions of .Net
either. 
</p>
        <p>
Fortunately, .Net provides us with the ability to make old code obsolete. We have
two options with this:
</p>
        <ol>
          <li>
Make it so users can still use the functionality, but inform them new functionality
exists 
</li>
          <li>
Require them to use the new functionality</li>
        </ol>
        <p>
          <br />
There is an attribute called “System.Obsolete” which allows us this option. It can
be used on a most anything (classes, properties, functions, structs, etc), and has
the following syntac in C#:
</p>
        <p>
[System.Obsolete(“Some description – provide the new recommended way”, true/false)]
</p>
        <p>
The true/false (defaults to false) parameter indicates if you want to create a compilation
error if this method is used. I do wonder about the usefulness of this paramter though,
as at that point, why not make sure it’s in source control and delete it? I guess
for historical purposes it might make sense to keep it.<br /></p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
            <p style="MARGIN: 0px">
 
</p>
            <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">TestClass</span></p>
            <p style="MARGIN: 0px">
    {
</p>
            <p style="MARGIN: 0px">
        [System.<span style="COLOR: #2b91af">Obsolete</span>(<span style="COLOR: #a31515">"Use
NewMethod()"</span>)]
</p>
            <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> OriginalMethodStillAvailable()
</p>
            <p style="MARGIN: 0px">
        {
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: green">//Do
Something...</span></p>
            <p style="MARGIN: 0px">
        }
</p>
            <p style="MARGIN: 0px">
 
</p>
            <p style="MARGIN: 0px">
        [System.<span style="COLOR: #2b91af">Obsolete</span>(<span style="COLOR: #a31515">"Use
NewMethod()"</span>, <span style="COLOR: blue">true</span>)]
</p>
            <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> OriginalMethodNotAvailable()
</p>
            <p style="MARGIN: 0px">
        {
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: green">//Do
Something...</span></p>
            <p style="MARGIN: 0px">
        }
</p>
            <p style="MARGIN: 0px">
 
</p>
            <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> NewMethod()
</p>
            <p style="MARGIN: 0px">
        {
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: green">//Do
Something...</span></p>
            <p style="MARGIN: 0px">
        }
</p>
            <p style="MARGIN: 0px">
 
</p>
            <p style="MARGIN: 0px">
    }
</p>
            <p style="MARGIN: 0px">
 
</p>
            <p style="MARGIN: 0px">
              <font face="Verdana" size="2">If you try to use the method which is marked obsolete,
but allowed, you'll see something like this:</font>
            </p>
            <p style="MARGIN: 0px">
              <font face="Verdana" size="2">
              </font> 
</p>
            <p style="MARGIN: 0px">
              <font face="Verdana" size="2">
              </font> 
</p>
          </div>
          <p>
            <!--EndFragment-->
          </p>
        </span>
        <img src="http://www.dotnettechnologies.com/content/binary/obsolete1.jpg" border="0" />
        <p>
If you try to use one with the obsolete flag set to true, you'll see a compilation
error like this:
</p>
        <p>
 
</p>
        <p>
          <img src="http://www.dotnettechnologies.com/content/binary/obsolete2.jpg" border="0" />
        </p>
        <p>
 
</p>
        <img src="http://www.dotnettechnologies.com/content/binary/obsolete3.jpg" border="0" />
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=78d1354f-358c-4052-a2ab-9f7fd732d20b" />
      </body>
      <title>Tip of the Day: Marking old routines obsolete</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,78d1354f-358c-4052-a2ab-9f7fd732d20b.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/11/06/TipOfTheDayMarkingOldRoutinesObsolete.aspx</link>
      <pubDate>Fri, 06 Nov 2009 03:43:11 GMT</pubDate>
      <description>&lt;p&gt;
There comes a time when old code needs to be laid to rest. For example, as I migrate
applications to VS2008, I find myself converting common functions to extension methods
where it makes sense to take advantage of the new language functionality. Lately,
I have been doing this a LOT.&amp;nbsp; I don’t want to have to maintain separate libraries
for each version, but I am also not doing much development in older versions of .Net
either. 
&lt;/p&gt;
&lt;p&gt;
Fortunately, .Net provides us with the ability to make old code obsolete. We have
two options with this:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Make it so users can still use the functionality, but inform them new functionality
exists 
&lt;li&gt;
Require them to use the new functionality&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
&lt;br&gt;
There is an attribute called “System.Obsolete” which allows us this option. It can
be used on a most anything (classes, properties, functions, structs, etc), and has
the following syntac in C#:
&lt;/p&gt;
&lt;p&gt;
[System.Obsolete(“Some description – provide the new recommended way”, true/false)]
&lt;/p&gt;
&lt;p&gt;
The true/false (defaults to false) parameter indicates if you want to create a compilation
error if this method is used. I do wonder about the usefulness of this paramter though,
as at that point, why not make sure it’s in source control and delete it? I guess
for historical purposes it might make sense to keep it.&lt;br&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TestClass&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [System.&lt;span style="COLOR: #2b91af"&gt;Obsolete&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Use
NewMethod()"&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; OriginalMethodStillAvailable()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//Do
Something...&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [System.&lt;span style="COLOR: #2b91af"&gt;Obsolete&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"Use
NewMethod()"&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; OriginalMethodNotAvailable()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//Do
Something...&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; NewMethod()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//Do
Something...&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;If you try to use the method which is marked obsolete, but
allowed, you'll see something like this:&lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;!--EndFragment--&gt;
&lt;/span&gt;&lt;img src="http://www.dotnettechnologies.com/content/binary/obsolete1.jpg" border=0&gt;&gt;
&lt;p&gt;
If you try to use one with the obsolete flag set to true, you'll see a compilation
error like this:
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/obsolete2.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/obsolete3.jpg" border=0&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=78d1354f-358c-4052-a2ab-9f7fd732d20b" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,78d1354f-358c-4052-a2ab-9f7fd732d20b.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=9c93a3a3-ff3c-4a78-b273-081242375c0d</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,9c93a3a3-ff3c-4a78-b273-081242375c0d.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,9c93a3a3-ff3c-4a78-b273-081242375c0d.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9c93a3a3-ff3c-4a78-b273-081242375c0d</wfw:commentRss>
      <title>New features of VS2010 which have me smiling (Part 1)</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,9c93a3a3-ff3c-4a78-b273-081242375c0d.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/10/31/NewFeaturesOfVS2010WhichHaveMeSmilingPart1.aspx</link>
      <pubDate>Sat, 31 Oct 2009 04:22:38 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;As I mentioned before, I historically have
avoided beta software. However, this time I am breaking that rule and really digging
into VS2010 early. Below are a few of the things which have me very excited to see
this release (and with Web Spark, I get it for free! Join now!) This is part one of
a multi-part entry of the things I find really appealing about the upcoming version
of Visual Studio 2010.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;IntelliTrace&lt;/b&gt; –
allows you to playback and trace a session to assist with debugging. The major features
are:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;ul style="MARGIN-TOP: 0in" type=disc&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Application Event Recording &lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Playback Debugging (a.k.a Time Travel Debugging) &lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Record and Playback of Manual Test Failures &lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Debugging Build Acceptance Tests &lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Diagnosing Unit Test Defects &lt;/font&gt;
&lt;/li&gt;
&lt;li class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Debugging Load Test Failures&lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;a href="http://blogs.msdn.com/habibh/archive/2009/06/02/an-in-depth-look-at-the-historical-debugger-in-visual-studio-2010-part-i.aspx" target=_blank&gt;&lt;font face=Calibri size=3&gt;http://blogs.msdn.com/habibh/archive/2009/06/02/an-in-depth-look-at-the-historical-debugger-in-visual-studio-2010-part-i.aspx&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Auto-Start
applications&lt;/b&gt; – Helps mitigate large startup processes which may run during the
web application “Application_Start” event. Provides a controlled approach for starting
up the application.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx" target=_blank&gt;&lt;font face=Calibri size=3&gt;http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Better
ViewState management&lt;/b&gt; – By default, ViewState is enabled for web controls in past
versions of ASP.Net. In VS2010, ViewState can be disabled by default and onlt enabled
for those that actually need it, and it now supports “inheritance” through the ViewStateMode
property. This allows you to set it to “Inherit” the value from the parent control.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;a href="http://www.asp.net/learn/whitepapers/aspnet4/" target=_blank&gt;&lt;font face=Calibri size=3&gt;http://www.asp.net/learn/whitepapers/aspnet4/&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Outut
Caching everywhere &lt;/b&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;-- Now you can
take advantage of caching in applications other than web based, as the cache API is
exposed without using the System.Web.Cache in a WinForm application. There are also
more providers, and the ability to create your own through extensibility.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;a href="http://www.asp.net/learn/whitepapers/aspnet4/" target=_blank&gt;&lt;font face=Calibri size=3&gt;http://www.asp.net/learn/whitepapers/aspnet4/&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Reduced
web.config size – &lt;/b&gt;Most of the configuration settings have been moved to the machine.config
file, which greatly simplifies the configuration settings in the web.config file.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Link: &lt;/font&gt;&lt;a href="http://www.asp.net/learn/whitepapers/aspnet4/"&gt;&lt;font face=Calibri size=3&gt;http://www.asp.net/learn/whitepapers/aspnet4/&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Get the VS2010 Beta 2 here: &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" target=_blank&gt;&lt;font face=Calibri size=3&gt;http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9c93a3a3-ff3c-4a78-b273-081242375c0d" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,9c93a3a3-ff3c-4a78-b273-081242375c0d.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Web Services</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=98e03a29-d433-4de1-a58a-9d11dd2bd28a</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,98e03a29-d433-4de1-a58a-9d11dd2bd28a.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,98e03a29-d433-4de1-a58a-9d11dd2bd28a.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=98e03a29-d433-4de1-a58a-9d11dd2bd28a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Once you have data loaded into a DataRow or SqlDataReader, you’d typically do something
like this:
</p>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">string</span> someValue = (<span style="COLOR: blue">string</span>)drData[<span style="COLOR: #a31515">"MyValue"</span>];
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">In order to place it in the variable, you need to cast
the type correctly (in this example, using the(string)). Also, what happens if “MyValue”
is null?  You’ll need to do an additional check, and then assign the value you
want for the situations where it is null.</font>
          </p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">Today’s tip uses generics to return the correct type.
It also allows you to return a default value if the value is null.</font>
          </p>
          <p style="MARGIN: 0px">
 
</p>
          <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the data row value.</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;typeparam
name="T"&gt;&lt;/typeparam&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="valueName"&gt;</span><span style="COLOR: green">Name of the value.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="drData"&gt;</span><span style="COLOR: green">The dr data.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="defaultValue"&gt;</span><span style="COLOR: green">The default value. Note,
this must be cast to the expected return type. For example, decimal.Parse("0").</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: blue">protected</span> T
GetDataRowValue&lt;T&gt;(<span style="COLOR: blue">string</span> valueName, <span style="COLOR: #2b91af">DataRow</span> drData,
T defaultValue)
</p>
            <p style="MARGIN: 0px">
        {
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: blue">if</span> (drData[valueName]
== <span style="COLOR: #2b91af">DBNull</span>.Value)
</p>
            <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span> defaultValue;
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: blue">else</span></p>
            <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span> (T)drData[valueName];
</p>
            <p style="MARGIN: 0px">
        }
</p>
            <p style="MARGIN: 0px">
 
</p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the data row value.</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;typeparam
name="T"&gt;&lt;/typeparam&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="valueName"&gt;</span><span style="COLOR: green">Name of the value.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="drData"&gt;</span><span style="COLOR: green">The dr data.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="defaultValue"&gt;</span><span style="COLOR: green">The default value. Note,
this must be cast to the expected return type. For example, decimal.Parse("0").</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;</span></p>
            <p style="MARGIN: 0px">
        <span style="COLOR: blue">protected</span> T
GetDataRowValue&lt;T&gt;(<span style="COLOR: blue">string</span> valueName, <span style="COLOR: #2b91af">SqlDataReader</span> drData,
T defaultValue)
</p>
            <p style="MARGIN: 0px">
        {
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: blue">if</span> (drData[valueName]
== <span style="COLOR: #2b91af">DBNull</span>.Value)
</p>
            <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span> defaultValue;
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: blue">else</span></p>
            <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span> (T)drData[valueName];
</p>
            <p style="MARGIN: 0px">
        }
</p>
            <p style="MARGIN: 0px">
 
</p>
          </div>
          <!--EndFragment-->
        </div>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <font face="Verdana" size="2">Here’s
how it’s used. Notice that through the use of generics, one routine can handle multiple
types. </font>
          <p style="MARGIN: 0px">
 
</p>
          <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
            <p style="MARGIN: 0px">
            <span style="COLOR: blue">int</span> myID
= GetDataRowValue(<span style="COLOR: #a31515">"SomeID"</span>, drData, 0);
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">DateTime</span> myDate
= GetDataRowValue(<span style="COLOR: #a31515">"SomeDate"</span>, drData, <span style="COLOR: #2b91af">DateTime</span>.Now);
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: blue">decimal</span> myAmt
= GetDataRowValue(<span style="COLOR: #a31515">"SomeDecimalAmount"</span>, drData, <span style="COLOR: blue">decimal</span>.Parse(<span style="COLOR: #a31515">"0"</span>));
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: blue">string</span> myString
= GetDataRowValue(<span style="COLOR: #a31515">"SomeString"</span>, drData, <span style="COLOR: #2b91af">String</span>.Empty);
</p>
          </div>
          <p style="MARGIN: 0px">
            <!--EndFragment-->
            <br />
          </p>
        </div>
        <!--EndFragment-->
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=98e03a29-d433-4de1-a58a-9d11dd2bd28a" />
      </body>
      <title>Tip of the Day: Using generics to simplify getting a value from a DataRow or DataReader</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,98e03a29-d433-4de1-a58a-9d11dd2bd28a.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/10/30/TipOfTheDayUsingGenericsToSimplifyGettingAValueFromADataRowOrDataReader.aspx</link>
      <pubDate>Fri, 30 Oct 2009 04:17:54 GMT</pubDate>
      <description>&lt;p&gt;
Once you have data loaded into a DataRow or SqlDataReader, you’d typically do something
like this:
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; someValue = (&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;)drData[&lt;span style="COLOR: #a31515"&gt;"MyValue"&lt;/span&gt;];
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;In order to place it in the variable, you need to cast the
type correctly (in this example, using the(string)). Also, what happens if “MyValue”
is null?&amp;nbsp; You’ll need to do an additional check, and then assign the value you
want for the situations where it is null.&lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;Today’s tip uses generics to return the correct type. It
also allows you to return a default value if the value is null.&lt;/font&gt; 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the data row value.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;typeparam
name="T"&amp;gt;&amp;lt;/typeparam&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="valueName"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Name of the value.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="drData"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The dr data.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="defaultValue"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The default value. Note,
this must be cast to the expected return type. For example, decimal.Parse("0").&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; T
GetDataRowValue&amp;lt;T&amp;gt;(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; valueName, &lt;span style="COLOR: #2b91af"&gt;DataRow&lt;/span&gt; drData,
T defaultValue)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (drData[valueName]
== &lt;span style="COLOR: #2b91af"&gt;DBNull&lt;/span&gt;.Value)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; defaultValue;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; (T)drData[valueName];
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the data row value.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;typeparam
name="T"&amp;gt;&amp;lt;/typeparam&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="valueName"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Name of the value.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="drData"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The dr data.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="defaultValue"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The default value. Note,
this must be cast to the expected return type. For example, decimal.Parse("0").&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; T
GetDataRowValue&amp;lt;T&amp;gt;(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; valueName, &lt;span style="COLOR: #2b91af"&gt;SqlDataReader&lt;/span&gt; drData,
T defaultValue)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (drData[valueName]
== &lt;span style="COLOR: #2b91af"&gt;DBNull&lt;/span&gt;.Value)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; defaultValue;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; (T)drData[valueName];
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;
&lt;/div&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;font face=Verdana size=2&gt;Here’s
how it’s used. Notice that through the use of generics, one routine can handle multiple
types. &lt;/font&gt; 
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; myID
= GetDataRowValue(&lt;span style="COLOR: #a31515"&gt;"SomeID"&lt;/span&gt;, drData, 0);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt; myDate
= GetDataRowValue(&lt;span style="COLOR: #a31515"&gt;"SomeDate"&lt;/span&gt;, drData, &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;.Now);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; myAmt
= GetDataRowValue(&lt;span style="COLOR: #a31515"&gt;"SomeDecimalAmount"&lt;/span&gt;, drData, &lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt;.Parse(&lt;span style="COLOR: #a31515"&gt;"0"&lt;/span&gt;));
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; myString
= GetDataRowValue(&lt;span style="COLOR: #a31515"&gt;"SomeString"&lt;/span&gt;, drData, &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.Empty);
&lt;/p&gt;
&lt;/div&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;!--EndFragment--&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=98e03a29-d433-4de1-a58a-9d11dd2bd28a" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,98e03a29-d433-4de1-a58a-9d11dd2bd28a.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=1731318f-32da-4580-bb09-42bf5a56a917</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,1731318f-32da-4580-bb09-42bf5a56a917.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,1731318f-32da-4580-bb09-42bf5a56a917.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1731318f-32da-4580-bb09-42bf5a56a917</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Every once in a while, you need to open another application from your WinForm application.
Today’s snippet is a wrapper which will give you the ability to start a new process
(application). It takes two parameters: <br />
    filename – string - the name full path of the application
to open<br />
    waitToFinish – bool - True/False – setting to true will cause
your program to stop until the opened application finishes processing. 
</p>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">private</span><span style="COLOR: blue">static</span><span style="COLOR: blue">void</span> OpenApplication(<span style="COLOR: blue">string</span> fileName, <span style="COLOR: blue">bool</span> waitToFinish)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            OpenApplication(fileName, <span style="COLOR: #2b91af">String</span>.Empty,
waitToFinish);
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">private</span><span style="COLOR: blue">static</span><span style="COLOR: blue">void</span> OpenApplication(<span style="COLOR: blue">string</span> fileName, <span style="COLOR: blue">string</span> arguments, <span style="COLOR: blue">bool</span> waitToFinish)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">using</span> (System.Diagnostics.<span style="COLOR: #2b91af">Process</span> prc
= <span style="COLOR: blue">new</span> System.Diagnostics.<span style="COLOR: #2b91af">Process</span>())
</p>
          <p style="MARGIN: 0px">
            {
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
                prc.StartInfo.FileName
= fileName;
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">if</span> (arguments.Trim().Length
&gt; 0)
</p>
          <p style="MARGIN: 0px">
                   
prc.StartInfo.Arguments = arguments;
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
                prc.Start();
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">if</span> (waitToFinish)
</p>
          <p style="MARGIN: 0px">
                {
</p>
          <p style="MARGIN: 0px">
                   
prc.WaitForExit();
</p>
          <p style="MARGIN: 0px">
                   
prc.Close();
</p>
          <p style="MARGIN: 0px">
                }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            }
</p>
          <p style="MARGIN: 0px">
        }
</p>
        </div>
        <!--EndFragment-->
        <font size="2">
          <p>
To use them, here’s an example usage:
</p>
          <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
            <p style="MARGIN: 0px">
        <span style="COLOR: blue">private</span><span style="COLOR: blue">void</span> button1_Click(<span style="COLOR: blue">object</span> sender, <span style="COLOR: #2b91af">EventArgs</span> e)
</p>
            <p style="MARGIN: 0px">
        {
</p>
            <p style="MARGIN: 0px">
            OpenApplication(<span style="COLOR: #a31515">@"c:\windows\notepad.exe"</span>, <span style="COLOR: blue">false</span>);
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">MessageBox</span>.Show(<span style="COLOR: #a31515">"Alert
that processing has continued!"</span>, <span style="COLOR: #a31515">"Processing.."</span>, <span style="COLOR: #2b91af">MessageBoxButtons</span>.OK, <span style="COLOR: #2b91af">MessageBoxIcon</span>.Information);
</p>
            <p style="MARGIN: 0px">
        }
</p>
          </div>
          <!--EndFragment-->
        </font>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1731318f-32da-4580-bb09-42bf5a56a917" />
      </body>
      <title>Tip of the day: Opening a process and (optionally) waiting</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,1731318f-32da-4580-bb09-42bf5a56a917.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/10/29/TipOfTheDayOpeningAProcessAndOptionallyWaiting.aspx</link>
      <pubDate>Thu, 29 Oct 2009 04:12:31 GMT</pubDate>
      <description>&lt;p&gt;
Every once in a while, you need to open another application from your WinForm application.
Today’s snippet is a wrapper which will give you the ability to start a new process
(application). It takes two parameters:&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;filename – string - the name full path of the application
to open&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;waitToFinish – bool - True/False – setting to true will cause
your program to stop until the opened application finishes processing. 
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; OpenApplication(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fileName, &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; waitToFinish)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; OpenApplication(fileName, &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.Empty,
waitToFinish);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; OpenApplication(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fileName, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; arguments, &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; waitToFinish)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;using&lt;/span&gt; (System.Diagnostics.&lt;span style="COLOR: #2b91af"&gt;Process&lt;/span&gt; prc
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; System.Diagnostics.&lt;span style="COLOR: #2b91af"&gt;Process&lt;/span&gt;())
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; prc.StartInfo.FileName
= fileName;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (arguments.Trim().Length
&amp;gt; 0)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
prc.StartInfo.Arguments = arguments;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; prc.Start();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (waitToFinish)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
prc.WaitForExit();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
prc.Close();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;font size=2&gt; 
&lt;p&gt;
To use them, here’s an example usage:
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; button1_Click(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; sender, &lt;span style="COLOR: #2b91af"&gt;EventArgs&lt;/span&gt; e)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; OpenApplication(&lt;span style="COLOR: #a31515"&gt;@"c:\windows\notepad.exe"&lt;/span&gt;, &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;MessageBox&lt;/span&gt;.Show(&lt;span style="COLOR: #a31515"&gt;"Alert
that processing has continued!"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"Processing.."&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;MessageBoxButtons&lt;/span&gt;.OK, &lt;span style="COLOR: #2b91af"&gt;MessageBoxIcon&lt;/span&gt;.Information);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/font&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1731318f-32da-4580-bb09-42bf5a56a917" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,1731318f-32da-4580-bb09-42bf5a56a917.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=59944df0-d1be-4713-a267-9318e88cf1c1</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,59944df0-d1be-4713-a267-9318e88cf1c1.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,59944df0-d1be-4713-a267-9318e88cf1c1.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=59944df0-d1be-4713-a267-9318e88cf1c1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This routine checks the specified minimum and maximum string lengths, and either returns
True/False that it meets those requirements, or could also throw an exception (based
on the throwException parameter value). 
</p>
        <p>
This would also be a good candidate for an extension method. To do so, add a parameter
(in the first position) as “this string”.
</p>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"> Checks
the length of a string to see if it meets the minimum and maximum length</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="checkString"&gt;</span><span style="COLOR: green">string to check</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="minLength"&gt;</span><span style="COLOR: green">minimum string length</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="maxLength"&gt;</span><span style="COLOR: green">maximum string length</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="stringName"&gt;</span><span style="COLOR: green">description of the value to
check</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="throwException"&gt;</span><span style="COLOR: green">T/F to throw an exception
if it exceeds the maximum</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">T/F</span><span style="COLOR: gray">&lt;/returns&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">static</span><span style="COLOR: blue">bool</span> ValidString(<span style="COLOR: blue">string</span> checkString, <span style="COLOR: blue">int</span> minLength, <span style="COLOR: blue">int</span> maxLength, <span style="COLOR: blue">string</span> stringName, <span style="COLOR: blue">bool</span> throwException)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">if</span> ((checkString.Length
&gt;= minLength) &amp;&amp; (checkString.Length &lt;= maxLength))
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span><span style="COLOR: blue">true</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">else</span></p>
          <p style="MARGIN: 0px">
            {
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">if</span> (checkString.Length
&lt; minLength)
</p>
          <p style="MARGIN: 0px">
                    <span style="COLOR: blue">if</span> (throwException)
</p>
          <p style="MARGIN: 0px">
                   
    <span style="COLOR: blue">throw</span><span style="COLOR: blue">new</span> System.<span style="COLOR: #2b91af">ArgumentOutOfRangeException</span>(<span style="COLOR: #a31515">"The
argument string - "</span> + stringName + <span style="COLOR: #a31515">" was less
than the minimum length."</span>);
</p>
          <p style="MARGIN: 0px">
                    <span style="COLOR: blue">else</span></p>
          <p style="MARGIN: 0px">
                   
    <span style="COLOR: blue">return</span><span style="COLOR: blue">false</span>;
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">if</span> (checkString.Length
&gt; maxLength)
</p>
          <p style="MARGIN: 0px">
                    <span style="COLOR: blue">if</span> (throwException)
</p>
          <p style="MARGIN: 0px">
                   
    <span style="COLOR: blue">throw</span><span style="COLOR: blue">new</span> System.<span style="COLOR: #2b91af">ArgumentOutOfRangeException</span>(<span style="COLOR: #a31515">"The
length ("</span> + checkString.Length.ToString() + <span style="COLOR: #a31515">")
of argument string - "</span> + stringName + <span style="COLOR: #a31515">" was longer
than the expected length("</span> + maxLength.ToString() + <span style="COLOR: #a31515">")."</span>);
</p>
          <p style="MARGIN: 0px">
                    <span style="COLOR: blue">else</span></p>
          <p style="MARGIN: 0px">
                   
    <span style="COLOR: blue">return</span><span style="COLOR: blue">false</span>;
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span><span style="COLOR: blue">false</span>;
</p>
          <p style="MARGIN: 0px">
            }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
        </div>
        <!--EndFragment-->
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=59944df0-d1be-4713-a267-9318e88cf1c1" />
      </body>
      <title>Tip of the day: Validate string meets length requirements</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,59944df0-d1be-4713-a267-9318e88cf1c1.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/10/28/TipOfTheDayValidateStringMeetsLengthRequirements.aspx</link>
      <pubDate>Wed, 28 Oct 2009 04:09:54 GMT</pubDate>
      <description>&lt;p&gt;
This routine checks the specified minimum and maximum string lengths, and either returns
True/False that it meets those requirements, or could also throw an exception (based
on the throwException parameter value). 
&lt;/p&gt;
&lt;p&gt;
This would also be a good candidate for an extension method. To do so, add a parameter
(in the first position) as “this string”.
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Checks
the length of a string to see if it meets the minimum and maximum length&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="checkString"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;string to check&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="minLength"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;minimum string length&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="maxLength"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;maximum string length&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="stringName"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;description of the value to
check&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="throwException"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;T/F to throw an exception
if it exceeds the maximum&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;T/F&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; ValidString(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; checkString, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; minLength, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; maxLength, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; stringName, &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; throwException)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; ((checkString.Length
&amp;gt;= minLength) &amp;amp;&amp;amp; (checkString.Length &amp;lt;= maxLength))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (checkString.Length
&amp;lt; minLength)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (throwException)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; System.&lt;span style="COLOR: #2b91af"&gt;ArgumentOutOfRangeException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"The
argument string - "&lt;/span&gt; + stringName + &lt;span style="COLOR: #a31515"&gt;" was less
than the minimum length."&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (checkString.Length
&amp;gt; maxLength)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (throwException)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; System.&lt;span style="COLOR: #2b91af"&gt;ArgumentOutOfRangeException&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"The
length ("&lt;/span&gt; + checkString.Length.ToString() + &lt;span style="COLOR: #a31515"&gt;")
of argument string - "&lt;/span&gt; + stringName + &lt;span style="COLOR: #a31515"&gt;" was longer
than the expected length("&lt;/span&gt; + maxLength.ToString() + &lt;span style="COLOR: #a31515"&gt;")."&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=59944df0-d1be-4713-a267-9318e88cf1c1" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,59944df0-d1be-4713-a267-9318e88cf1c1.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=11d51691-b09f-4422-aaa5-15a7bf2b628c</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,11d51691-b09f-4422-aaa5-15a7bf2b628c.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,11d51691-b09f-4422-aaa5-15a7bf2b628c.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=11d51691-b09f-4422-aaa5-15a7bf2b628c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When starting a project, I always recommend inheriting objects from a base object,
regardless of whether you know you'll need it or not. Usually, they will contain common
functionality like error handling, debugging or other common methods which you'll
use over and over.
</p>
        <p>
In WinForms, however, this can cause a problem if you make the base form an abstract
class (another thing I recommend).  For example, take this simple form:
</p>
        <p>
 
</p>
        <p>
          <img src="http://www.dotnettechnologies.com/content/binary/FormExample.png" border="0" />
        </p>
        <p>
Now let's say I decide to derive this form from an abstract base class, which I will
call BaseForm:
</p>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">    5</span> <span style="COLOR: blue">using</span> System.Windows.Forms;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">    6</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">    7</span> <span style="COLOR: blue">namespace</span> TestForm
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">    8</span> {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">    9</span>     <span style="COLOR: blue">public</span><span style="COLOR: blue">abstract</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">BaseForm</span> : <span style="COLOR: #2b91af">Form</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   10</span>     {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   11</span>         <span style="COLOR: blue">protected</span><span style="COLOR: blue">void</span> SomeCommonMethod()
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   12</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   13</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   14</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   15</span>     }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   16</span> }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">When I go to edit the UI again, I see this, and it scares
the heck out of me (looks scarier in VS2005)....</font>
          </p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">
            </font>
            <img src="http://www.dotnettechnologies.com/content/binary/ErrorPage1.png" border="0" />
          </p>
          <p style="MARGIN: 0px">
            <!--EndFragment-->
          </p>
        </div>
        <p>
What this is telling you is that it can't render an abstract class BaseForm. So while
you are creating the application, you might remove the abstract identifier
from UI related base classes (with a note that they should be inherited from, not
used, as well as a /TODO marker to make sure you mark it as abstract before deployment). 
</p>
        <p>
Doing this will allow you to inherit from a base class while at the same time edit
the UI.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=11d51691-b09f-4422-aaa5-15a7bf2b628c" />
      </body>
      <title>Tip of the Day: Winform: Displaying the form derived from a base class</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,11d51691-b09f-4422-aaa5-15a7bf2b628c.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/10/14/TipOfTheDayWinformDisplayingTheFormDerivedFromABaseClass.aspx</link>
      <pubDate>Wed, 14 Oct 2009 05:27:16 GMT</pubDate>
      <description>&lt;p&gt;
When starting a project, I always recommend inheriting objects from a base object,
regardless of whether you know you'll need it or not. Usually, they will contain common
functionality like error handling, debugging or other common methods which you'll
use over and over.
&lt;/p&gt;
&lt;p&gt;
In WinForms, however, this can cause a problem if you make the base form an abstract
class (another thing I recommend).&amp;nbsp; For example, take this simple form:
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/FormExample.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Now let's say I decide to derive this form from an abstract base class, which I will
call BaseForm:
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Windows.Forms;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; TestForm
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;abstract&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;BaseForm&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;Form&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; SomeCommonMethod()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;When I go to edit the UI again, I see this, and it scares
the heck out of me (looks scarier in VS2005)....&lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&lt;img src="http://www.dotnettechnologies.com/content/binary/ErrorPage1.png" border=0&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;!--EndFragment--&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
What this is telling you is that it can't render an abstract class BaseForm. So while
you are creating the application, you might&amp;nbsp;remove the abstract&amp;nbsp;identifier
from UI related base classes (with a note that they should be inherited from, not
used, as well as a /TODO marker to make sure you mark it as abstract before deployment). 
&lt;/p&gt;
&lt;p&gt;
Doing this will allow you to inherit from a base class while at the same time edit
the UI.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=11d51691-b09f-4422-aaa5-15a7bf2b628c" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,11d51691-b09f-4422-aaa5-15a7bf2b628c.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Windows</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=011670b6-c21b-465c-8637-aa8e2f3f86da</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,011670b6-c21b-465c-8637-aa8e2f3f86da.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,011670b6-c21b-465c-8637-aa8e2f3f86da.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=011670b6-c21b-465c-8637-aa8e2f3f86da</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Been quiet on the blogging front because I finally have clients for my "side" work.
I haven't even put it on my site yet, but I have been working with a contracting firm
to help screen candidates with technical interviews so they can place them in interviews
at the appropriate positions. It's been interesting, and so far the candidates have
been very strong. Strong enough that if I was a development manager again, I would
have hired them in a second. 
</p>
        <p>
In my last position where I was interviewing and hiring, I was surprised at how poor
some of the candidates were. Part of it was the method the company was using to locate
candidates. I understand they were trying to save money, but when it comes to quality
people, you can't skimp. One thing I will tell any developer is make sure you establish
good relationships with recruiters. Yes, it takes some effort, but it can reap benefits
when it comes to a job search or even in learning about unlisted jobs, or the environments
there. As they get to know you, good recruiters will match you to the environments
where you will thrive. I am amazed when developers complain that recruiters only want
to close the sale. While this is true of some, as a developer, you have a responsibility
of establishing the relationship with the recruiter so they look for your interests.
You'll quickly learn which recruiters they are.
</p>
        <p>
I also have my first interview coaching session coming up. One of these nights I am
going to get this information up on the <a href="http://www.rubiconcomputing.com/" target="_blank">Rubicon
Computing</a> site, but for now, it's all been word of mouth and careful marketing
to recruiters and developers I know. I have a nice AJAXified information request form,
but I need to work on some of the verbiage first.
</p>
        <p>
At some point things will slow down enough to put some more tips up. I have been developing
a list of them to write, so likely it will be a lot at once!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=011670b6-c21b-465c-8637-aa8e2f3f86da" />
      </body>
      <title>Employment screenings and coaching</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,011670b6-c21b-465c-8637-aa8e2f3f86da.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/10/07/EmploymentScreeningsAndCoaching.aspx</link>
      <pubDate>Wed, 07 Oct 2009 04:14:00 GMT</pubDate>
      <description>&lt;p&gt;
Been quiet on the blogging front because I finally have clients for my "side" work.
I haven't even put it on my site yet, but I have been working with a contracting firm
to help screen candidates with technical interviews so they can place them in interviews
at the appropriate positions. It's been interesting, and so far the candidates have
been very strong. Strong enough that if I was a development manager again, I would
have hired them in a second. 
&lt;/p&gt;
&lt;p&gt;
In my last position where I was interviewing and hiring, I was surprised at how poor
some of the candidates were. Part of it was the method the company was using to locate
candidates. I understand they were trying to save money, but when it comes to quality
people, you can't skimp. One thing I will tell any developer is make sure you establish
good relationships with recruiters. Yes, it takes some effort, but it can reap benefits
when it comes to a job search or even in learning about unlisted jobs, or the environments
there. As they get to know you, good recruiters will match you to the environments
where you will thrive. I am amazed when developers complain that recruiters only want
to close the sale. While this is true of some, as a developer, you have a responsibility
of establishing the relationship with the recruiter so they look for your interests.
You'll quickly learn which recruiters they are.
&lt;/p&gt;
&lt;p&gt;
I also have my first interview coaching session coming up. One of these nights I am
going to get this information up on the &lt;a href="http://www.rubiconcomputing.com/" target=_blank&gt;Rubicon
Computing&lt;/a&gt; site, but for now, it's all been word of mouth and careful marketing
to recruiters and developers I know. I have a nice AJAXified information request form,
but I need to work on some of the verbiage first.
&lt;/p&gt;
&lt;p&gt;
At some point things will slow down enough to put some more tips up. I have been developing
a list of them to write, so likely it will be a lot at once!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=011670b6-c21b-465c-8637-aa8e2f3f86da" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,011670b6-c21b-465c-8637-aa8e2f3f86da.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=a371e8a5-64e8-4e1c-9dd5-cd4a67243da8</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,a371e8a5-64e8-4e1c-9dd5-cd4a67243da8.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,a371e8a5-64e8-4e1c-9dd5-cd4a67243da8.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a371e8a5-64e8-4e1c-9dd5-cd4a67243da8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When using master pages, there are times when you want to access part of the Master
Page (e.g. a public property). One way of doing this is by defining the master page
with the MasterType directive.
</p>
        <p>
&lt;%@ MasterType VirtualPath="~/MyMasterPage.master"%&gt;
</p>
        <p>
By doing this, you can now access the MasterPage as a class Master, and programatically
(and with the benefits of compilation checking) access it.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a371e8a5-64e8-4e1c-9dd5-cd4a67243da8" />
      </body>
      <title>Tip of the Day: Directly accessing a Master Page</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,a371e8a5-64e8-4e1c-9dd5-cd4a67243da8.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/29/TipOfTheDayDirectlyAccessingAMasterPage.aspx</link>
      <pubDate>Tue, 29 Sep 2009 04:34:35 GMT</pubDate>
      <description>&lt;p&gt;
When using master pages, there are times when you want to access part of the Master
Page (e.g. a public property). One way of doing this is by defining the master page
with the MasterType directive.
&lt;/p&gt;
&lt;p&gt;
&amp;lt;%@ MasterType VirtualPath="~/MyMasterPage.master"%&amp;gt;
&lt;/p&gt;
&lt;p&gt;
By doing this, you can now access the MasterPage as a class Master, and programatically
(and with the benefits of compilation checking) access it.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a371e8a5-64e8-4e1c-9dd5-cd4a67243da8" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,a371e8a5-64e8-4e1c-9dd5-cd4a67243da8.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=7452f6fe-0a49-4452-87ba-d8110e86f4a4</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,7452f6fe-0a49-4452-87ba-d8110e86f4a4.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,7452f6fe-0a49-4452-87ba-d8110e86f4a4.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7452f6fe-0a49-4452-87ba-d8110e86f4a4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
So much is going on, where to begin. First, I'll start with <a href="http://www.microsoft.com/web/websitespark/" target="_blank">WebSpark</a>.
I've had my issues with Microsoft programs in the past, but this one does make up
some ground. First, I'll lead you to the place where I first heard of the program, <a href="http://weblogs.asp.net/scottgu/archive/2009/09/24/announcing-the-websitespark-program.aspx" target="_blank">Scott
Guthrie's site</a>.
</p>
        <p>
The gist of the program is if you are a small company (less than 10 developers) and
you are designing web sites for other companies, they'll give you development software
for 3 years for $100 (and server software). If you decide to keep it, you'll pay $999,
and even that is a bargain. You get upgrades (hint --&gt; VS2010) as well. This is
a huge deal with a very easy qualification.
</p>
        <p>
On a personal front, I was bidding on some things on eBay, and needed to pay for them
via PayPal. I haven't used either in years, primarily in that I got taken on eBay,
and PayPal refused to help on my dispute. The advised me that they hoped I used my
credit card so I can dispute that, as they were unable to help. Doesn't PayPal prefer
our checking accounts? 
</p>
        <p>
The issue came about because I ordered a very expensive GPS system which had near
realtime traffic updates. The listing described the GPS as in "mint, like new" condition
(the words from the ad). The problem was, the seller decided to make a little extra
money and sell the traffic antenna (costs $200 to replace) and not mention that in
their description of "mint". When I contacted PayPal to dispute the issue (after the
seller told me I was screwed), they were not helpful and refused my claim
agreeing with the seller.  Apparently mint does not mean complete. Never
again. Score one more victory (lost customer) for foreign customer service! I say
that because the emails had some of the worst English I have ever seen. Ever. I should
dig them out and post them kind of bad.
</p>
        <p>
But alas, there are certain things you can only find on eBay, and PayPal is the
only way to pay sometimes. I signed up for my account, and connected my credit card
to it this time. However, as part of their verification process, they process a $1.95
charge, then you have to enter the code. At the bottom is a disclaimer, which seemed
written by a 5 year old. To paraphrase, it went something like this:
</p>
        <p>
"If you contact your credit card company to get this transaction information, and
your credit card company complains to PayPal, your account may be cancelled." -- Nice...
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7452f6fe-0a49-4452-87ba-d8110e86f4a4" />
      </body>
      <title>Catching up is hard to do...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,7452f6fe-0a49-4452-87ba-d8110e86f4a4.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/29/CatchingUpIsHardToDo.aspx</link>
      <pubDate>Tue, 29 Sep 2009 04:23:27 GMT</pubDate>
      <description>&lt;p&gt;
So much is going on, where to begin. First, I'll start with &lt;a href="http://www.microsoft.com/web/websitespark/" target=_blank&gt;WebSpark&lt;/a&gt;.
I've had my issues with Microsoft programs in the past, but this one does make up
some ground. First, I'll lead you to the place where I first heard of the program, &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/09/24/announcing-the-websitespark-program.aspx" target=_blank&gt;Scott
Guthrie's site&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
The gist of the program is if you are a small company (less than 10 developers) and
you are designing web sites for other companies, they'll give you development software
for 3 years for $100 (and server software). If you decide to keep it, you'll pay $999,
and even that is a bargain. You get upgrades (hint --&amp;gt; VS2010) as well. This is
a huge deal with a very easy qualification.
&lt;/p&gt;
&lt;p&gt;
On a personal front, I was bidding on some things on eBay, and needed to pay for them
via PayPal. I haven't used either in years, primarily in that I got taken on eBay,
and PayPal refused to help on my dispute. The advised me that they hoped I used my
credit card so I can dispute that, as they were unable to help. Doesn't PayPal prefer
our checking accounts? 
&lt;/p&gt;
&lt;p&gt;
The issue came about because I ordered a very expensive GPS system which had near
realtime traffic updates. The listing described the GPS as in "mint, like new" condition
(the words from the ad). The problem was, the seller decided to make a little extra
money and sell the traffic antenna (costs $200 to replace) and not mention that in
their description of "mint". When I contacted PayPal to dispute the issue (after the
seller told me I was screwed), they were&amp;nbsp;not helpful&amp;nbsp;and refused my claim
agreeing with the seller.&amp;nbsp;&amp;nbsp;Apparently mint does not mean complete. Never
again. Score one more victory (lost customer) for foreign customer service! I say
that because the emails had some of the worst English I have ever seen. Ever. I should
dig them out and post them kind of bad.
&lt;/p&gt;
&lt;p&gt;
But alas, there are certain things you can only&amp;nbsp;find on eBay, and PayPal is the
only way to pay sometimes. I signed up for my account, and connected my credit card
to it this time. However, as part of their verification process, they process a $1.95
charge, then you have to enter the code. At the bottom is a disclaimer, which seemed
written by a&amp;nbsp;5 year old. To paraphrase, it went something like this:
&lt;/p&gt;
&lt;p&gt;
"If you contact your credit card company to get this transaction information, and
your credit card company complains to PayPal, your account may be cancelled." -- Nice...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7452f6fe-0a49-4452-87ba-d8110e86f4a4" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,7452f6fe-0a49-4452-87ba-d8110e86f4a4.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=886aa54f-3ce6-48ac-8164-5733d9a870da</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,886aa54f-3ce6-48ac-8164-5733d9a870da.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,886aa54f-3ce6-48ac-8164-5733d9a870da.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=886aa54f-3ce6-48ac-8164-5733d9a870da</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you'd like to redirect your page trace infomation to a file (which can be useful
when you are trying to run down a problem and don't want the world to see your trace
information during testing), it's as simple as this:
</p>
        <p>
Add this to your web.config:
</p>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
            <p>
&lt;
</p>
          </font>
        </font>
        <font color="#a31515" size="2">
          <font color="#a31515" size="2">trace</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
          </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">enabled</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">=</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">true</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
          </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">traceMode</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">=</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">SortByTime</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
          </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">pageOutput</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">=</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">false</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
          </font>
        </font>
        <font color="#ff0000" size="2">
          <font color="#ff0000" size="2">localOnly</font>
        </font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">=</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">false</font>
        </font>
        <font color="#000000" size="2">"</font>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2"> /&gt;</font>
        </font>
        <p>
          <font color="#0000ff" size="2">
            <font color="#0000ff" size="2">
              <font color="#003300">The
key is the <font color="#ff0000">pageOutput</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=</font></font><font color="#000000" size="2">"</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">false</font></font><font color="#000000" size="2">" <font color="#003300">which
tells the framework to redirect the trace info to the trace.axd file. To view the
trace information, you just need to load the page in the browser, such as:</font></font></font>
            </font>
          </font>
        </p>
        <p>
          <font color="#0000ff" size="2">
            <font color="#0000ff" size="2">
              <font color="#003300">http://localhost:4774/trace.axd</font>
            </font>
          </font>
        </p>
        <p>
          <font color="#0000ff" size="2">
            <font color="#0000ff" size="2">
              <font color="#003300">This
will allow you to see the trace history of any browsed files since the trace was started,
as well as clearing the trace history. Just remember to remove this before you deploy
(or make sure you compile in release mode!).</font>
            </font>
          </font>
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=886aa54f-3ce6-48ac-8164-5733d9a870da" />
      </body>
      <title>Tip of the Day: Redirecting page trace output to a file</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,886aa54f-3ce6-48ac-8164-5733d9a870da.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/25/TipOfTheDayRedirectingPageTraceOutputToAFile.aspx</link>
      <pubDate>Fri, 25 Sep 2009 05:11:05 GMT</pubDate>
      <description>&lt;p&gt;
If you'd like to redirect your page trace infomation to a file (which can be useful
when you are trying to run down a problem and don't want the world to see your trace
information during testing), it's as simple as this:
&lt;/p&gt;
&lt;p&gt;
Add this to your web.config:
&lt;/p&gt;
&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt; 
&lt;p&gt;
&amp;lt;
&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515 size=2&gt;&lt;font color=#a31515 size=2&gt;trace&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000 size=2&gt;&lt;font color=#ff0000 size=2&gt;enabled&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;true&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000 size=2&gt;&lt;font color=#ff0000 size=2&gt;traceMode&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;SortByTime&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000 size=2&gt;&lt;font color=#ff0000 size=2&gt;pageOutput&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;false&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000 size=2&gt;&lt;font color=#ff0000 size=2&gt;localOnly&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;false&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt; /&amp;gt;&lt;/font&gt;&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#003300&gt;The key
is the &lt;font color=#ff0000&gt;pageOutput&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;false&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt;" &lt;font color=#003300&gt;which
tells the framework to redirect the trace info to the trace.axd file. To view the
trace information, you just need to load the page in the browser, such as:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#003300&gt;http://localhost:4774/trace.axd&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#003300&gt;This will
allow you to see the trace history of any browsed files since the trace was started,
as well as clearing the trace history. Just remember to remove this before you deploy
(or make sure you compile in release mode!).&lt;/font&gt;
&lt;/p&gt;
&gt;&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=886aa54f-3ce6-48ac-8164-5733d9a870da" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,886aa54f-3ce6-48ac-8164-5733d9a870da.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Debugging</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=48a3579a-9701-429e-9f5f-55e0faa9f6c3</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,48a3579a-9701-429e-9f5f-55e0faa9f6c3.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,48a3579a-9701-429e-9f5f-55e0faa9f6c3.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=48a3579a-9701-429e-9f5f-55e0faa9f6c3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It's time I got back to the interviewing tips as well. So here's an OOP question a
suprising number of candidates miss:
</p>
        <p>
          <strong>Question: </strong>In C#, what's the <em>virtual</em> keywork used for. 
</p>
        <p>
          <strong>Answer: </strong>A method marked virtual has an implementation, but inheriting
objects may override the implementation and provide their own implementation. This
differs from the <em>abstract</em> keyword in that the base class does not have an
implementation, and the deriving class <strong>must</strong> provide an implementation.
</p>
        <p>
This is a key concept to object-oriented programming. If you missed this one, you
can get more information on <a href="http://msdn.microsoft.com/en-us/library/9fkccyh4(VS.80).aspx" target="_blank">Microsoft's
MSDN site</a>.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=48a3579a-9701-429e-9f5f-55e0faa9f6c3" />
      </body>
      <title>Interviewing Question of the Day: Virtual Keyword</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,48a3579a-9701-429e-9f5f-55e0faa9f6c3.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/23/InterviewingQuestionOfTheDayVirtualKeyword.aspx</link>
      <pubDate>Wed, 23 Sep 2009 04:45:06 GMT</pubDate>
      <description>&lt;p&gt;
It's time I got back to the interviewing tips as well. So here's an OOP question a
suprising number of&amp;nbsp;candidates miss:
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Question: &lt;/strong&gt;In C#, what's the &lt;em&gt;virtual&lt;/em&gt; keywork used for. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Answer: &lt;/strong&gt;A method marked virtual has an implementation, but inheriting
objects may override the implementation and provide their own implementation. This
differs from the &lt;em&gt;abstract&lt;/em&gt; keyword in that the base class does not have an
implementation, and the deriving class &lt;strong&gt;must&lt;/strong&gt; provide an implementation.
&lt;/p&gt;
&lt;p&gt;
This is a key concept to object-oriented programming. If you missed this one, you
can get more information on &lt;a href="http://msdn.microsoft.com/en-us/library/9fkccyh4(VS.80).aspx" target=_blank&gt;Microsoft's
MSDN site&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=48a3579a-9701-429e-9f5f-55e0faa9f6c3" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,48a3579a-9701-429e-9f5f-55e0faa9f6c3.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=379a8a5c-997d-4e80-a93d-6c47af8f13c7</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,379a8a5c-997d-4e80-a93d-6c47af8f13c7.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,379a8a5c-997d-4e80-a93d-6c47af8f13c7.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=379a8a5c-997d-4e80-a93d-6c47af8f13c7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
So I made a lot of progress on my WinForm application today, and I ran across an issue
where I was displaying two tooltips for the same control. I probably would never usually
have noticed it, but in this case, I was dynamically setting the contents of the tooltips,
and the length of the first tip (which was underneath) was substantially less than
the length of the topmost tip. 
</p>
        <p>
In debugging the problem, I was looking for a method to clear all previous tooltips
associated to the control. I found one (but didn't seem to work), but also noticed
a plethora of other cool functionality available to me. Some of the neat properties:
</p>
        <p>
IsBalloon --&gt; Set to true, creates a balloon style tooltip
</p>
        <p>
ToolTipTitle --&gt; A string you can use create a "title" for your tool tip.
</p>
        <p>
ToolTipIcon --&gt; A constant which shows an appropriate icon to the left of the title/tooltip
</p>
        <p>
BackColor --&gt; allows you to set the background color of the tip
</p>
        <p>
There are many more, but I have changed my tooltip routine to look like this:
</p>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">static</span><span style="COLOR: blue">void</span> SetToolTip(System.Windows.Forms.<span style="COLOR: #2b91af">Control</span> ctrl, <span style="COLOR: blue">string</span> description)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            System.Windows.Forms.<span style="COLOR: #2b91af">ToolTip</span> tt
= <span style="COLOR: blue">new</span> System.Windows.Forms.<span style="COLOR: #2b91af">ToolTip</span>();
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            tt.ShowAlways = <span style="COLOR: blue">false</span>;
</p>
          <p style="MARGIN: 0px">
            tt.IsBalloon = <span style="COLOR: blue">true</span>;
</p>
          <p style="MARGIN: 0px">
            tt.UseAnimation = <span style="COLOR: blue">true</span>;
</p>
          <p style="MARGIN: 0px">
            tt.ToolTipTitle = <span style="COLOR: #a31515">"Info"</span>;
</p>
          <p style="MARGIN: 0px">
            tt.ToolTipIcon = System.Windows.Forms.<span style="COLOR: #2b91af">ToolTipIcon</span>.Info;
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            tt.SetToolTip(ctrl, description);
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">The end result went from this:</font>
          </p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">
            </font> 
</p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">
            </font> 
</p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">
            </font> 
</p>
          <img src="http://www.dotnettechnologies.com/content/binary/old_tooltip.png" border="0" />
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">To this!</font>
          </p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">
            </font> 
</p>
        </div>
        <!--EndFragment-->
        <img src="http://www.dotnettechnologies.com/content/binary/tooltip.png" border="0" />
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=379a8a5c-997d-4e80-a93d-6c47af8f13c7" />
      </body>
      <title>Tip of the day: More WinForm tooltip tips...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,379a8a5c-997d-4e80-a93d-6c47af8f13c7.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/23/TipOfTheDayMoreWinFormTooltipTips.aspx</link>
      <pubDate>Wed, 23 Sep 2009 03:58:23 GMT</pubDate>
      <description>&lt;p&gt;
So I made a lot of progress on my WinForm application today, and I ran across an issue
where I was displaying two tooltips for the same control. I probably would never usually
have noticed it, but in this case, I was dynamically setting the contents of the tooltips,
and the length of the first tip (which was underneath) was substantially less than
the length of the topmost tip. 
&lt;/p&gt;
&lt;p&gt;
In debugging the problem, I was looking for a method to clear all previous tooltips
associated to the control. I found one (but didn't seem to work), but also noticed
a plethora of other cool functionality available to me. Some of the neat properties:
&lt;/p&gt;
&lt;p&gt;
IsBalloon --&amp;gt; Set to true, creates a balloon style tooltip
&lt;/p&gt;
&lt;p&gt;
ToolTipTitle --&amp;gt; A string you can use create a "title" for your tool tip.
&lt;/p&gt;
&lt;p&gt;
ToolTipIcon --&amp;gt; A constant which shows an appropriate icon to the left of the title/tooltip
&lt;/p&gt;
&lt;p&gt;
BackColor --&amp;gt; allows you to set the background color of the tip
&lt;/p&gt;
&lt;p&gt;
There are many more, but I have changed my tooltip routine to look like this:
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; SetToolTip(System.Windows.Forms.&lt;span style="COLOR: #2b91af"&gt;Control&lt;/span&gt; ctrl, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; description)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.Windows.Forms.&lt;span style="COLOR: #2b91af"&gt;ToolTip&lt;/span&gt; tt
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; System.Windows.Forms.&lt;span style="COLOR: #2b91af"&gt;ToolTip&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tt.ShowAlways = &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tt.IsBalloon = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tt.UseAnimation = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tt.ToolTipTitle = &lt;span style="COLOR: #a31515"&gt;"Info"&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tt.ToolTipIcon = System.Windows.Forms.&lt;span style="COLOR: #2b91af"&gt;ToolTipIcon&lt;/span&gt;.Info;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tt.SetToolTip(ctrl, description);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;The end result went from this:&lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/old_tooltip.png" border=0&gt; 
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;To this!&lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img src="http://www.dotnettechnologies.com/content/binary/tooltip.png" border=0&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=379a8a5c-997d-4e80-a93d-6c47af8f13c7" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,379a8a5c-997d-4e80-a93d-6c47af8f13c7.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Windows</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=a5809af6-e642-4d62-b305-6d99b65685c0</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,a5809af6-e642-4d62-b305-6d99b65685c0.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,a5809af6-e642-4d62-b305-6d99b65685c0.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a5809af6-e642-4d62-b305-6d99b65685c0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
You can always grab the ToolTip control out of the toolbox, but I prefer to add a
common function to a base form so I don't have to remember to add this control to
the form. Then, any time I want to add a tooltip, I pass in the control and the text,
and this simple snippet will take care of it for me. I remembered it as I needed to
add some tooltips, which is something the existing application lacks.
</p>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <span style="COLOR: #2b91af">
            <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
              <p style="MARGIN: 0px">
                <span style="COLOR: blue">        protected</span>
                <span style="COLOR: blue">void</span> SetToolTip(<span style="COLOR: teal">IContainer</span> component, <span style="COLOR: teal">Control</span> ctrl, <span style="COLOR: blue">string</span> tip)
</p>
              <p style="MARGIN: 0px">
        {
</p>
              <p style="MARGIN: 0px">
            <span style="COLOR: blue">try</span></p>
              <p style="MARGIN: 0px">
            {
</p>
              <p style="MARGIN: 0px">
 
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: teal">ToolTip</span> tooltip
= <span style="COLOR: blue">new</span><span style="COLOR: teal">ToolTip</span>(component);
</p>
              <p style="MARGIN: 0px">
                tooltip.SetToolTip(ctrl,
tip);
</p>
              <p style="MARGIN: 0px">
                tooltip.Active
= <span style="COLOR: blue">true</span>;
</p>
              <p style="MARGIN: 0px">
            }
</p>
              <p style="MARGIN: 0px">
            <span style="COLOR: blue">catch</span></p>
              <p style="MARGIN: 0px">
            {
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: green">//Don't
worry</span></p>
              <p style="MARGIN: 0px">
            }
</p>
              <p style="MARGIN: 0px">
        }
</p>
            </div>
            <!--EndFragment-->
          </span>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
Usage: 
</p>
          <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   41</span> SetToolTip(<span style="COLOR: blue">this</span>.components,
lvwCategories, <span style="COLOR: maroon">"Right click for menu options..."</span>);
</p>
          </div>
          <!--EndFragment-->
        </div>
        <!--EndFragment-->
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a5809af6-e642-4d62-b305-6d99b65685c0" />
      </body>
      <title>Tip of the Day: WinForms and adding tooltips programmatically</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,a5809af6-e642-4d62-b305-6d99b65685c0.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/22/TipOfTheDayWinFormsAndAddingTooltipsProgrammatically.aspx</link>
      <pubDate>Tue, 22 Sep 2009 04:38:13 GMT</pubDate>
      <description>&lt;p&gt;
You can always grab the ToolTip control out of the toolbox, but I prefer to add a
common function to a base form so I don't have to remember to add this control to
the form. Then, any time I want to add a tooltip, I pass in the control and the text,
and this simple snippet will take care of it for me. I remembered it as I needed to
add some tooltips, which is something the existing application lacks.
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt; 
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; SetToolTip(&lt;span style="COLOR: teal"&gt;IContainer&lt;/span&gt; component, &lt;span style="COLOR: teal"&gt;Control&lt;/span&gt; ctrl, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; tip)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;ToolTip&lt;/span&gt; tooltip
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ToolTip&lt;/span&gt;(component);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tooltip.SetToolTip(ctrl,
tip);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; tooltip.Active
= &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;catch&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//Don't
worry&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/span&gt; 
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
Usage: 
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;41&lt;/span&gt;&amp;nbsp;SetToolTip(&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.components,
lvwCategories, &lt;span style="COLOR: maroon"&gt;"Right click for menu options..."&lt;/span&gt;);
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a5809af6-e642-4d62-b305-6d99b65685c0" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,a5809af6-e642-4d62-b305-6d99b65685c0.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=faf3b8ac-f38e-4e82-8546-505f90c64fdd</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,faf3b8ac-f38e-4e82-8546-505f90c64fdd.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,faf3b8ac-f38e-4e82-8546-505f90c64fdd.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=faf3b8ac-f38e-4e82-8546-505f90c64fdd</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Going to try to make up for some lost time here, as this new project is taking up
a good deal of my time. OK, not exactly true initially, as it took a full week to
get the access I needed, but now I have my environment set up, and I submitted my
Functional Specification Document for the project for review. Technically I am not
supposed to begin coding until mid-October, but I don't think the Technical Document
will take <em>nearly</em> that long, so I am creating some prototypes in the mean
time to foster some discussion of some of the changes I am making.
</p>
        <p>
So I am going to post some WinForm related tips, simply because that's what I have
been working. I have a long list of things I wanted to write about though, so who
knows what will end up here while I have the energy to do so.
</p>
        <p>
As I review this project, I came across a lot of things I would love to change. For
example, everywhere there is data access code, they repeat the same functionality.
By encapsulating that code, I could probably reduce the overall lines fo code and
complexity considerably. However, I was advised not to, because changing code means
more testing, and even with that, if something changed breaks, there will be Hell
to pay. 
</p>
        <p>
Regardless if I try to take that risk, which I feel is well warranted, I also see
lots of opportunities for CodeSmith templates to generate the code. It's not a big
project, and it will probably take longer to write all the specifications than it
will to actually code, but that's how it goes sometimes.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=faf3b8ac-f38e-4e82-8546-505f90c64fdd" />
      </body>
      <title>New projects take time</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,faf3b8ac-f38e-4e82-8546-505f90c64fdd.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/22/NewProjectsTakeTime.aspx</link>
      <pubDate>Tue, 22 Sep 2009 04:15:25 GMT</pubDate>
      <description>&lt;p&gt;
Going to try to make up for some lost time here, as this new project is taking up
a good deal of my time. OK, not exactly true initially, as it took a full week to
get the access I needed, but now I have my environment set up, and I submitted my
Functional Specification Document for the project for review. Technically I am not
supposed to begin coding until mid-October, but I don't think the Technical Document
will take &lt;em&gt;nearly&lt;/em&gt; that long, so I am creating some prototypes in the mean
time to foster some discussion of some of the changes I am making.
&lt;/p&gt;
&lt;p&gt;
So I am going to post some WinForm related tips, simply because that's what I have
been working. I have a long list of things I wanted to write about though, so who
knows what will end up here while I have the energy to do so.
&lt;/p&gt;
&lt;p&gt;
As I review this project, I came across a lot of things I would love to change. For
example, everywhere there is data access code, they repeat the same functionality.
By encapsulating that code, I could probably reduce the overall lines fo code and
complexity considerably. However, I was advised not to, because changing code means
more testing, and even with that, if something changed breaks, there will be Hell
to pay. 
&lt;/p&gt;
&lt;p&gt;
Regardless if I try to take that risk, which I feel is well warranted, I also see
lots of opportunities for CodeSmith templates to generate the code. It's not a big
project, and it will probably take longer to write all the specifications than it
will to actually code, but that's how it goes sometimes.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=faf3b8ac-f38e-4e82-8546-505f90c64fdd" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,faf3b8ac-f38e-4e82-8546-505f90c64fdd.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=f1dddb05-8006-4567-a998-73be29abf147</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,f1dddb05-8006-4567-a998-73be29abf147.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,f1dddb05-8006-4567-a998-73be29abf147.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f1dddb05-8006-4567-a998-73be29abf147</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Earlier, I posted a <a href="http://www.rubiconcomputing.com/DevArea.aspx" target="_blank">useful
link</a> at <a href="http://www.rubiconcomputing.com/" target="_blank">Rubicon Computing
Solutions </a>for a poster of all the keyboard shortcuts in the Visual Studio IDE.
As I was looking for some more neat shortcuts, I came across this site with more useful
tips -- mainly, <a href="http://msdn.microsoft.com/en-us/library/bb245788(VS.80).aspx" target="_blank">how
to enumerate all the shortcuts, and how to customize them</a>. 
</p>
        <p>
I have had many occasions to have to remap the shortcuts, primarily related to add-ons
I have placed in my IDE. The macro in the referenced Microsoft link will help show
what the <em>current</em> mappings are, which would be extremely useful if you needed
to do a lot of remapping.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=f1dddb05-8006-4567-a998-73be29abf147" />
      </body>
      <title>Useful Link -- Information on shortcut keys in the Visual Studio IDE</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,f1dddb05-8006-4567-a998-73be29abf147.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/16/UsefulLinkInformationOnShortcutKeysInTheVisualStudioIDE.aspx</link>
      <pubDate>Wed, 16 Sep 2009 05:22:12 GMT</pubDate>
      <description>&lt;p&gt;
Earlier, I posted a &lt;a href="http://www.rubiconcomputing.com/DevArea.aspx" target=_blank&gt;useful
link&lt;/a&gt; at &lt;a href="http://www.rubiconcomputing.com/" target=_blank&gt;Rubicon Computing
Solutions &lt;/a&gt;for a poster of all the keyboard shortcuts in the Visual Studio IDE.
As I was looking for some more neat shortcuts, I came across this site with more useful
tips -- mainly, &lt;a href="http://msdn.microsoft.com/en-us/library/bb245788(VS.80).aspx" target=_blank&gt;how
to enumerate all the shortcuts, and how to customize them&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
I have had many occasions to have to remap the shortcuts, primarily related to add-ons
I have placed in my IDE. The macro in the referenced Microsoft link will help show
what the &lt;em&gt;current&lt;/em&gt; mappings are, which would be extremely useful if you needed
to do a lot of remapping.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=f1dddb05-8006-4567-a998-73be29abf147" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,f1dddb05-8006-4567-a998-73be29abf147.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=0ba9e1fb-994f-4406-beed-b2c12876ad5c</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,0ba9e1fb-994f-4406-beed-b2c12876ad5c.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,0ba9e1fb-994f-4406-beed-b2c12876ad5c.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0ba9e1fb-994f-4406-beed-b2c12876ad5c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am getting settled in my new project, and it only took me a week to get rights to
install anything on the laptop! A lot of people would say "Wow, a billable week with
no work!" but personally, the days just drag by. I'd much rather be buried in code.
I did make some good use of the time though, digging into what documentation I could
find and creating a new Functional Specification Document. I did finally get my rights,
so tomorrow will be spent installing things and looking into code again.
</p>
        <p>
I did get some reading done though, and I saw that in VS2010 C# will have optional
and named parameters. I know the VB crowd (of which I come from) will chuckle a little
at that, as that feature has been around forever. Until now, it's required C# developers
to overload functions. Nothing Earth-shattering about this feature, other than as
part of it, C# will support named parameters and default values as well as part of
the implementation (the default values are part of the defiinition of the function).
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0ba9e1fb-994f-4406-beed-b2c12876ad5c" />
      </body>
      <title>More VS2010 features -- optional parameters in C#</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,0ba9e1fb-994f-4406-beed-b2c12876ad5c.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/16/MoreVS2010FeaturesOptionalParametersInC.aspx</link>
      <pubDate>Wed, 16 Sep 2009 04:36:56 GMT</pubDate>
      <description>&lt;p&gt;
I am getting settled in my new project, and it only took me a week to get rights to
install anything on the laptop! A lot of people would say "Wow, a billable week with
no work!" but personally, the days just drag by. I'd much rather be buried in code.
I did make some good use of the time though, digging into what documentation I could
find and creating a new Functional Specification Document. I did finally get my rights,
so tomorrow will be spent installing things and looking into code again.
&lt;/p&gt;
&lt;p&gt;
I did get some reading done though, and I saw that in VS2010 C# will have optional
and named parameters. I know the VB crowd (of which I come from) will chuckle a little
at that, as that feature has been around forever. Until now, it's required C# developers
to overload functions. Nothing Earth-shattering about this feature, other than as
part of it, C# will support named parameters and default values as well as part of
the implementation (the default values are part of the defiinition of the function).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0ba9e1fb-994f-4406-beed-b2c12876ad5c" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,0ba9e1fb-994f-4406-beed-b2c12876ad5c.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>General</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=46475fa1-9c46-45fc-aed3-d3e4fdf045f4</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,46475fa1-9c46-45fc-aed3-d3e4fdf045f4.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,46475fa1-9c46-45fc-aed3-d3e4fdf045f4.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=46475fa1-9c46-45fc-aed3-d3e4fdf045f4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Most people set break points, and iterate through code until they find the condition
they were looking for. Although (IMHO) poorly documented, it's possible to place a
condition on your breakpoint to have it stop when your condition is met. 
</p>
        <p>
Let's look at this code:
</p>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <span style="COLOR: blue">
            <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   20</span>        
    <span style="COLOR: blue">int</span> maxIdx = 15;
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   21</span>        
    <span style="COLOR: blue">for</span>(<span style="COLOR: blue">int</span> idx=1;
idx &lt; maxIdx; idx++)
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   22</span>        
    {
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   23</span>        
        Response.Write(<span style="COLOR: #a31515">"Index:"</span> +
idx.ToString());
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   24</span>        
    }
</p>
              <p style="MARGIN: 0px">
 
</p>
            </div>
            <!--EndFragment-->
          </span>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">If I were to place a breakpoint on line 23, the debugger
would stop every time it hit the Response.Write. For a small loop that *might* be
ok, but let's say I notice something weird with the 13th item. Within the breakpoint
itself, I can place a condition when I actually want it to stop, in this case, the
13th iteration.</font>
          </p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">
            </font> 
</p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">By right clicking on the debug "circle", the following
context-sensitive menu comes up: </font>
          </p>
          <p style="MARGIN: 0px">
 
</p>
        </div>
        <p>
          <!--EndFragment-->
          <img src="http://www.dotnettechnologies.com/content/binary/DebugCondition.png" border="0" />
        </p>
        <p>
Select "Condition" and the following dialog appears:
</p>
        <p>
 
</p>
        <p>
          <img src="http://www.dotnettechnologies.com/content/binary/BreakCondition.png" border="0" />
        </p>
        <p>
In the textbox, place the condition that you want. In this case, when idx == 13, the
condition is true, and therefore, the breakpoint will now be active and execution
will stop.
</p>
        <p>
When a condition for a breakpoint is set, you'll notice the image for the breakpoint
changes as well:
</p>
        <img src="http://www.dotnettechnologies.com/content/binary/condbreak.png" border="0" />
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=46475fa1-9c46-45fc-aed3-d3e4fdf045f4" />
      </body>
      <title>Tip of the Day: Debugging -- Conditional Breaks</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,46475fa1-9c46-45fc-aed3-d3e4fdf045f4.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/07/TipOfTheDayDebuggingConditionalBreaks.aspx</link>
      <pubDate>Mon, 07 Sep 2009 22:46:14 GMT</pubDate>
      <description>&lt;p&gt;
Most people&amp;nbsp;set break points, and iterate through code until they find the condition
they were looking for. Although (IMHO) poorly documented, it's possible to place a
condition on your breakpoint to have it stop when your condition is met. 
&lt;/p&gt;
&lt;p&gt;
Let's look at this code:
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt; 
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; maxIdx = 15;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;for&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; idx=1;
idx &amp;lt; maxIdx; idx++)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Response.Write(&lt;span style="COLOR: #a31515"&gt;"Index:"&lt;/span&gt; +
idx.ToString());
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/span&gt; 
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;If I were to place a breakpoint on line 23, the debugger
would stop every time it hit the Response.Write. For a small loop that *might* be
ok, but let's say I notice something weird with the 13th item. Within the breakpoint
itself, I can place a condition when I actually want it to stop, in this case, the
13th iteration.&lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;By right clicking on the debug "circle", the following context-sensitive
menu comes up: &lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;!--EndFragment--&gt;&lt;img src="http://www.dotnettechnologies.com/content/binary/DebugCondition.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Select "Condition" and the following dialog appears:
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/BreakCondition.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
In the textbox, place the condition that you want. In this case, when idx == 13, the
condition is true, and therefore, the breakpoint will now be active and execution
will stop.
&lt;/p&gt;
&lt;p&gt;
When a condition for a breakpoint is set, you'll notice the image for the breakpoint
changes as well:
&lt;/p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/condbreak.png" border=0&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=46475fa1-9c46-45fc-aed3-d3e4fdf045f4" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,46475fa1-9c46-45fc-aed3-d3e4fdf045f4.aspx</comments>
      <category>All Things</category>
      <category>Debugging</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=f42ed926-5622-4a75-ba3e-8f36637b572b</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,f42ed926-5622-4a75-ba3e-8f36637b572b.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,f42ed926-5622-4a75-ba3e-8f36637b572b.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f42ed926-5622-4a75-ba3e-8f36637b572b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This has been around for quite some time, but I am always suprised when I go to a
new client site at the number of developers who don't know how to make the debugger
stop when it encounters an error. This is a repeat tip of a long time ago, as it's
just that useful. It's a very useful debug trick because some projects are so
large, you don't know where to start looking for an issue. Additionally, an error
may actually be occurring somewhere unexpected because it's getting caught in error
handling.
</p>
        <p>
By setting it to break on "Thrown", the debugger will stop right where an error originates.
To turn this functionality on, you can select the "Debug" menu item, and select "Exceptions".
For you hot key fans out there, you can invoke the dialog with Ctrl+Alt+E. When you
do, you'll see the following dialog. Mark the "Thrown" box for the "Common Language
runtime Exceptions" as shown below.
</p>
        <p>
          <img src="http://www.dotnettechnologies.com/content/binary/BreakOnError.png" border="0" />
        </p>
        <p>
When done debugging, save yourself some grief and uncheck the "Thrown" box, otherwise
you'll be stopping a LOT when you don't mean to.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=f42ed926-5622-4a75-ba3e-8f36637b572b" />
      </body>
      <title>Tip of the Day: Debugging -- Break on Error</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,f42ed926-5622-4a75-ba3e-8f36637b572b.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/07/TipOfTheDayDebuggingBreakOnError.aspx</link>
      <pubDate>Mon, 07 Sep 2009 22:28:20 GMT</pubDate>
      <description>&lt;p&gt;
This has been around for quite some time, but I am always suprised when I go to a
new client site at the number of developers who don't know how to make the debugger
stop when it encounters an error. This is a repeat tip of a long time ago, as it's
just that useful.&amp;nbsp;It's a very useful debug trick because some projects are so
large, you don't know where to start looking for an issue. Additionally, an error
may actually be occurring somewhere unexpected because it's getting caught in error
handling.
&lt;/p&gt;
&lt;p&gt;
By setting it to break on "Thrown", the debugger will stop right where an error originates.
To turn this functionality on, you can select the "Debug" menu item, and select "Exceptions".
For you hot key fans out there, you can invoke the dialog with Ctrl+Alt+E. When you
do, you'll see the following dialog. Mark the "Thrown" box for the "Common Language
runtime Exceptions" as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/BreakOnError.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
When done debugging, save yourself some grief and uncheck the "Thrown" box, otherwise
you'll be stopping a LOT when you don't mean to.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=f42ed926-5622-4a75-ba3e-8f36637b572b" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,f42ed926-5622-4a75-ba3e-8f36637b572b.aspx</comments>
      <category>All Things</category>
      <category>Debugging</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=36655dbd-218c-4fcb-b596-e118b6130507</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,36655dbd-218c-4fcb-b596-e118b6130507.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,36655dbd-218c-4fcb-b596-e118b6130507.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=36655dbd-218c-4fcb-b596-e118b6130507</wfw:commentRss>
      <title>Looking into Microsoft Expression -- A design tool</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,36655dbd-218c-4fcb-b596-e118b6130507.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/05/LookingIntoMicrosoftExpressionADesignTool.aspx</link>
      <pubDate>Sat, 05 Sep 2009 15:55:17 GMT</pubDate>
      <description>&lt;p&gt;
As I was looking through &lt;a href="http://www.hanselman.com/blog/ScottHanselmans2009UltimateDeveloperAndPowerUsersToolListForWindows.aspx" target=_blank&gt;Scott
Hanselman's List of Tools for&amp;nbsp;2009&lt;/a&gt;, I saw a reference for &lt;a href="http://www.microsoft.com/expression/" target-?_blank?&gt;Microsoft's
Sketchflow&lt;/a&gt;&amp;nbsp;(part of Microsoft Expression), which allows you to design (among
other things) and work through ideas prior to coding. I am going to check it out this
weekend, and maybe some of the alternate tools he recommended for his post.&amp;nbsp;
I might even have to dust off my Table PC, as it seems like a good combination.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=36655dbd-218c-4fcb-b596-e118b6130507" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,36655dbd-218c-4fcb-b596-e118b6130507.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=27255803-b360-4bd0-ba4f-3382811b3ada</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,27255803-b360-4bd0-ba4f-3382811b3ada.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,27255803-b360-4bd0-ba4f-3382811b3ada.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=27255803-b360-4bd0-ba4f-3382811b3ada</wfw:commentRss>
      <title>Tip of the Day: A brief explanation of extension methods</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,27255803-b360-4bd0-ba4f-3382811b3ada.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/04/TipOfTheDayABriefExplanationOfExtensionMethods.aspx</link>
      <pubDate>Fri, 04 Sep 2009 05:10:29 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;There’s a very powerful feature in .Net 3.5
called extension methods. In an earlier blog, I used an extension method in my LINQ
to XML to format the date retrieved from an RSS feed. If you’re new to the 3.5 framework,
you may be wondering what the big deal is.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;As a consultant, I have to look at a lot of
old and 3&lt;sup&gt;rd&lt;/sup&gt; party code. There are times when I don’t have access to the
source code, and I need to add some additional functionality to a class. If I can
inherit from the base class, I can just inherit the class and extend it. But what
do I do if the class is sealed? Prior to .et 3.5, my options were limited and certainly
not as object oriented. I’d have to write some type of wrapper of common function
to create the functionality.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;As an example, let’s say I wanted to extend
string with some additional functionality, such as adding in functionality to reverse
a string easily. I create my new class, and try to inherit from the String class,
but I get a compilation error. Let’s look at the definition of the String class in
.Net:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="BACKGROUND: #dddddd; MARGIN: 0in 0in 0pt; VERTICAL-ALIGN: top; WORD-BREAK: break-all; LINE-HEIGHT: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;[SerializableAttribute]&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="BACKGROUND: #dddddd; MARGIN: 0in 0in 0pt; VERTICAL-ALIGN: top; WORD-BREAK: break-all; LINE-HEIGHT: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;[ComVisibleAttribute(&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;true&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;)]&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="BACKGROUND: #dddddd; MARGIN: 0in 0in 0pt; VERTICAL-ALIGN: top; WORD-BREAK: break-all; LINE-HEIGHT: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt; sealed &lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;class&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt; String
: IComparable, 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="BACKGROUND: #dddddd; MARGIN: 0in 0in 0pt; VERTICAL-ALIGN: top; WORD-BREAK: break-all; LINE-HEIGHT: normal; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ICloneable,
IConvertible, IComparable&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;string&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&amp;gt;,
IEnumerable&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;char&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;&amp;gt;, 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;span style="FONT-SIZE: 12pt; COLOR: black; LINE-HEIGHT: 115%; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;IEnumerable,
IEquatable&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;string&lt;/span&gt;&lt;span style="FONT-SIZE: 12pt; COLOR: black; LINE-HEIGHT: 115%; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Because the class is sealed, I can’t inherit
from it. Prior to .Net 3.5, I am going to have to create a function and pass in the
string. By using extension methods, I am no longer restricted by the “sealed” keywords. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Reverses the specified string.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="s"&amp;gt;The string to reverse.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;returns&amp;gt;Reversed string&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; Reverse(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; s)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;char&lt;/span&gt;[]
arr &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; s.ToCharArray();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Array.Reverse(arr);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;(arr);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri size=3&gt;The code above extends any string with a new Reverse function,
which reverses the referenced string. Here’s how it is used:&lt;/font&gt;
&lt;/p&gt;
&lt;font face=Calibri size=3&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; testString &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"MyString"&lt;/span&gt;;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; reversedString &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; testString.Reverse();&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
The new reverse function shows up in Intellisense for any string, which helps speed
up coding as well.
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
So how did this work? It’s all in the definition. First, the class and the function
has to be defined as static. Second, the first parameter must begin with &lt;i style="mso-bidi-font-style: normal"&gt;this&lt;/i&gt; and
is a reference to the type this method extends.
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
There are some restrictions to static methods. For example, the extension method can
only access public methods of the referenced class. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
Below are some more examples of extending the string class with some additional functionality.
A couple of days ago, I posted some examples of getting values from a DataRow safely.
This would be another great refactor opportunity to extend the DataRow class to provide
this functionality right from the DataRow itself.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Globalization;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Text.RegularExpressions;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Threading;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;namespace&lt;/span&gt; Rubicon.Common&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; StringExtensions&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Reverses the specified string.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="s"&amp;gt;The string to reverse.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;returns&amp;gt;Reversed string&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; Reverse(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; s)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;char&lt;/span&gt;[]
arr &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; s.ToCharArray();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Array.Reverse(arr);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;(arr);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Converts the string to title case.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="s"&amp;gt;The string to convert.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;returns&amp;gt;A title case string.&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; ToTitleCase(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; s)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;CultureInfo ci &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Thread.CurrentThread.CurrentCulture;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;TextInfo ti &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; ci.TextInfo;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; ti.ToTitleCase(s);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Returns true if string is over the specified max length&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="s"&amp;gt;The string to check.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="maxLength"&amp;gt;max length.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; OverMaxLength(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; s, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; maxLength)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; (s.Length
&amp;lt;= maxLength);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Returns true if string is under the specified min length&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="s"&amp;gt;The string to check.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="minLength"&amp;gt;min length&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; UnderMinLength(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; s, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; minLength)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; (s.Length
&amp;lt;= minLength);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Checks the length of the string to make sure it is within the set bounds.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="s"&amp;gt;The string to check.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="minLength"&amp;gt;min length&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="maxLength"&amp;gt;max length&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; WithinValidLength(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; s, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; minLength, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; maxLength)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; ((s.Length
&amp;gt;= minLength) &amp;amp;&amp;amp; (s.Length &amp;lt;= maxLength));&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Determines whether the string is alpahbetic only.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="s"&amp;gt;The string to check.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if [is alpha only] [the specified
s]; otherwise, &amp;lt;c&amp;gt;false&amp;lt;/c&amp;gt;.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; IsAlphaOnly(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; s)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Regex regPattern &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Regex(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"[^a-zA-Z]"&lt;/span&gt;);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; !regPattern.IsMatch(s);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
Determines whether the string is alphanumeric.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;param name="s"&amp;gt;The string to check.&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;c&amp;gt;true&amp;lt;/c&amp;gt; if [is alpha numeric] [the specified
s]; otherwise, &amp;lt;c&amp;gt;false&amp;lt;/c&amp;gt;.&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;///
&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;static&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; IsAlphaNumeric(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; s)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Regex regPattern &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Regex(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"[^a-zA-Z0-9]"&lt;/span&gt;);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; !regPattern.IsMatch(s); 
&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
}&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri size=3&gt;Extension methods are a very powerful tool, and enhance
OOP concepts like encapsulation. They will help you organize your code, and extend
the functionality of classes previously you could not modify. I obtained my first
taste of &lt;a href="http://www.amazon.com/Pro-LINQ-Language-Integrated-Windows-Net/dp/1590597893/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1252017727&amp;amp;sr=8-1" target=_blank&gt;Extension
Methods in this book&lt;/a&gt; as I was learning LINQ, and I highly recommend it.&lt;/font&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=27255803-b360-4bd0-ba4f-3382811b3ada" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,27255803-b360-4bd0-ba4f-3382811b3ada.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=13f9d0b3-d92b-4787-b147-c379333b39a0</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,13f9d0b3-d92b-4787-b147-c379333b39a0.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,13f9d0b3-d92b-4787-b147-c379333b39a0.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=13f9d0b3-d92b-4787-b147-c379333b39a0</wfw:commentRss>
      <title>Starting new projects.. how to approach it?</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,13f9d0b3-d92b-4787-b147-c379333b39a0.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/03/StartingNewProjectsHowToApproachIt.aspx</link>
      <pubDate>Thu, 03 Sep 2009 19:41:58 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Next week, I’ll be starting a new project,
which is always exciting for me. In this case, it will be a WinForms application,
which I really enjoy working on.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Since
everything is more web-oriented these days, there just aren’t as many WinForms projects.
In fact, I haven’t done one in about two years where I built an application for a
major phone system manufacturer which takes Oracle data/Excel spreadsheets, imports
the data and generates a PDF price list.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;I know a lot of people dread deployment of
WinForm apps, which is one of many reasons web development has taken off. From my
perspective, it’s an even trade because web development has many challenges.. scalability,
security, browser compatibility, etc. Mostly, since WinForm apps are so rare these
days, it’s going to be a fun contract to do something different for a change.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;But that’s not the point of this post. I was
thinking about how I approach a new project (in this case, it’s a re-write of an older
application) and what I do to get it started. &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;In this case, it will look something like
this:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Get
oriented (passwords, system information, high-level project overview)&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Get
the environment set up&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l1 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Get
a high level view of what the project entails&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;From there, it’s time to dig in. In this case
it’s a re-write, so one of the many questions I ask will be to find out what was lacking
or has changed since the first application, and what the new desired features are.
Ultimately, this may entail a semi-working prototype. I’ll also want to familiarize
myself with how the old application works. This is important, as most people don’t
like a lot of change unless it really improves the process, so it’s good to understand
how they currently use it, and how they &lt;i style="mso-bidi-font-style: normal"&gt;want&lt;/i&gt; to
use it. You need end user buy-in to be successful, so it’s important that any change
you make will be accepted.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;So now we get to designing and ultimately
coding. It usually involves a few things:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo2"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Architecting
the application&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo2"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Data
Mining/design&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo2"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Designing
tests&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo2"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Deployment
Strategy&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo2"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Post-deployment
support&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo2"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Documentation&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;To architect the application, I need to see
if there are any existing architectures in place. Very rarely am I given free reign
to build the data access layer, but it does happen. A lot of contractors really push
this, or ignore current architectures, but that’s a mistake. I say this because you
need to leave an application which your client can support. If I do change the existing
practices in place, I make sure I know WHY, communicate it and document it. &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Now come the tools. Some clients won’t allow
you to bring your own software licenses. In that case, I may have to do a CodeSmith
demo to help justify the purchase of the tool. I’ll look for opportunities to generate
code and speed up development. I have had a LOT of push back on that from other contractors
though, in that they feel you are losing billable time by generating all that code,
but I disagree.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;First, as a consultant,
I feel I have a duty to save my client money and time where I can. Second, when you
do quality work and it’s fast, I assure you that you’ll be either getting more projects
or called back. In my 13 years of consulting,&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;almost
every client I have has brought me back for subsequent projects for that exact reason.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;I also bring things like my data
mining queries in my other blog posts which help find what I need to find quickly.&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;What tools/techniques do you use?&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
&lt;o:p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=13f9d0b3-d92b-4787-b147-c379333b39a0" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,13f9d0b3-d92b-4787-b147-c379333b39a0.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=b1654b01-66f4-4a29-9b70-7c4fc1524f94</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,b1654b01-66f4-4a29-9b70-7c4fc1524f94.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,b1654b01-66f4-4a29-9b70-7c4fc1524f94.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=b1654b01-66f4-4a29-9b70-7c4fc1524f94</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I can't take credit for this, as I took it from the article <a href="http://www.sqlservercentral.com/articles/T-SQL/67624/" target="_blank">How
To Get Table Row Counts Quickly And Painlessly on SqlServerCentral.com by Kendal
Van Dyke</a>. However, it such a good tip, I had to change it a bit, as I tend to
use this a LOT.
</p>
        <p>
First, I made the results a little more "printable" but reducing the table name column.
Next, I made it a system proc because when I go onto client sites, I am looking at
many databases. I probably don't need to create a procedure for it, but there have
been many cases where I trend things, and it would be nice to have this handy. Finally,
I added a parameter to allow me to change the sorting. By default, it sorts by table
name. I added an optional parameter to allow me to pass in an integer (could have
done it a million ways, I know, but I chose to do this solely for my preferences --
feel free to change to yours).
</p>
        <p>
          <strong>Usage</strong>:  <font size="2">sp_retrieveRowCounts   
--- sorts by table name</font></p>
        <p>
          <font size="2">            <font size="2">sp_retrieveRowCounts
1  ---sorts by row count, then table name</font></font>
        </p>
        <p>
          <font size="2">
            <font size="2">Here's the proc:</font>
          </font>
        </p>
        <font size="2">
          <font size="2">
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <br />
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">USE</span> master<br />
GO<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IF</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span><span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">OBJECT_ID</span>(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'sp_retrieveRowCounts'</span>,<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'P'</span>)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IS</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NOT</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NULL</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BEGIN</span><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DROP</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PROC</span> sp_retrieveRowCounts<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">END</span><br />
GO<br /><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CREATE</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PROC</span> sp_retrieveRowCounts
(@OrderByCount <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> = <span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">null</span>)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BEGIN</span><br /><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @OrderByParm <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @SQLStatement <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">varchar</span>(700)<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @OrderByClause <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">varchar</span>(35)<br />
    <br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> @OrderByParm
= <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ISNULL</span>(@OrderByCount,0)<br /><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IF</span> (@OrderByParm
!= 0)<br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> @OrderByClause
= <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
ddps.row_count DESC, o.NAME ASC'</span><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ELSE</span><br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> @OrderByClause
= <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
o.NAME ASC'</span><br /><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> @SQLStatement
= <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'SELECT
TableName = LEFT(o.name,50), TotalRows = ddps.row_count FROM sys.indexes AS i 
<br />
     INNER JOIN sys.objects AS o ON i.OBJECT_ID = o.OBJECT_ID<br />
     INNER JOIN sys.dm_db_partition_stats AS ddps ON i.OBJECT_ID
= ddps.OBJECT_ID<br />
     AND i.index_id = ddps.index_id 
<br />
    WHERE i.index_id &lt; 2 
<br />
     AND o.is_ms_shipped = 0 
<br />
    ORDER BY '</span> + @OrderByClause<br />
    <br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">EXEC</span>(@SQLStatement)<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">END</span></span>
            </p>
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">--Mark
procedure as system object</span>
                <br />
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">EXEC</span> sys.sp_MS_marksystemobject
sp_retrieveRowCounts<br />
GO<br /><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">GRANT</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">EXEC</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ON</span> sp_retrieveRowCounts <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">TO</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><br />
GO</span>
            </p>
            <p>
            </p>
          </font>
        </font> 
<img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=b1654b01-66f4-4a29-9b70-7c4fc1524f94" /></body>
      <title>Tip of the Day: Getting Table Counts</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,b1654b01-66f4-4a29-9b70-7c4fc1524f94.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/02/TipOfTheDayGettingTableCounts.aspx</link>
      <pubDate>Wed, 02 Sep 2009 17:34:10 GMT</pubDate>
      <description>&lt;p&gt;
I can't take credit for this, as I took it from&amp;nbsp;the&amp;nbsp;article &lt;a href="http://www.sqlservercentral.com/articles/T-SQL/67624/" target=_blank&gt;How
To Get Table Row Counts Quickly And Painlessly&amp;nbsp;on SqlServerCentral.com by Kendal
Van Dyke&lt;/a&gt;. However, it such a good tip, I had to change it a bit, as I tend to
use this a LOT.
&lt;/p&gt;
&lt;p&gt;
First, I made the results a little more "printable" but reducing the table name column.
Next, I made it a system proc because when I go onto client sites, I am looking at
many databases. I probably don't need to create a procedure for it, but there have
been many cases where I trend things, and it would be nice to have this handy. Finally,
I added a parameter to allow me to change the sorting. By default, it sorts by table
name. I added an optional parameter to allow me to pass in an integer (could have
done it a million ways, I know, but I chose to do this solely for my preferences --
feel free to change to yours).
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Usage&lt;/strong&gt;:&amp;nbsp; &lt;font size=2&gt;sp_retrieveRowCounts&amp;nbsp;&amp;nbsp;&amp;nbsp;
--- sorts by table name&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font size=2&gt;sp_retrieveRowCounts
1&amp;nbsp; ---sorts by row count, then table name&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font size=2&gt;&lt;font size=2&gt;Here's the proc:&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt;&lt;font size=2&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;USE&lt;/span&gt; master&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IF&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;OBJECT_ID&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'sp_retrieveRowCounts'&lt;/span&gt;,&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'P'&lt;/span&gt;)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NOT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NULL&lt;/span&gt; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BEGIN&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DROP&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PROC&lt;/span&gt; sp_retrieveRowCounts&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;END&lt;/span&gt;
&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CREATE&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PROC&lt;/span&gt; sp_retrieveRowCounts
(@OrderByCount &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; = &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/span&gt;)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BEGIN&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @OrderByParm &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @SQLStatement &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;varchar&lt;/span&gt;(700)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @OrderByClause &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;varchar&lt;/span&gt;(35)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; @OrderByParm
= &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ISNULL&lt;/span&gt;(@OrderByCount,0)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IF&lt;/span&gt; (@OrderByParm
!= 0)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; @OrderByClause
= &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
ddps.row_count DESC, o.NAME ASC'&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ELSE&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; @OrderByClause
= &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
o.NAME ASC'&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; @SQLStatement
= &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'SELECT
TableName = LEFT(o.name,50), TotalRows = ddps.row_count FROM sys.indexes AS i 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INNER JOIN sys.objects AS o ON i.OBJECT_ID = o.OBJECT_ID&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INNER JOIN sys.dm_db_partition_stats AS ddps ON i.OBJECT_ID
= ddps.OBJECT_ID&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND i.index_id = ddps.index_id 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WHERE i.index_id &amp;lt; 2 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AND o.is_ms_shipped = 0 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ORDER BY '&lt;/span&gt; + @OrderByClause&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;EXEC&lt;/span&gt;(@SQLStatement)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;END&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;--Mark
procedure as system object&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;EXEC&lt;/span&gt; sys.sp_MS_marksystemobject
sp_retrieveRowCounts&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;GRANT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;EXEC&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ON&lt;/span&gt; sp_retrieveRowCounts &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;TO&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;
&lt;br&gt;
GO&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/font&gt;&lt;/font&gt;&amp;nbsp;&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=b1654b01-66f4-4a29-9b70-7c4fc1524f94" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,b1654b01-66f4-4a29-9b70-7c4fc1524f94.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=423c8757-db97-49b5-aa71-e99b424bc5e5</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,423c8757-db97-49b5-aa71-e99b424bc5e5.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,423c8757-db97-49b5-aa71-e99b424bc5e5.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=423c8757-db97-49b5-aa71-e99b424bc5e5</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I posted about <a href="http://www.dotnettechnologies.com/PermaLink,guid,f20dd081-543c-48cb-8e21-cc44f6d2ea5a.aspx" target="_blank">sp_findsp
previously</a> and decided to revisit it. I didn't write it (see previous post
for credit/link) but I did add a bit to it. First, I cleaned it up a bit to make it
easier to read, and second, I made it so that it is a system proc so I could access
it from any db on my server. I may end up doing some cleanup on it's output, but that's
all I had time for for now. So here goes, the new version!
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">USE</span> master<br />
GO<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PRINT</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Checking
for the existence of this procedure'</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IF</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span><span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">OBJECT_ID</span>(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'sp_generate_inserts'</span>,<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'P'</span>)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IS</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NOT</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NULL</span><span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">--means,
the procedure already exists</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BEGIN</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PRINT</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Procedure
already exists. So, dropping it'</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DROP</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PROC</span> sp_findsp<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">END</span><br />
GO<br /><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CREATE</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PROC</span> sp_findsp
@s <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">varchar</span>(255) 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BEGIN</span><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DECLARE</span> @msg <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">varchar</span>(255)
,@ul <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">varchar</span>(255)<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> @s=<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'%'</span> +
@s + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'%'</span><br />
    <br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'SP
Name'</span>=<span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">upper</span>(o.name),
Seq=colid ,<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'SP
Line'</span>=<span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">substring</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">text</span>,<span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">patindex</span>(@s,<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">text</span>)-5,
30)<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span><span style="FONT-SIZE: 11px; COLOR: lawngreen; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">syscomments</span> c
, <span style="FONT-SIZE: 11px; COLOR: lawngreen; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">sysobjects</span> o<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> o.id=c.id<br />
    <span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">and</span><span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">patindex</span>(@s,<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">text</span>)
&gt; 0<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ORDER</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BY</span> [name]<br /><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> @msg=<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'*
Stored procedures containing string "'</span> + @s + <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'='</span> + <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">convert</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">varchar</span>(8),<span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">@@rowcount</span>)
+ <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
*'</span><br /><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> @ul=<span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">replicate</span>(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'*'</span>,<span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">datalength</span>(@msg))<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PRINT</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
'</span><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PRINT</span> @ul<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PRINT</span> @msg<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PRINT</span> @ul<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">END</span><br />
GO 
<br /><br /><span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">--Mark
procedure as system object</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">EXEC</span> sys.sp_MS_marksystemobject
sp_findsp<br />
GO<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PRINT</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Granting
EXECUTE permission on sp_findsp to all users'</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">GRANT</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">EXEC</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ON</span> sp_findsp <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">TO</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><br /><br />
GO<br /><br /><br /></span>
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=423c8757-db97-49b5-aa71-e99b424bc5e5" />
      </body>
      <title>Tip of the Day: sp_findsp revisted</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,423c8757-db97-49b5-aa71-e99b424bc5e5.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/01/TipOfTheDaySpfindspRevisted.aspx</link>
      <pubDate>Tue, 01 Sep 2009 04:20:43 GMT</pubDate>
      <description>&lt;p&gt;
I posted about &lt;a href="http://www.dotnettechnologies.com/PermaLink,guid,f20dd081-543c-48cb-8e21-cc44f6d2ea5a.aspx" target=_blank&gt;sp_findsp
previously&lt;/a&gt;&amp;nbsp;and decided to revisit it. I didn't write it (see previous post
for credit/link) but I did add a bit to it. First, I cleaned it up a bit to make it
easier to read, and second, I made it so that it is a system proc so I could access
it from any db on my server. I may end up doing some cleanup on it's output, but that's
all I had time for for now. So here goes, the new version!
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;USE&lt;/span&gt; master&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PRINT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Checking
for the existence of this procedure'&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IF&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;OBJECT_ID&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'sp_generate_inserts'&lt;/span&gt;,&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'P'&lt;/span&gt;)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NOT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NULL&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;--means,
the procedure already exists&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BEGIN&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PRINT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Procedure
already exists. So, dropping it'&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DROP&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PROC&lt;/span&gt; sp_findsp&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;END&lt;/span&gt;
&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CREATE&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PROC&lt;/span&gt; sp_findsp
@s &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;varchar&lt;/span&gt;(255) 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BEGIN&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DECLARE&lt;/span&gt; @msg &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;varchar&lt;/span&gt;(255)
,@ul &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;varchar&lt;/span&gt;(255)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; @s=&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'%'&lt;/span&gt; +
@s + &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'%'&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'SP
Name'&lt;/span&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;upper&lt;/span&gt;(o.name),
Seq=colid ,&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'SP
Line'&lt;/span&gt;=&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;substring&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;text&lt;/span&gt;,&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;patindex&lt;/span&gt;(@s,&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;text&lt;/span&gt;)-5,
30)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: lawngreen; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;syscomments&lt;/span&gt; c
, &lt;span style="FONT-SIZE: 11px; COLOR: lawngreen; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;sysobjects&lt;/span&gt; o&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; o.id=c.id&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;and&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;patindex&lt;/span&gt;(@s,&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;text&lt;/span&gt;)
&amp;gt; 0&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ORDER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BY&lt;/span&gt; [name]&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; @msg=&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'*
Stored procedures containing string "'&lt;/span&gt; + @s + &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'='&lt;/span&gt; + &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;convert&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;varchar&lt;/span&gt;(8),&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;@@rowcount&lt;/span&gt;)
+ &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
*'&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; @ul=&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;replicate&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'*'&lt;/span&gt;,&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;datalength&lt;/span&gt;(@msg))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PRINT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
'&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PRINT&lt;/span&gt; @ul&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PRINT&lt;/span&gt; @msg&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PRINT&lt;/span&gt; @ul&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;END&lt;/span&gt;
&lt;br&gt;
GO 
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;--Mark
procedure as system object&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;EXEC&lt;/span&gt; sys.sp_MS_marksystemobject
sp_findsp&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PRINT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Granting
EXECUTE permission on sp_findsp to all users'&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;GRANT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;EXEC&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ON&lt;/span&gt; sp_findsp &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;TO&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=423c8757-db97-49b5-aa71-e99b424bc5e5" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,423c8757-db97-49b5-aa71-e99b424bc5e5.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=f20dd081-543c-48cb-8e21-cc44f6d2ea5a</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,f20dd081-543c-48cb-8e21-cc44f6d2ea5a.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,f20dd081-543c-48cb-8e21-cc44f6d2ea5a.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f20dd081-543c-48cb-8e21-cc44f6d2ea5a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When I go onto a client site, I usually don't have the luxury of designing everything
from scratch. There are times (like on my current engagement) if I were given the
choice, I'd say scrap it, but usually it doesn't happen that way. It is what it is...
been saying that a lot lately!
</p>
        <p>
So one of the tools I find useful is the ability to search for particular field
names in the database. This is very similar to sp_findsp I use, which I have
posted in the past off the net, but I have modified it so it gets registered as a
system procedure.
</p>
        <p>
So here's sp_findfields. It will return a fairly printable representation of the results
of all fields which match the passed in string. It's registered as a system procedure
in this script, so it is accessible to all databases.
</p>
        <p>
Usage: 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">sp_findfields <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'%Contact%'</span></span>
        </p>
        <p>
This will find all fields with the string 'Item' in it. Note you need to provide
the wildcard characters.
</p>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">USE</span> master<br />
GO<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IF</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span><span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">OBJECT_ID</span>(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'sp_findfields'</span>,<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'P'</span>)) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">IS</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NOT</span><span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">NULL</span><br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BEGIN</span><br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">DROP</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PROCEDURE</span> sp_findfields<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">END</span><br />
GO<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">CREATE</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">PROCEDURE</span> sp_findfields 
<br />
(@searchText <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">varchar</span>(50))<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">AS</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BEGIN</span><br />
    <br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SELECT</span> SchemaName
= <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">LEFT</span>(TABLE_SCHEMA,10),<br />
        TableName = <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">LEFT</span>(TABLE_NAME,
35),<br />
        FieldName = <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">LEFT</span>(COLUMN_NAME,
40),<br />
        DataType = <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">LEFT</span>(DATA_TYPE,
13),<br />
        DataSize = CHARACTER_MAXIMUM_LENGTH,<br />
        AlloysNulls = IS_NULLABLE<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">FROM</span> INFORMATION_SCHEMA.columns 
<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span> column_name <span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">like</span> @searchText<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ORDER</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">BY</span> TableName,
FieldName<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">END</span><br />
GO<br /><br /><span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">--Mark
procedure as system object</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">EXEC</span> sys.sp_MS_marksystemobject
sp_findfields<br />
GO<br /><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">GRANT</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">EXEC</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ON</span> sp_findfields <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">TO</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><br />
GO</span>
            </p>
          </font>
        </font>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=f20dd081-543c-48cb-8e21-cc44f6d2ea5a" />
      </body>
      <title>Tip of the Day: A system procedure for locating fields in a database</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,f20dd081-543c-48cb-8e21-cc44f6d2ea5a.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/09/01/TipOfTheDayASystemProcedureForLocatingFieldsInADatabase.aspx</link>
      <pubDate>Tue, 01 Sep 2009 04:10:15 GMT</pubDate>
      <description>&lt;p&gt;
When I go onto a client site, I usually don't have the luxury of designing everything
from scratch. There are times (like on my current engagement) if I were given the
choice, I'd say scrap it, but usually it doesn't happen that way. It is what it is...
been saying that a lot lately!
&lt;/p&gt;
&lt;p&gt;
So one of the tools I find useful is the ability to search for particular&amp;nbsp;field
names&amp;nbsp;in the database. This is very similar to sp_findsp I use, which I have
posted in the past off the net, but I have modified it so it gets registered as a
system procedure.
&lt;/p&gt;
&lt;p&gt;
So here's sp_findfields. It will return a fairly printable representation of the results
of all fields which match the passed in string. It's registered as a system procedure
in this script, so it is accessible to all databases.
&lt;/p&gt;
&lt;p&gt;
Usage: 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;sp_findfields &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'%Contact%'&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
This will find all fields with the&amp;nbsp;string 'Item' in it. Note you need to provide
the wildcard characters.
&lt;/p&gt;
&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;USE&lt;/span&gt; master&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IF&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;OBJECT_ID&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'sp_findfields'&lt;/span&gt;,&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'P'&lt;/span&gt;)) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;IS&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NOT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;NULL&lt;/span&gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BEGIN&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;DROP&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PROCEDURE&lt;/span&gt; sp_findfields&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;END&lt;/span&gt;
&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;CREATE&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;PROCEDURE&lt;/span&gt; sp_findfields 
&lt;br&gt;
(@searchText &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;varchar&lt;/span&gt;(50))&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;AS&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BEGIN&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SELECT&lt;/span&gt; SchemaName
= &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;LEFT&lt;/span&gt;(TABLE_SCHEMA,10),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TableName = &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;LEFT&lt;/span&gt;(TABLE_NAME,
35),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;FieldName = &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;LEFT&lt;/span&gt;(COLUMN_NAME,
40),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DataType = &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;LEFT&lt;/span&gt;(DATA_TYPE,
13),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DataSize = CHARACTER_MAXIMUM_LENGTH,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;AlloysNulls = IS_NULLABLE&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;FROM&lt;/span&gt; INFORMATION_SCHEMA.columns 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt; column_name &lt;span style="FONT-SIZE: 11px; COLOR: silver; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;like&lt;/span&gt; @searchText&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ORDER&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;BY&lt;/span&gt; TableName,
FieldName&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;END&lt;/span&gt;
&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: teal; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;--Mark
procedure as system object&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;EXEC&lt;/span&gt; sys.sp_MS_marksystemobject
sp_findfields&lt;br&gt;
GO&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;GRANT&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;EXEC&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ON&lt;/span&gt; sp_findfields &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;TO&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt;
&lt;br&gt;
GO&lt;/span&gt;
&lt;/p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=f20dd081-543c-48cb-8e21-cc44f6d2ea5a" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,f20dd081-543c-48cb-8e21-cc44f6d2ea5a.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=6c4a70ac-6885-4331-b8ad-4ad09a77c62f</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,6c4a70ac-6885-4331-b8ad-4ad09a77c62f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,6c4a70ac-6885-4331-b8ad-4ad09a77c62f.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6c4a70ac-6885-4331-b8ad-4ad09a77c62f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Since I am going back into full time consulting, I decided lugging around twenty 800
page books is a bad idea. Tonight, I pulled the trigger in a <a href="http://www.amazon.com/Kindle-DX-Amazons-Wireless-Generation/dp/B0015TCML0" target="_blank">Kindle
DX</a>. A bit pricy, but the fact I can annotate my books (and export the annotations)
and read native PDFs, I can see the value in the price. I only wish it allowed you
to annotate PDFs, as I know I can put a LOT of things in PDF form and place on there. 
</p>
        <p>
So I was noticing Amazon charges for placing RSS feeds on the Kindle, and I decided
to either find a service which converts RSS feeds to PDF format, or write one myself.
Fortunately, I found <a href="http://www.tabbloid.com/" target="_blank">Tabbloid</a>,
which mails your RSS feeds in PDF format at an interval you specify. Even better,
it looks free. I may still write one and put some filtering capability in it, but
this is a win for now. 
</p>
        <p>
The other gadget I have and just enjoy is my <a href="http://reviews.cnet.com/satellite-radio-tuners/pioneer-xmp3/4505-7873_7-33364879.html" target="_blank">Pioneer
XMp3</a> player. It allows me to record XM content, and place all kinds of music on
the Micro SD card. It's still kind of buggy, and with the XM-Sirius merger, I don't
imagine that will change, but I still enjoy it immensely. 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=6c4a70ac-6885-4331-b8ad-4ad09a77c62f" />
      </body>
      <title>Gadgets and more</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,6c4a70ac-6885-4331-b8ad-4ad09a77c62f.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/31/GadgetsAndMore.aspx</link>
      <pubDate>Mon, 31 Aug 2009 04:26:21 GMT</pubDate>
      <description>&lt;p&gt;
Since I am going back into full time consulting, I decided lugging around twenty 800
page books is a bad idea. Tonight, I pulled the trigger in a &lt;a href="http://www.amazon.com/Kindle-DX-Amazons-Wireless-Generation/dp/B0015TCML0" target=_blank&gt;Kindle
DX&lt;/a&gt;. A bit pricy, but the fact I can annotate my books (and export the annotations)
and read native PDFs, I can see the value in the price. I only wish it allowed you
to annotate PDFs, as I know I can put a LOT of things in PDF form and place on there. 
&lt;/p&gt;
&lt;p&gt;
So I was noticing Amazon charges for placing RSS feeds on the Kindle, and I decided
to either find a service which converts RSS feeds to PDF format, or write one myself.
Fortunately, I found &lt;a href="http://www.tabbloid.com/" target=_blank&gt;Tabbloid&lt;/a&gt;,
which mails your RSS feeds in PDF format at an interval you specify. Even better,
it looks free. I may still write one and put some filtering capability in it, but
this is a win for now. 
&lt;/p&gt;
&lt;p&gt;
The other gadget I have and just enjoy is my &lt;a href="http://reviews.cnet.com/satellite-radio-tuners/pioneer-xmp3/4505-7873_7-33364879.html" target=_blank&gt;Pioneer
XMp3&lt;/a&gt; player. It allows me to record XM content, and place all kinds of music on
the Micro SD card. It's still kind of buggy, and with the XM-Sirius merger, I don't
imagine that will change, but I still enjoy it immensely. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=6c4a70ac-6885-4331-b8ad-4ad09a77c62f" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,6c4a70ac-6885-4331-b8ad-4ad09a77c62f.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=df218446-0028-4b48-8451-3c2d8d807084</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,df218446-0028-4b48-8451-3c2d8d807084.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,df218446-0028-4b48-8451-3c2d8d807084.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=df218446-0028-4b48-8451-3c2d8d807084</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Normally, I don't have enough time to really dig into the bleeding edge technologies,
but I am trying to rectify that. The question is always "When is it too early.."
</p>
        <p>
For now, I have been looking at some of .Net 4.0's newer features, and one really
cool thing for environments which have years of legacy software is called "Multi-targeting".
Essentially, it allows you set the target environment for an application in the same
IDE (but later target new versions).
</p>
        <p>
As an example, let's say you are currently using ASP.Net 2.0, and you have to because
of client concerns. No problem, you'll be able to set the VS IDE to target the 2.0
framework. However, when you decide to upgrade, you can just change the target framework
version. The neat thing is that the IDE willl hide and show Intellisense based on
the target framework as well.
</p>
        <p>
Scott Guthie is writing a <a href="http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx" target="_blank">series</a> on
it I plan on following closely. This time, I may just have to be more bleeding edge
than I have been in the past.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=df218446-0028-4b48-8451-3c2d8d807084" />
      </body>
      <title>.Net 4.0 Multi-Targeting</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,df218446-0028-4b48-8451-3c2d8d807084.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/30/Net40MultiTargeting.aspx</link>
      <pubDate>Sun, 30 Aug 2009 15:31:31 GMT</pubDate>
      <description>&lt;p&gt;
Normally, I don't have enough time to really dig into the bleeding edge technologies,
but I am trying to rectify that. The question is always "When is it too early.."
&lt;/p&gt;
&lt;p&gt;
For now, I have been looking at some of .Net 4.0's newer features, and one really
cool thing for environments which have years of legacy software is called "Multi-targeting".
Essentially, it allows you set the target environment for an application in the same
IDE (but later target new versions).
&lt;/p&gt;
&lt;p&gt;
As an example, let's say you are currently using ASP.Net 2.0, and you have to because
of client concerns. No problem, you'll be able to set the VS IDE to target the 2.0
framework. However, when you decide to upgrade, you can just change the target framework
version. The neat thing is that the IDE willl hide and show Intellisense based on
the target framework as well.
&lt;/p&gt;
&lt;p&gt;
Scott Guthie is writing a &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx" target=_blank&gt;series&lt;/a&gt; on
it I plan on following closely. This time, I may just have to be more bleeding edge
than I have been in the past.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=df218446-0028-4b48-8451-3c2d8d807084" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,df218446-0028-4b48-8451-3c2d8d807084.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=90c19b04-8938-4e9e-a097-fc79ff9aa222</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,90c19b04-8938-4e9e-a097-fc79ff9aa222.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,90c19b04-8938-4e9e-a097-fc79ff9aa222.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=90c19b04-8938-4e9e-a097-fc79ff9aa222</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The following code snippets make retrieving values from DataRows safely, and properly
casts them to the desired values. 
</p>
        <p>
 
</p>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the int value from data row.</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="fieldName"&gt;</span><span style="COLOR: green">Name of the field.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="dr"&gt;</span><span style="COLOR: green">The dr.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">static</span><span style="COLOR: blue">int</span> GetIntValueFromDataRow(<span style="COLOR: blue">string</span> fieldName, <span style="COLOR: #2b91af">DataRow</span> dr)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span> (dr[fieldName]
== <span style="COLOR: #2b91af">DBNull</span>.Value ? 0 : <span style="COLOR: #2b91af">Convert</span>.ToInt32(dr[fieldName].ToString()));
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the int value from data row.</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="fieldName"&gt;</span><span style="COLOR: green">Name of the field.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="dr"&gt;</span><span style="COLOR: green">The dr.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="defaultValue"&gt;</span><span style="COLOR: green">The default value.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">static</span><span style="COLOR: blue">int</span> GetIntValueFromDataRow(<span style="COLOR: blue">string</span> fieldName, <span style="COLOR: #2b91af">DataRow</span> dr, <span style="COLOR: blue">int</span> defaultValue)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span> (dr[fieldName]
== <span style="COLOR: #2b91af">DBNull</span>.Value ? defaultValue : <span style="COLOR: #2b91af">Convert</span>.ToInt32(dr[fieldName].ToString()));
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the string value from data row.</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="fieldName"&gt;</span><span style="COLOR: green">Name of the field.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="dr"&gt;</span><span style="COLOR: green">The dr.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">static</span><span style="COLOR: blue">string</span> GetStringValueFromDataRow(<span style="COLOR: blue">string</span> fieldName, <span style="COLOR: #2b91af">DataRow</span> dr)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span> (dr[fieldName]
== <span style="COLOR: #2b91af">DBNull</span>.Value ? <span style="COLOR: #2b91af">String</span>.Empty
: dr[fieldName].ToString());
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the string value from data row.</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="fieldName"&gt;</span><span style="COLOR: green">Name of the field.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="dr"&gt;</span><span style="COLOR: green">The dr.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="defaultValue"&gt;</span><span style="COLOR: green">The default value.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">static</span><span style="COLOR: blue">string</span> GetStringValueFromDataRow(<span style="COLOR: blue">string</span> fieldName, <span style="COLOR: #2b91af">DataRow</span> dr, <span style="COLOR: blue">string</span> defaultValue)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span> (dr[fieldName]
== <span style="COLOR: #2b91af">DBNull</span>.Value ? defaultValue : dr[fieldName].ToString());
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the bool value from data row.</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="fieldName"&gt;</span><span style="COLOR: green">Name of the field.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="dr"&gt;</span><span style="COLOR: green">The dr.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">static</span><span style="COLOR: blue">bool</span> GetBoolValueFromDataRow(<span style="COLOR: blue">string</span> fieldName, <span style="COLOR: #2b91af">DataRow</span> dr)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span> (dr[fieldName]
== <span style="COLOR: #2b91af">DBNull</span>.Value ? <span style="COLOR: blue">false</span> : <span style="COLOR: #2b91af">Convert</span>.ToBoolean(dr[fieldName].ToString()));
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the decimal value from data row.</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="fieldName"&gt;</span><span style="COLOR: green">Name of the field.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="dr"&gt;</span><span style="COLOR: green">The dr.</span><span style="COLOR: gray">&lt;/param&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">static</span><span style="COLOR: blue">decimal</span> GetDecimalValueFromDataRow(<span style="COLOR: blue">string</span> fieldName, <span style="COLOR: #2b91af">DataRow</span> dr)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span> (dr[fieldName]
== <span style="COLOR: #2b91af">DBNull</span>.Value ? 0 : <span style="COLOR: #2b91af">Convert</span>.ToDecimal(dr[fieldName].ToString()));
</p>
          <p style="MARGIN: 0px">
        }
</p>
        </div>
        <!--EndFragment-->
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=90c19b04-8938-4e9e-a097-fc79ff9aa222" />
      </body>
      <title>Tip of the Day: Get values from DataRows safely</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,90c19b04-8938-4e9e-a097-fc79ff9aa222.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/29/TipOfTheDayGetValuesFromDataRowsSafely.aspx</link>
      <pubDate>Sat, 29 Aug 2009 18:32:59 GMT</pubDate>
      <description>&lt;p&gt;
The following code snippets make retrieving values from DataRows safely, and properly
casts them to the desired values. 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the int value from data row.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="fieldName"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Name of the field.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="dr"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The dr.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; GetIntValueFromDataRow(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fieldName, &lt;span style="COLOR: #2b91af"&gt;DataRow&lt;/span&gt; dr)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; (dr[fieldName]
== &lt;span style="COLOR: #2b91af"&gt;DBNull&lt;/span&gt;.Value ? 0 : &lt;span style="COLOR: #2b91af"&gt;Convert&lt;/span&gt;.ToInt32(dr[fieldName].ToString()));
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the int value from data row.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="fieldName"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Name of the field.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="dr"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The dr.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="defaultValue"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The default value.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; GetIntValueFromDataRow(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fieldName, &lt;span style="COLOR: #2b91af"&gt;DataRow&lt;/span&gt; dr, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; defaultValue)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; (dr[fieldName]
== &lt;span style="COLOR: #2b91af"&gt;DBNull&lt;/span&gt;.Value ? defaultValue : &lt;span style="COLOR: #2b91af"&gt;Convert&lt;/span&gt;.ToInt32(dr[fieldName].ToString()));
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the string value from data row.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="fieldName"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Name of the field.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="dr"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The dr.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; GetStringValueFromDataRow(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fieldName, &lt;span style="COLOR: #2b91af"&gt;DataRow&lt;/span&gt; dr)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; (dr[fieldName]
== &lt;span style="COLOR: #2b91af"&gt;DBNull&lt;/span&gt;.Value ? &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.Empty
: dr[fieldName].ToString());
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the string value from data row.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="fieldName"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Name of the field.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="dr"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The dr.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="defaultValue"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The default value.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; GetStringValueFromDataRow(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fieldName, &lt;span style="COLOR: #2b91af"&gt;DataRow&lt;/span&gt; dr, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; defaultValue)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; (dr[fieldName]
== &lt;span style="COLOR: #2b91af"&gt;DBNull&lt;/span&gt;.Value ? defaultValue : dr[fieldName].ToString());
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the bool value from data row.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="fieldName"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Name of the field.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="dr"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The dr.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; GetBoolValueFromDataRow(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fieldName, &lt;span style="COLOR: #2b91af"&gt;DataRow&lt;/span&gt; dr)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; (dr[fieldName]
== &lt;span style="COLOR: #2b91af"&gt;DBNull&lt;/span&gt;.Value ? &lt;span style="COLOR: blue"&gt;false&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;Convert&lt;/span&gt;.ToBoolean(dr[fieldName].ToString()));
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the decimal value from data row.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="fieldName"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Name of the field.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="dr"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The dr.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; GetDecimalValueFromDataRow(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fieldName, &lt;span style="COLOR: #2b91af"&gt;DataRow&lt;/span&gt; dr)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; (dr[fieldName]
== &lt;span style="COLOR: #2b91af"&gt;DBNull&lt;/span&gt;.Value ? 0 : &lt;span style="COLOR: #2b91af"&gt;Convert&lt;/span&gt;.ToDecimal(dr[fieldName].ToString()));
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=90c19b04-8938-4e9e-a097-fc79ff9aa222" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,90c19b04-8938-4e9e-a097-fc79ff9aa222.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=dbeb28b9-75cc-4b79-9b41-102b83a7c279</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,dbeb28b9-75cc-4b79-9b41-102b83a7c279.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,dbeb28b9-75cc-4b79-9b41-102b83a7c279.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=dbeb28b9-75cc-4b79-9b41-102b83a7c279</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">I am a huge fan of <a href="http://www.codesmithtools.com/" target="_blank">CodeSmith</a>.
If you are not familiar with it, and you do any amount of coding at all, you owe it
to yourself to check it out. </font>
        </p>
        <p>
          <font color="#000000">Below is some template code which loads the foreign keys of
a table into a Dictionary object. It stores the name of the table and foreign key
field name. As you can see, it generates a notice when it comes across a recursive
relationship. </font>
        </p>
        <p>
 
</p>
        <p>
public Dictionary&lt;string,string&gt; GetForeignKeyTables()<br />
{<br />
    Dictionary&lt;string,string&gt; dic = new Dictionary&lt;string,string&gt;(
);
</p>
        <p>
 for (int idx = 0; idx &lt; SourceTable.ForeignKeys.Count; idx ++)<br />
 {<br />
        string primaryTable = String.Empty;<br />
        string primaryKey = String.Empty;
</p>
        <p>
  // To get the foreign key columns<br />
  ColumnSchema col1 = SourceTable.ForeignKeys[idx].ForeignKeyMemberColumns[0];<br />
        primaryKey = col1.Name.Trim();
</p>
        <p>
  // To get the foreign key tables<br />
        primaryTable = SourceTable.ForeignKeys[idx].PrimaryKeyTable.ToString().Replace("dbo.",String.Empty).Trim();<br />
        if (!dic.ContainsKey(primaryKey))<br />
            dic.Add(primaryKey,
primaryTable);<br />
        else<br />
            MessageBox.Show("This
table may contain recursive relationships. You must set those relationships up manually.");<br />
    }
</p>
        <p>
    return dic;<br />
}
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=dbeb28b9-75cc-4b79-9b41-102b83a7c279" />
      </body>
      <title>Tip of the Day: CodeSmith Template -- Load all foreign keys into a Dictionary object</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,dbeb28b9-75cc-4b79-9b41-102b83a7c279.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/28/TipOfTheDayCodeSmithTemplateLoadAllForeignKeysIntoADictionaryObject.aspx</link>
      <pubDate>Fri, 28 Aug 2009 21:48:39 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;I am a huge fan of &lt;a href="http://www.codesmithtools.com/" target=_blank&gt;CodeSmith&lt;/a&gt;.
If you are not familiar with it, and you do any amount of coding at all, you owe it
to yourself to check it out. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Below is some template code which loads the foreign keys of a
table into a Dictionary object. It stores the name of the table and foreign key field
name. As you can see, it generates a notice when it comes across a recursive relationship. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
public Dictionary&amp;lt;string,string&amp;gt; GetForeignKeyTables()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dictionary&amp;lt;string,string&amp;gt; dic = new Dictionary&amp;lt;string,string&amp;gt;(
);
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;for (int idx = 0; idx &amp;lt; SourceTable.ForeignKeys.Count; idx ++)&lt;br&gt;
&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string primaryTable = String.Empty;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string primaryKey = String.Empty;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;// To get the foreign key columns&lt;br&gt;
&amp;nbsp;&amp;nbsp;ColumnSchema col1 = SourceTable.ForeignKeys[idx].ForeignKeyMemberColumns[0];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; primaryKey = col1.Name.Trim();
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;// To get the foreign key tables&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; primaryTable = SourceTable.ForeignKeys[idx].PrimaryKeyTable.ToString().Replace("dbo.",String.Empty).Trim();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!dic.ContainsKey(primaryKey))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dic.Add(primaryKey,
primaryTable);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MessageBox.Show("This
table may contain recursive relationships. You must set those relationships up manually.");&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return dic;&lt;br&gt;
}
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=dbeb28b9-75cc-4b79-9b41-102b83a7c279" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,dbeb28b9-75cc-4b79-9b41-102b83a7c279.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=1382d7be-526c-4af0-a8b7-03d539b1a17d</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,1382d7be-526c-4af0-a8b7-03d539b1a17d.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,1382d7be-526c-4af0-a8b7-03d539b1a17d.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1382d7be-526c-4af0-a8b7-03d539b1a17d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I mainly ask this of QA people when I interview them, but I have started adding it
to my general interview questions.
</p>
        <p>
Let's face it, if you have been coding long enough, and release your application to
the world, there's a 100% chance at some point something will go wrong. It's part
of life and it's nothing to be ashamed of.. most of the time.
</p>
        <p>
The key to answering this question is address it honestly, but with all  "negative"
questions, show what you have learned from it. For example, say you had an application
launch, and when you turned it on, it didn't perform well because it was wildly successful.
You could describe this, but make sure you say something like "now, before I launch,
we create performance tests and build in performance indicators so we can detect these
issues pre-launch, and monitor the application proactively." In a word --&gt; what
I learned from it.
</p>
        <p>
One of my classic "flubs" was for an auction I wrote the software for. It was live
on TV, and the client had me make a database change the night before going live, and
we didn't get a chance to adequately test the change (which is to say, nothing more
than my rudimentary testing, and my client just didn't have the time). As the auction
commenced, the save method was failing on certain items, and I quickly saw the problem
and fixed it LIVE on national TV. My lesson --&gt; NEVER let a client tell me they
don't have time to test, and no one even knew it was failing.
</p>
        <p>
As an aside to this, the reason no one knew there was a problem is I had very good
error handling/trapping and logging. The application adequately handled the issue,
and I was able to monitor the application logs remotely, and immediately saw the problem
and knew what the fix was. 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1382d7be-526c-4af0-a8b7-03d539b1a17d" />
      </body>
      <title>Interview Question: Have you ever had an application launch fail? </title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,1382d7be-526c-4af0-a8b7-03d539b1a17d.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/26/InterviewQuestionHaveYouEverHadAnApplicationLaunchFail.aspx</link>
      <pubDate>Wed, 26 Aug 2009 23:01:11 GMT</pubDate>
      <description>&lt;p&gt;
I mainly ask this of QA people when I interview them, but I have started adding it
to my general interview questions.
&lt;/p&gt;
&lt;p&gt;
Let's face it, if you have been coding long enough, and release your application to
the world, there's a 100% chance at some point something will go wrong. It's part
of life and it's nothing to be ashamed of.. most of the time.
&lt;/p&gt;
&lt;p&gt;
The key to answering this question is address it honestly, but with all&amp;nbsp; "negative"
questions, show what you have learned from it. For example, say you had an application
launch, and when you turned it on, it didn't perform well because it was wildly successful.
You could describe this, but make sure you say something like "now, before I launch,
we create performance tests and build in performance indicators so we can detect these
issues pre-launch, and monitor the application proactively." In a word --&amp;gt; what
I learned from it.
&lt;/p&gt;
&lt;p&gt;
One of my classic "flubs" was for an auction I wrote the software for. It was live
on TV, and the client had me make a database change the night before going live, and
we didn't get a chance to adequately test the change (which is to say, nothing more
than my rudimentary testing, and my client just didn't have the time). As the auction
commenced, the save method was failing on certain items, and I quickly saw the problem
and fixed it LIVE on national TV. My lesson --&amp;gt; NEVER let a client tell me they
don't have time to test, and no one even knew it was failing.
&lt;/p&gt;
&lt;p&gt;
As an aside to this, the reason no one knew there was a problem is I had very good
error handling/trapping and logging. The application adequately handled the issue,
and I was able to monitor the application logs remotely, and immediately saw the problem
and knew what the fix was. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1382d7be-526c-4af0-a8b7-03d539b1a17d" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,1382d7be-526c-4af0-a8b7-03d539b1a17d.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=28e48f37-06e8-4ef1-9abc-b2a44a34dcdf</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,28e48f37-06e8-4ef1-9abc-b2a44a34dcdf.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,28e48f37-06e8-4ef1-9abc-b2a44a34dcdf.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=28e48f37-06e8-4ef1-9abc-b2a44a34dcdf</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Earlier today, I blogged an interview question about reflection. Earlier this year,
as part of the interviewing process I was tasked to write a simple calculator. There
would only be 2 integer inputs with a single operation. For example, if the invoked
the program, and entered in 1 U 2 (U being the operation for addition), the program
would output 3. 
</p>
        <p>
The assignment also mentioned they would want the possibility to expand the operations
later. Instead of just commenting on it, I decided to implement that into the design.
</p>
        <p>
I won't go into retrieving the data from command prompt, but I will provide the project
at the end and you can see how that is accomplished. I made it robust by accounting
for spaces, etc. As a programming concept, you should always program defensively and
assume the work (and you'll be glad with the results).
</p>
        <p>
First, I created a base class each operand would inherit from, so that each works
similarly. The base class <em>OperationBase</em> looks like this:
</p>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">using</span> System.Diagnostics;
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">namespace</span> CalcLibrary
</p>
          <p style="MARGIN: 0px">
{
</p>
          <p style="MARGIN: 0px">
    [<span style="COLOR: #2b91af">OperatorIndex</span>(<span style="COLOR: #a31515">""</span>)]
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">abstract</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">OperationBase</span></p>
          <p style="MARGIN: 0px">
    {
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">private</span><span style="COLOR: blue">int</span> value1;
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">private</span><span style="COLOR: blue">int</span> value2;
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">private</span><span style="COLOR: blue">string</span> errorInformation
= <span style="COLOR: #2b91af">String</span>.Empty;
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">int</span> Value1
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">get</span> { <span style="COLOR: blue">return</span> value1;
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">set</span> {
value1 = <span style="COLOR: blue">value</span>; }
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">int</span> Value2
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">get</span> { <span style="COLOR: blue">return</span> value2;
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">set</span> {
value2 = <span style="COLOR: blue">value</span>; }
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">string</span> ErrorInformation
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">get</span> { <span style="COLOR: blue">return</span> errorInformation;
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">private</span><span style="COLOR: blue">set</span> {
errorInformation = <span style="COLOR: blue">value</span>; }
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: green">//NOTE: We may want
to return a string as the division will round every time, but we will keep this as
an int</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">abstract</span><span style="COLOR: blue">int</span> Calculate();
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: blue">protected</span><span style="COLOR: blue">void</span> ErrorHandler(<span style="COLOR: #2b91af">Exception</span> ex)
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">try</span></p>
          <p style="MARGIN: 0px">
            {
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: green">//While
in a production app we would want to hide the internals of an error, in this app we
will show them</span></p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">this</span>.ErrorInformation
= <span style="COLOR: #a31515">"An unexpected error occurred ("</span> + <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">StackTrace</span>().GetFrame(2).GetMethod().Name
+ <span style="COLOR: #a31515">")-"</span> + ex.Message;
</p>
          <p style="MARGIN: 0px">
            }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">catch</span> 
{}
</p>
          <p style="MARGIN: 0px">
        }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
    }
</p>
          <p style="MARGIN: 0px">
}
</p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">You'll notice this abstract class defines taking two
int inputs (Value1 and Value2), handles the errors, and forces every implementation
to provide a definition of the "Calculate" method. When inheriting from this class, any
operand will be very simple to define -- all it needs to do is determine what to do
for a Calculation, as seen by the addition operand implementation.</font>
          </p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">
            </font> 
</p>
          <font face="Verdana" size="2">
            <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
              <p style="MARGIN: 0px">
                <span style="COLOR: blue">namespace</span> CalcLibrary
</p>
              <p style="MARGIN: 0px">
{
</p>
              <p style="MARGIN: 0px">
    [<span style="COLOR: #2b91af">OperatorIndex</span>(<span style="COLOR: #a31515">"U"</span>)]
</p>
              <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">AdditionOperand</span> : <span style="COLOR: #2b91af">OperationBase</span></p>
              <p style="MARGIN: 0px">
    {
</p>
              <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">int</span> Calculate()
</p>
              <p style="MARGIN: 0px">
        {
</p>
              <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span><span style="COLOR: blue">this</span>.Value1
+ <span style="COLOR: blue">this</span>.Value2;
</p>
              <p style="MARGIN: 0px">
        }
</p>
              <p style="MARGIN: 0px">
    }
</p>
              <p style="MARGIN: 0px">
}
</p>
            </div>
            <!--EndFragment-->
          </font>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">The next task was to determine which operand to use
given the user's input. We could write an "if" statement or a factory method, but
I wanted to make sure if anyone came in to add a new operand, they would not have
to change any code -- just add a new class, inherit from <em>OperationBase</em> and
implement the Calculate() method. To accomplish this task, I decided to use reflection.
By decorating each Operand class with an attribute, I could designate how it reacts
to the inputs. </font>
          </p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">
            </font> 
</p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">First, I needed to define my attribute:</font>
          </p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">
            </font> 
</p>
          <font face="Verdana" size="2">
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
              <span style="COLOR: blue">using</span> System;
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
 
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
              <span style="COLOR: blue">namespace</span> CalcLibrary
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
{
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
    [System.<span style="COLOR: #2b91af">AttributeUsage</span>(System.<span style="COLOR: #2b91af">AttributeTargets</span>.Class)]
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">OperatorIndex</span> :
System.<span style="COLOR: #2b91af">Attribute</span></p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
    {
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">string</span> OperatorId
= <span style="COLOR: #2b91af">String</span>.Empty;
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
        <span style="COLOR: blue">public</span> OperatorIndex(<span style="COLOR: blue">string</span> operatorId)
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
        {
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
            OperatorId = operatorId;
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
        }
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
    }
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
}
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
 
</p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
              <font face="Verdana" size="2">Next, I need to decorate my operands with the appropriate
attribute. Again, I will use the AdditionOperand, which is indicated by the "U" notation.
When I define my class, I decorate it with the attribute letter I want to use to define
that function.</font>
            </p>
            <p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New">
              <font size="2">
              </font>
              <font color="#2b91af" size="2">
                <font color="#2b91af" size="2"> 
</font>
              </font>
            </p>
          </font>
          <font face="Verdana" size="2">
            <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
              <p style="MARGIN: 0px">
    [<span style="COLOR: #2b91af">OperatorIndex</span>(<span style="COLOR: #a31515">"U"</span>)]
</p>
              <p style="MARGIN: 0px">
    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">AdditionOperand</span> : <span style="COLOR: #2b91af">OperationBase</span></p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">
                </span> 
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">
                  <font face="Verdana" color="#000000" size="2">Now that
I have defined my operations, I need to use them. I created a publically exposed static
class called <em>CalcEngine</em> which loads all the operations, validates the inputs,
and processes the calculations. I created this as a class library so it could be used
with a console application (as it is being called from in the supplied example), a
web application, etc.</font>
                </span>
              </p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">
                  <font face="Verdana" color="#000000" size="2">
                  </font>
                </span> 
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">
                  <font face="Verdana" color="#000000" size="2">In the
constructor, I call a method <em>LoadOperators()</em> which uses LINQ to Reflection
to quickly retrieve all classes of type <em>OperatorBase</em> and have the <em>OperatorIndex</em> defined.
I load the resules into a dictionary object so I can quickly retrieve them for my
calculations. Below is how I load the operators using LINQ to Reflection.</font>
                </span>
              </p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">
                  <font face="Verdana" color="#000000" size="2">
                  </font>
                </span> 
</p>
              <span style="COLOR: #2b91af">
                <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
                  <p style="MARGIN: 0px">
                    <span style="COLOR: blue">private</span>
                    <span style="COLOR: blue">static</span>
                    <span style="COLOR: blue">void</span> LoadOperators()
</p>
                  <p style="MARGIN: 0px">
        {
</p>
                  <p style="MARGIN: 0px">
            <span style="COLOR: green">//Using
LINQ to Reflection, load all classes from the assembly that inherit from our base
Operator type, </span></p>
                  <p style="MARGIN: 0px">
            <span style="COLOR: green">//and
have the attribute set into a dictionary, so we can quickly reference the operator
we want</span></p>
                  <p style="MARGIN: 0px">
            operations =
</p>
                  <p style="MARGIN: 0px">
                (<span style="COLOR: blue">from</span> a <span style="COLOR: blue">in</span><span style="COLOR: #2b91af">AppDomain</span>.CurrentDomain.GetAssemblies()
</p>
                  <p style="MARGIN: 0px">
                <span style="COLOR: blue">from</span> t <span style="COLOR: blue">in</span> a.GetTypes()
</p>
                  <p style="MARGIN: 0px">
                <span style="COLOR: blue">where</span><span style="COLOR: #2b91af">Attribute</span>.IsDefined(t,<span style="COLOR: blue">typeof</span>(<span style="COLOR: #2b91af">OperatorIndex</span>))
</p>
                  <p style="MARGIN: 0px">
                <span style="COLOR: blue">where</span> t.BaseType
== <span style="COLOR: blue">typeof</span>(<span style="COLOR: #2b91af">OperationBase</span>)
</p>
                  <p style="MARGIN: 0px">
                <span style="COLOR: blue">let</span> attribute
= <span style="COLOR: #2b91af">Attribute</span>.GetCustomAttribute(t,<span style="COLOR: blue">typeof</span>(<span style="COLOR: #2b91af">OperatorIndex</span>)) <span style="COLOR: blue">as</span><span style="COLOR: #2b91af">OperatorIndex</span></p>
                  <p style="MARGIN: 0px">
                <span style="COLOR: blue">where</span> attribute.OperatorId
!= <span style="COLOR: #a31515">""</span></p>
                  <p style="MARGIN: 0px">
                <span style="COLOR: blue">select</span></p>
                  <p style="MARGIN: 0px">
                    <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">OperatorDetails</span></p>
                  <p style="MARGIN: 0px">
                   
{
</p>
                  <p style="MARGIN: 0px">
                   
    AssemName = a.GetName().Name,
</p>
                  <p style="MARGIN: 0px">
                   
    ClassName = t.FullName,
</p>
                  <p style="MARGIN: 0px">
                   
    OperatorId = attribute.OperatorId
</p>
                  <p style="MARGIN: 0px">
                   
}).ToDictionary(p =&gt; p.OperatorId,p =&gt; p);
</p>
                  <p style="MARGIN: 0px">
 
</p>
                  <p style="MARGIN: 0px">
        }
</p>
                </div>
                <!--EndFragment-->
              </span>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">
                  <font face="Verdana" color="#000000" size="2">The main <em>Calculate </em>method
validates the input, retrieves the right operand key from the dictionary, late binds
to the proper <em>OperatorBase</em> class and invokes the <em>Calculate() </em>method,
as seen below.</font>
                </span>
              </p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">
                  <font face="Verdana" color="#000000" size="2">
                  </font>
                </span> 
</p>
              <span style="COLOR: #2b91af">
                <font face="Verdana" color="#000000" size="2">
                  <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
                    <p style="MARGIN: 0px">
                <span style="COLOR: green">//locate
the correct operator from our dictionary</span></p>
                    <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">OperatorDetails</span> operatorInfo
= operations[mathOperator];
</p>
                    <p style="MARGIN: 0px">
 
</p>
                    <p style="MARGIN: 0px">
                <span style="COLOR: green">//dynamically
load the operator class. I chose to do it using reflection so that we wouldn't need
a</span></p>
                    <p style="MARGIN: 0px">
                <span style="COLOR: green">//factory,
which would need to be changed every time a new operator was added.</span></p>
                    <p style="MARGIN: 0px">
                <span style="COLOR: green">//ENHANCEMENT:
you could actually detect other assemblies and load them as well</span></p>
                    <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">Type</span> calcClass
= <span style="COLOR: #2b91af">Type</span>.GetType(operatorInfo.ClassName);
</p>
                    <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">OperationBase</span> calculator
= (<span style="COLOR: #2b91af">OperationBase</span>) <span style="COLOR: #2b91af">Activator</span>.CreateInstance(calcClass);
</p>
                    <p style="MARGIN: 0px">
                calculator.Value1
= value1;
</p>
                    <p style="MARGIN: 0px">
                calculator.Value2
= value2;
</p>
                    <p style="MARGIN: 0px">
                <span style="COLOR: blue">int</span> calculatedResult
= calculator.Calculate();
</p>
                  </div>
                  <!--EndFragment-->
                </font>
              </span>
            </div>
          </font>
        </div>
        <font face="Verdana" size="2">
          <font face="Verdana" size="2">
          </font>
        </font>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <font face="Verdana" size="2">
            <font face="Verdana" size="2">
            </font>
          </font> 
</div>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <font face="Verdana" size="2">
            <font face="Verdana" size="2">Using
a console application, it looks like this:</font>
          </font>
        </div>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <font face="Verdana" size="2">
            <font face="Verdana" size="2">
            </font>
          </font> 
</div>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <font face="Verdana" size="2">
            <font face="Verdana" size="2">
              <!--EndFragment-->
            </font>
            <!--EndFragment-->
          </font>
        </div>
        <p>
          <img src="http://www.dotnettechnologies.com/content/binary/calc_example.png" border="0" />
        </p>
        <p>
Here's the sample code to look at and play with.. Enjoy!
</p>
        <p>
 
</p>
        <a href="http://www.dotnettechnologies.com/content/binary/SampleProj.zip">SampleProj.zip
(89.4 KB)</a>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=28e48f37-06e8-4ef1-9abc-b2a44a34dcdf" />
      </body>
      <title>How I have used reflection</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,28e48f37-06e8-4ef1-9abc-b2a44a34dcdf.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/25/HowIHaveUsedReflection.aspx</link>
      <pubDate>Tue, 25 Aug 2009 05:12:16 GMT</pubDate>
      <description>&lt;p&gt;
Earlier today, I blogged an interview question about reflection. Earlier this year,
as part of the interviewing process I was tasked to write a simple calculator. There
would only be 2 integer inputs with a single operation. For example, if the invoked
the program, and entered in 1 U 2 (U being the operation for addition), the program
would output 3. 
&lt;/p&gt;
&lt;p&gt;
The assignment also mentioned they would want the possibility to expand the operations
later. Instead of just commenting on it, I decided to implement that into the design.
&lt;/p&gt;
&lt;p&gt;
I won't go into retrieving the data from command prompt, but I will provide the project
at the end and you can see how that is accomplished. I made it robust by accounting
for spaces, etc. As a programming concept, you should always program defensively and
assume the work (and you'll be glad with the results).
&lt;/p&gt;
&lt;p&gt;
First, I created a base class each operand would inherit from, so that each works
similarly. The base class &lt;em&gt;OperationBase&lt;/em&gt; looks like this:
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Diagnostics;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; CalcLibrary
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: #2b91af"&gt;OperatorIndex&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;abstract&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;OperationBase&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; value1;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; value2;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; errorInformation
= &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.Empty;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; Value1
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;get&lt;/span&gt; { &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; value1;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt; {
value1 = &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; Value2
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;get&lt;/span&gt; { &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; value2;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt; {
value2 = &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; ErrorInformation
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;get&lt;/span&gt; { &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; errorInformation;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;set&lt;/span&gt; {
errorInformation = &lt;span style="COLOR: blue"&gt;value&lt;/span&gt;; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//NOTE: We may want
to return a string as the division will round every time, but we will keep this as
an int&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;abstract&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; Calculate();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; ErrorHandler(&lt;span style="COLOR: #2b91af"&gt;Exception&lt;/span&gt; ex)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//While
in a production app we would want to hide the internals of an error, in this app we
will show them&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.ErrorInformation
= &lt;span style="COLOR: #a31515"&gt;"An unexpected error occurred ("&lt;/span&gt; + &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;StackTrace&lt;/span&gt;().GetFrame(2).GetMethod().Name
+ &lt;span style="COLOR: #a31515"&gt;")-"&lt;/span&gt; + ex.Message;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;catch&lt;/span&gt;&amp;nbsp;
{}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;You'll notice this abstract class defines taking two int
inputs (Value1 and Value2), handles the errors, and forces every implementation to
provide a definition of the "Calculate" method. When inheriting from this class,&amp;nbsp;any
operand will be very simple to define -- all it needs to do is determine what to do
for a Calculation, as seen by the addition operand implementation.&lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;font face=Verdana size=2&gt; 
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; CalcLibrary
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: #2b91af"&gt;OperatorIndex&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"U"&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;AdditionOperand&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;OperationBase&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; Calculate()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Value1
+ &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Value2;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
}
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/font&gt; 
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;The next task was to determine which operand to use given
the user's input. We could write an "if" statement or a factory method, but I wanted
to make sure if anyone came in to add a new operand, they would not have to change
any code -- just add a new class, inherit from &lt;em&gt;OperationBase&lt;/em&gt; and implement
the Calculate() method.&amp;nbsp;To accomplish this task, I decided to use reflection.
By decorating each Operand class with an attribute, I could designate how it reacts
to the inputs. &lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;First, I needed to define my attribute:&lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;font face=Verdana size=2&gt; 
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System;
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; CalcLibrary
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
{
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [System.&lt;span style="COLOR: #2b91af"&gt;AttributeUsage&lt;/span&gt;(System.&lt;span style="COLOR: #2b91af"&gt;AttributeTargets&lt;/span&gt;.Class)]
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;OperatorIndex&lt;/span&gt; :
System.&lt;span style="COLOR: #2b91af"&gt;Attribute&lt;/span&gt;
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; OperatorId
= &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.Empty;
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; OperatorIndex(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; operatorId)
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; OperatorId = operatorId;
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
}
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;font face=Verdana size=2&gt;Next, I need to decorate my operands with the appropriate
attribute. Again, I will use the AdditionOperand, which is indicated by the "U" notation.
When I define my class, I decorate it with the attribute letter I want to use to define
that function.&lt;/font&gt;
&lt;/p&gt;
&lt;p style="FONT-SIZE: 8pt; BACKGROUND: white; MARGIN: 0px; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;font size=2&gt;&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;&amp;nbsp;
&lt;/p&gt;
&lt;/font&gt;&gt;&lt;font face=Verdana size=2&gt; 
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: #2b91af"&gt;OperatorIndex&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"U"&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;AdditionOperand&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;OperationBase&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&lt;font face=Verdana color=#000000 size=2&gt;Now that I have
defined my operations, I need to use them. I created a publically exposed static class
called &lt;em&gt;CalcEngine&lt;/em&gt; which loads all the operations, validates the inputs, and
processes the calculations. I created this as a class library so it could be used
with a console application (as it is being called from in the supplied example), a
web application, etc.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&lt;font face=Verdana color=#000000 size=2&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&lt;font face=Verdana color=#000000 size=2&gt;In the constructor,
I call a method &lt;em&gt;LoadOperators()&lt;/em&gt; which uses LINQ to Reflection to quickly
retrieve all classes of type &lt;em&gt;OperatorBase&lt;/em&gt; and have the &lt;em&gt;OperatorIndex&lt;/em&gt; defined.
I load the resules into a dictionary object so I can quickly retrieve them for my
calculations. Below is how I load the operators using LINQ to Reflection.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&lt;font face=Verdana color=#000000 size=2&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;span style="COLOR: #2b91af"&gt; 
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; LoadOperators()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//Using
LINQ to Reflection, load all classes from the assembly that inherit from our base
Operator type, &lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//and
have the attribute set into a dictionary, so we can quickly reference the operator
we want&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; operations =
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;span style="COLOR: blue"&gt;from&lt;/span&gt; a &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;AppDomain&lt;/span&gt;.CurrentDomain.GetAssemblies()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; t &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; a.GetTypes()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;where&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Attribute&lt;/span&gt;.IsDefined(t,&lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;OperatorIndex&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;where&lt;/span&gt; t.BaseType
== &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;OperationBase&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;let&lt;/span&gt; attribute
= &lt;span style="COLOR: #2b91af"&gt;Attribute&lt;/span&gt;.GetCustomAttribute(t,&lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;OperatorIndex&lt;/span&gt;)) &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;OperatorIndex&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;where&lt;/span&gt; attribute.OperatorId
!= &lt;span style="COLOR: #a31515"&gt;""&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;select&lt;/span&gt; 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;OperatorDetails&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; AssemName = a.GetName().Name,
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ClassName = t.FullName,
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; OperatorId = attribute.OperatorId
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
}).ToDictionary(p =&amp;gt; p.OperatorId,p =&amp;gt; p);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/span&gt; 
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&lt;font face=Verdana color=#000000 size=2&gt;The main &lt;em&gt;Calculate &lt;/em&gt;method
validates the input, retrieves the right operand key from the dictionary, late binds
to the proper &lt;em&gt;OperatorBase&lt;/em&gt; class and invokes the &lt;em&gt;Calculate() &lt;/em&gt;method,
as seen below.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&lt;font face=Verdana color=#000000 size=2&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;span style="COLOR: #2b91af"&gt;&lt;font face=Verdana color=#000000 size=2&gt; 
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//locate
the correct operator from our dictionary&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;OperatorDetails&lt;/span&gt; operatorInfo
= operations[mathOperator];
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//dynamically
load the operator class. I chose to do it using reflection so that we wouldn't need
a&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//factory,
which would need to be changed every time a new operator was added.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//ENHANCEMENT:
you could actually detect other assemblies and load them as well&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt; calcClass
= &lt;span style="COLOR: #2b91af"&gt;Type&lt;/span&gt;.GetType(operatorInfo.ClassName);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;OperationBase&lt;/span&gt; calculator
= (&lt;span style="COLOR: #2b91af"&gt;OperationBase&lt;/span&gt;) &lt;span style="COLOR: #2b91af"&gt;Activator&lt;/span&gt;.CreateInstance(calcClass);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; calculator.Value1
= value1;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; calculator.Value2
= value2;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; calculatedResult
= calculator.Calculate();
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/font&gt;
&lt;/font&gt;&gt;&gt;
&lt;/div&gt;
&lt;font face=Verdana size=2&gt;&lt;font face=Verdana size=2&gt;&lt;/font&gt;&lt;/font&gt;&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;font face=Verdana size=2&gt;&lt;font face=Verdana size=2&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp;
&lt;/div&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;font face=Verdana size=2&gt;&lt;font face=Verdana size=2&gt;Using
a console application, it looks like this:&lt;/font&gt;&lt;/font&gt;
&lt;/div&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;font face=Verdana size=2&gt;&lt;font face=Verdana size=2&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp;
&lt;/div&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;font face=Verdana size=2&gt;&lt;font face=Verdana size=2&gt;
&lt;!--EndFragment--&gt;&lt;/font&gt;
&lt;!--EndFragment--&gt;&lt;/font&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/calc_example.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Here's the sample code to look at and play with.. Enjoy!
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;a href="http://www.dotnettechnologies.com/content/binary/SampleProj.zip"&gt;SampleProj.zip
(89.4 KB)&lt;/a&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=28e48f37-06e8-4ef1-9abc-b2a44a34dcdf" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,28e48f37-06e8-4ef1-9abc-b2a44a34dcdf.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=4a377aac-37cf-4611-9579-20cec1061335</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,4a377aac-37cf-4611-9579-20cec1061335.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,4a377aac-37cf-4611-9579-20cec1061335.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=4a377aac-37cf-4611-9579-20cec1061335</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today has been an insanely busy day, but I have so much I want to blog about, and
this one won't wait. A few days ago, as I was using some code I found on the net,
I <a href="http://www.dotnettechnologies.com/PermaLink,guid,5428d2b4-f00b-47fc-91a9-6825caa723b6.aspx" target="_blank">commented
here</a> about the over-use of the <em>var</em> keyword.
</p>
        <p>
Seems I am not the only one who has an opinion on the matter. I subscribe to the CodeProject
newsletter, and each issue features a survey. This week, the survey relates to the
opinion of the <em>var</em> type in C#. You can see the <a href="http://www.codeproject.com/script/Surveys/Results.aspx?srvid=950" target="_blank">survey
results here</a>. Make sure you click through to the "optional text answers" for some
funny comments (and a few relevant ones as well).
</p>
        <p>
The interesting thing to note from the survey is that the answers tend to skew towards
the "never use that scenario" range. The two areas where it is most prevalent is with
LINQ, and with anonymous types, which makes total sense. 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=4a377aac-37cf-4611-9579-20cec1061335" />
      </body>
      <title>Topical: The use of the var keyword revisited</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,4a377aac-37cf-4611-9579-20cec1061335.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/25/TopicalTheUseOfTheVarKeywordRevisited.aspx</link>
      <pubDate>Tue, 25 Aug 2009 04:28:04 GMT</pubDate>
      <description>&lt;p&gt;
Today has been an insanely busy day, but I have so much I want to blog about, and
this one won't wait. A few days ago, as I was using some code I found on the net,
I &lt;a href="http://www.dotnettechnologies.com/PermaLink,guid,5428d2b4-f00b-47fc-91a9-6825caa723b6.aspx" target=_blank&gt;commented
here&lt;/a&gt; about the over-use of the &lt;em&gt;var&lt;/em&gt; keyword.
&lt;/p&gt;
&lt;p&gt;
Seems I am not the only one who has an opinion on the matter. I subscribe to the CodeProject
newsletter, and each issue features a survey. This week, the survey relates to the
opinion of the &lt;em&gt;var&lt;/em&gt; type in C#. You can see the &lt;a href="http://www.codeproject.com/script/Surveys/Results.aspx?srvid=950" target=_blank&gt;survey
results here&lt;/a&gt;. Make sure you click through to the "optional text answers" for some
funny comments (and a few relevant ones as well).
&lt;/p&gt;
&lt;p&gt;
The interesting thing to note from the survey is that the answers tend to skew towards
the "never use that scenario" range. The two areas where it is most prevalent is with
LINQ, and with anonymous types, which makes total sense. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=4a377aac-37cf-4611-9579-20cec1061335" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,4a377aac-37cf-4611-9579-20cec1061335.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=b94da6c0-6f70-4eee-841d-2d4236253c92</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,b94da6c0-6f70-4eee-841d-2d4236253c92.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,b94da6c0-6f70-4eee-841d-2d4236253c92.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=b94da6c0-6f70-4eee-841d-2d4236253c92</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>Question: </strong>What's reflection, and how have you used it to solve a
problem?
</p>
        <p>
          <strong>Answer: </strong>Reflection is a way to look at assembly metadata and look
in and see what is contained. It also allows you to use late binding and call methods
within those assembles.
</p>
        <p>
For the second part, a simple explanation is all you need to show that you understand
how it is used.
</p>
        <p>
So what if you've enver used reflection? First, shame on you (kidding!). It DOES serve
a very important purpose and allows for some great solutions, especially at an architectural
level. If you've never used it, I recommend immediately trying it out, and you'll
find many, many uses. Here's a <a href="http://www.codeguru.com/csharp/csharp/cs_misc/reflection/article.php/c4257" target="_blank">tutorial</a> I
found that looks decent. That way, when asked this question (and I get this one a
lot) you can answer how you *might* really use it. Honestly, you've probably used
it and didn't realize it if you've added certain attributes to your code.
</p>
        <p>
I have used reflection for everything from identifying certain classes and functions.
For example, for a coding sample, I used LINQ for Reflection and attributes to identify
classes which supported certain calculations. By doing this, I could add more
functions dynamically and the UI would pick it without changing code. Since LINQ for
Reflection is not discussed much, I'll post some about that later.
</p>
        <p>
There are some costs associated with Reflection though. Speed! Late Binding is slower
by it's nature, as well as all the processing looking for methods, so plan and use
wisely!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=b94da6c0-6f70-4eee-841d-2d4236253c92" />
      </body>
      <title>Tip of the Day: Technical Interview question: What's Reflection?</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,b94da6c0-6f70-4eee-841d-2d4236253c92.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/24/TipOfTheDayTechnicalInterviewQuestionWhatsReflection.aspx</link>
      <pubDate>Mon, 24 Aug 2009 14:27:02 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;Question: &lt;/strong&gt;What's reflection, and how have you used it to solve a
problem?
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Answer: &lt;/strong&gt;Reflection is a way to look at assembly metadata and look
in and see what is contained. It also allows you to use late binding and call methods
within those assembles.
&lt;/p&gt;
&lt;p&gt;
For the second part, a simple explanation is all you need to show that you understand
how it is used.
&lt;/p&gt;
&lt;p&gt;
So what if you've enver used reflection? First, shame on you (kidding!). It DOES serve
a very important purpose and allows for some great solutions, especially at an architectural
level. If you've never used it, I recommend immediately trying it out, and you'll
find many, many uses. Here's a &lt;a href="http://www.codeguru.com/csharp/csharp/cs_misc/reflection/article.php/c4257" target=_blank&gt;tutorial&lt;/a&gt; I
found that looks decent. That way, when asked this question (and I get this one a
lot) you can answer how you *might* really use it. Honestly, you've probably used
it and didn't realize it if you've added certain attributes to your code.
&lt;/p&gt;
&lt;p&gt;
I have used reflection for everything from identifying certain classes and functions.
For example, for a coding sample, I used LINQ for Reflection and attributes to identify
classes which supported certain calculations. By doing this,&amp;nbsp;I could add more
functions dynamically and the UI would pick it without changing code. Since LINQ for
Reflection is not discussed much, I'll post some about that later.
&lt;/p&gt;
&lt;p&gt;
There are some costs associated with Reflection though. Speed! Late Binding is slower
by it's nature, as well as all the processing looking for methods, so plan and use
wisely!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=b94da6c0-6f70-4eee-841d-2d4236253c92" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,b94da6c0-6f70-4eee-841d-2d4236253c92.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=1249a156-8ee0-439c-8a62-e368cd50e004</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,1249a156-8ee0-439c-8a62-e368cd50e004.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,1249a156-8ee0-439c-8a62-e368cd50e004.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1249a156-8ee0-439c-8a62-e368cd50e004</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As a full time developer, I search the web... a lot. If you are writing a lot of new
code without at least searching to see what exists, you're either getting paid by
the hour (or line of code), stubborn or a glutton for punishment. Even if I don't
use it, I can get some guidance on what someone else tried, and how it worked out
before I start coding. Granted, it usually requires a lot of refactoring the code
to my standards or needs, but it's a great start.
</p>
        <p>
As I was thinking of things I wanted to put on my site, I realized it would be nice
to share my "favorites"...sort of. If I found something useful, I wanted to be able
to show what it was, how I found it useful and where someone else can find it. In
a way, I am also helping to promote someone else's hard work and improving their search
engine visibility to return the favor of their sharing their work.
</p>
        <p>
Out of this, I came up with an idea for a "Useful Links" section. I wanted to be able
to add links and commentary, and also add it to my <a href="http://www.dotnettechnologies.com/PermaLink,guid,308bd3f2-4d3c-48b6-84f2-1dbe04982eed.aspx" target="_blank">Activity
Aggregator</a> to show help show the content of the site has changed. Later, as I
was using Bing, I got the idea to add some webthumbs to enhance the page graphically,
so the reader would know what the site looked like before going there. I also needed
to add an admin page for creating the useful links (and ultimately maintaining them
-- which is on my TODO list). I'll also leave out the icon creation part, although
I really need to farm out for a new cool looking icon, which is also on my list of
things to do.
</p>
        <p>
I'll skip the admin section, as it's just data entry fields. The process for creating
the entries does change a bit, as I needed to do a few extra steps.
</p>
        <ol>
          <li>
Save the UsefulLink class 
</li>
          <li>
Default the webthumb image to a default "safety" image in case we can't get a webthumb 
</li>
          <li>
Make a request to get a webthumb image of the target site 
</li>
          <li>
Once the image is retrieved, update the UsefulLink record to point to the new webthumb 
</li>
          <li>
Update the Activity Aggregator to show we have a new useful link.</li>
        </ol>
        <p>
Step 3 is where things get tricky. How in all getout do we get webthumb images? There
are <a href="http://www.acasystems.com/en/web-thumb-activex/faq-generate-image-from-html-in-c-sharp.htm" target="_blank">controls </a>out
there you can get, and they are reasonably priced as well. But I decided to keep searching
so I could write this one on my own, as it seems like an interesting challenge.
</p>
        <p>
My next thought was to create my own service to do this. There's plenty of code
out there, but the easiest way to do this would require some WinForms programming.
Don't get me wrong, I LOVE programming WinForms. The problem is I don't want to have
to install it everywhere I am at, as I need a service. I could possibly create a Web
and Windows service to do this as well, but that seemed overly complex. So I did a
search, and I found <a href="http://webthumb.bluga.net/home" target="_blank">this</a>,
which is a service which does it for you. What's even nicer is that they expose a
nice API to use. As of now, the first 100 images a month are free, and after that,
the fees are very reasonable. Even though I doubt I will go over 100 images per month,
I am so impressed I may pay just to keep the service going.
</p>
        <p>
I was also able to find some c# code to make learning the API fast. I did end up changing
it some, but in general it worked very well. You can find it <a href="http://stackoverflow.com/questions/701680/how-do-i-save-a-web-page-to-image-using-c" target="_blank">here</a>.
</p>
        <p>
So when the service returns with my image (I used the medium size), I save it to a
thumbs directory (had to add write permissions to the directory, or I got an obscure GDI+
error), and call a method on my UsefulLink class to update the record with the thumbnail
image. I name the image with the current date and time so that the names will be unique
as well.
</p>
        <p>
Finally, once I have downloaded the image and updated the UsefulLink record, I add
a call to my Activity class which creates an entry for the Activity Aggregator.
As I add more items to throw into the Activity Aggregator, I am considering refactoring
things to do some delegate multicasting for all the updates, or perhaps creating a
factory where you provide class (should be easy since my business objects
share the same base class) or interface, and it knows how to create the activity
record instead of making individual calls. That's on my list down the road. :)
</p>
        <p>
Here's what the Activity Aggrgator looks like, with a special Useful Link icon(<img src="http://www.dotnettechnologies.com/content/binary/useful_link.png" border="0" />):
</p>
        <p>
 
</p>
        <p>
          <img src="http://www.dotnettechnologies.com/content/binary/DevArea_new.png" border="0" />
        </p>
        <p>
And here's what the Useful Link section (which has the webthumbs) looks like. I will
only be showing 10 at a time to save web page real estate. But I also don't want to
lose older links off the page. I am debating now whether to use paging, or just have a
smaller hyperlink-only section below the most recent links. I am leaning towards paging,
as I have a very neat service I want to implement which makes paging and sorting incredibly
fast and easy (more on that someday.. I need to upgrade it to user .Net 3.5 functionality
before I post it).
</p>
        <p>
 
</p>
        <img src="http://www.dotnettechnologies.com/content/binary/UsefulLinks.png" border="0" />
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1249a156-8ee0-439c-8a62-e368cd50e004" />
      </body>
      <title>Useful Links -- An overview</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,1249a156-8ee0-439c-8a62-e368cd50e004.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/23/UsefulLinksAnOverview.aspx</link>
      <pubDate>Sun, 23 Aug 2009 16:28:00 GMT</pubDate>
      <description>&lt;p&gt;
As a full time developer, I search the web... a lot. If you are writing a lot of new
code without at least searching to see what exists, you're either getting paid by
the hour (or line of code), stubborn or a glutton for punishment. Even if I don't
use it, I can get some guidance on what someone else tried, and how it worked out
before I start coding. Granted, it usually requires a lot of refactoring the code
to my standards or needs, but it's a great start.
&lt;/p&gt;
&lt;p&gt;
As I was thinking of things I wanted to put on my site, I realized it would be nice
to share my "favorites"...sort of. If I found something useful, I wanted to be able
to show what it was, how I found it useful and where someone else can find it. In
a way, I am also helping to promote someone else's hard work and improving their search
engine visibility to return the favor of their sharing their work.
&lt;/p&gt;
&lt;p&gt;
Out of this, I came up with an idea for a "Useful Links" section. I wanted to be able
to add links and commentary, and also add it to my &lt;a href="http://www.dotnettechnologies.com/PermaLink,guid,308bd3f2-4d3c-48b6-84f2-1dbe04982eed.aspx" target=_blank&gt;Activity
Aggregator&lt;/a&gt; to show help show the content of the site has changed. Later, as I
was using Bing, I got the idea to add some webthumbs to enhance the page graphically,
so the reader would know what the site looked like before going there. I also needed
to add an admin page for creating the useful links (and ultimately maintaining them
-- which is on my TODO list). I'll also leave out the icon creation part, although
I really need to farm out for a new cool looking icon, which is also on my list of
things to do.
&lt;/p&gt;
&lt;p&gt;
I'll skip the admin section, as it's just data entry fields. The process for creating
the entries does change a bit, as I needed to do a few extra steps.
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Save the UsefulLink class 
&lt;li&gt;
Default the webthumb image to a default "safety" image in case we can't get a webthumb 
&lt;li&gt;
Make a request to get a webthumb image of the target site 
&lt;li&gt;
Once the image is retrieved, update the UsefulLink record to point to the new webthumb 
&lt;li&gt;
Update the Activity Aggregator to show we have a new useful link.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Step 3 is where things get tricky. How in all getout do we get webthumb images? There
are &lt;a href="http://www.acasystems.com/en/web-thumb-activex/faq-generate-image-from-html-in-c-sharp.htm" target=_blank&gt;controls &lt;/a&gt;out
there you can get, and they are reasonably priced as well. But I decided to keep searching
so I could write this one on my own, as it seems like an interesting challenge.
&lt;/p&gt;
&lt;p&gt;
My&amp;nbsp;next thought was to create my own service to do this. There's plenty of code
out there, but the easiest way to do this would require some WinForms programming.
Don't get me wrong, I LOVE programming WinForms. The problem is I don't want to have
to install it everywhere I am at, as I need a service. I could possibly create a Web
and Windows service to do this as well, but that seemed overly complex. So I did a
search, and I found &lt;a href="http://webthumb.bluga.net/home" target=_blank&gt;this&lt;/a&gt;,
which is a service which does it for you. What's even nicer is that they expose a
nice API to use. As of now, the first 100 images a month are free, and after that,
the fees are very reasonable. Even though I doubt I will go over 100 images per month,
I am so impressed I may pay just to keep the service going.
&lt;/p&gt;
&lt;p&gt;
I was also able to find some c# code to make learning the API fast. I did end up changing
it some, but in general it worked very well. You can find it &lt;a href="http://stackoverflow.com/questions/701680/how-do-i-save-a-web-page-to-image-using-c" target=_blank&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
So when the service returns with my image (I used the medium size), I save it to a
thumbs directory (had to add write permissions to the directory, or I got an obscure&amp;nbsp;GDI+
error), and call a method on my UsefulLink class to update the record with the thumbnail
image. I name the image with the current date and time so that the names will be unique
as well.
&lt;/p&gt;
&lt;p&gt;
Finally, once I have downloaded the image and updated the UsefulLink record, I add
a call to my Activity class which creates an entry&amp;nbsp;for the Activity Aggregator.
As I add more items to throw into the Activity Aggregator, I am considering refactoring
things to do some delegate multicasting for all the updates, or perhaps creating a
factory where you provide&amp;nbsp;class (should be&amp;nbsp;easy since my business objects
share the same base class)&amp;nbsp;or interface, and it knows how to create the activity
record instead of making individual calls. That's on my list down the road. :)
&lt;/p&gt;
&lt;p&gt;
Here's what the Activity Aggrgator looks like, with a special Useful Link icon(&lt;img src="http://www.dotnettechnologies.com/content/binary/useful_link.png" border=0&gt;):
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/DevArea_new.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
And here's what the Useful Link section (which has the webthumbs) looks like. I will
only be showing 10 at a time to save web page real estate. But I also don't want to
lose older links off the page. I am debating now whether to use paging, or just have&amp;nbsp;a
smaller hyperlink-only section below the most recent links. I am leaning towards paging,
as I have a very neat service I want to implement which makes paging and sorting incredibly
fast and easy (more on that someday.. I need to upgrade it to user .Net 3.5 functionality
before I post it).
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/UsefulLinks.png" border=0&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1249a156-8ee0-439c-8a62-e368cd50e004" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,1249a156-8ee0-439c-8a62-e368cd50e004.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=5428d2b4-f00b-47fc-91a9-6825caa723b6</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,5428d2b4-f00b-47fc-91a9-6825caa723b6.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,5428d2b4-f00b-47fc-91a9-6825caa723b6.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5428d2b4-f00b-47fc-91a9-6825caa723b6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today, I was super-dad AND got a lot of coding done, and I managed to get my useful
links controls done for my site <a href="http://www.rubiconcomputing.com/DevArea.aspx" target="_blank">here</a>.
It was actually a complex process to get things like the webthumbs integrated, update
the activity aggregator, create an admin page. The end result needs some cleanup,
but I think for a first run, it came out nice. Tomorrow I will blog on the details
and some code on how I did everything in case someone decides they want something
similar.
</p>
        <p>
Tonight, I am tired. But as I was coding, I came across some code for accessing my
webthumbs, and something struck me. In .Net 3.5, there's a new keyword "var" which
allows for anonymous casting (sort of). When it compiles, the underlying code is cast
to the correct type, and in using the var typed variable, it acts like the cast-type.
It would definitely speed up development if you used it a lot. For those old-school
VB fans, it really reminds me of the variant data type (which it is not). Read more
about it <a href="http://msdn.microsoft.com/en-us/library/bb383973.aspx" target="_blank">here </a>if
you want some details.
</p>
        <p>
However, as with all things, there is a cost. For me, it's readability. In English
anyways, we read left to right. When I see a "var" vast variable, I have to keep reading
to understand the type, then see how it is used. Not too difficult (unless it is coming
out of a function or LINQ query), but it does take a little more time to figure it
out. For example..
</p>
        <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">var</span> doc = <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">XDocument</span>(
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">XElement</span>(
</p>
        </div>
        <!--EndFragment-->
        <p>
That being said, you can get around using it by declaring the variable to the
expected type when you code it. I have some samples I will post later when I was using
LINQ I forced myself to do this so I would fully understand what was happening in
my LINQ. <a href="http://richarddingwall.name/2008/06/21/csharps-var-keyword-jeff-atwood-gets-it-all-wrong/" target="_blank">Here's</a> someone
else who is taking a similar take on it.
</p>
        <p>
Anyone have any thoughts on that?
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=5428d2b4-f00b-47fc-91a9-6825caa723b6" />
      </body>
      <title>WebThumbs working.. but an aside about VS.Net 2008's var keyword</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,5428d2b4-f00b-47fc-91a9-6825caa723b6.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/23/WebThumbsWorkingButAnAsideAboutVSNet2008sVarKeyword.aspx</link>
      <pubDate>Sun, 23 Aug 2009 06:09:25 GMT</pubDate>
      <description>&lt;p&gt;
Today, I was super-dad AND got a lot of coding done, and I managed to get my useful
links controls done for my site &lt;a href="http://www.rubiconcomputing.com/DevArea.aspx" target=_blank&gt;here&lt;/a&gt;.
It was actually a complex process to get things like the webthumbs integrated, update
the activity aggregator, create an admin page. The end result needs some cleanup,
but I think for a first run, it came out nice. Tomorrow I will blog on the details
and some code on how I did everything in case someone decides they want something
similar.
&lt;/p&gt;
&lt;p&gt;
Tonight, I am tired. But as I was coding, I came across some code for accessing my
webthumbs, and something struck me. In .Net 3.5, there's a new keyword "var" which
allows for anonymous casting (sort of). When it compiles, the underlying code is cast
to the correct type, and in using the var typed variable, it acts like the cast-type.
It would definitely speed up development if you used it a lot. For those old-school
VB fans, it really reminds me of the variant data type (which it is not). Read more
about it &lt;a href="http://msdn.microsoft.com/en-us/library/bb383973.aspx" target=_blank&gt;here &lt;/a&gt;if
you want some details.
&lt;/p&gt;
&lt;p&gt;
However, as with all things, there is a cost. For me, it's readability. In English
anyways, we read left to right. When I see a "var" vast variable, I have to keep reading
to understand the type, then see how it is used. Not too difficult (unless it is coming
out of a function or LINQ query), but it does take a little more time to figure it
out. For example..
&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; doc = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;XDocument&lt;/span&gt;(
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;XElement&lt;/span&gt;(
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;
&lt;p&gt;
That being said, you can get around using it by&amp;nbsp;declaring the variable to the
expected type when you code it. I have some samples I will post later when I was using
LINQ I forced myself to do this so I would fully understand what was happening in
my LINQ. &lt;a href="http://richarddingwall.name/2008/06/21/csharps-var-keyword-jeff-atwood-gets-it-all-wrong/" target=_blank&gt;Here's&lt;/a&gt; someone
else who is taking a similar take on it.
&lt;/p&gt;
&lt;p&gt;
Anyone have any thoughts on that?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=5428d2b4-f00b-47fc-91a9-6825caa723b6" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,5428d2b4-f00b-47fc-91a9-6825caa723b6.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=80361cb8-d014-4cc3-b122-202c9f889e92</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,80361cb8-d014-4cc3-b122-202c9f889e92.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,80361cb8-d014-4cc3-b122-202c9f889e92.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=80361cb8-d014-4cc3-b122-202c9f889e92</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font face="Calibri" color="#000000" size="3">Here’s another question which is very
basic, and is mandatory to be able to answer for C# developers: </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b>Question</b>: What are
the various access modifiers in C#?</font>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b>
                </b>
              </font>
            </font>
          </font> 
</p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b>Answer: </b>public, private,
protected, internal, protected internal</font>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font face="Calibri" color="#000000" size="3">Depending on how the person answers
the question (e.g. if it’s obviously an easy question for them, I move on), I may
follow up with “So what does the protected keyword mean?”</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font face="Calibri" color="#000000" size="3">So here’s the answers to each… you absolutely
need to know what each of these are!</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b>Public</b> – accessible
to anything </font>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b>Private</b> – can only
be access by code in the same class or struct</font>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b>Internal</b> – accessible
only within the same assembly</font>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b>Protected</b> – accessible
in the same class, or in a derived class</font>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font face="Calibri" color="#000000" size="3">
          </font> 
</p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
          <font face="Calibri" color="#000000" size="3">Go here for some more info if needed:  </font>
          <a href="http://msdn.microsoft.com/en-us/library/ms173121.aspx" target="_blank">
            <font face="Calibri" size="3">http://msdn.microsoft.com/en-us/library/ms173121.aspx</font>
          </a>
          <font face="Calibri" color="#000000" size="3">
          </font>
        </p>
        <p>
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=80361cb8-d014-4cc3-b122-202c9f889e92" />
      </body>
      <title>Tip of the Day: Interview Questions- Access modifiers in C#         </title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,80361cb8-d014-4cc3-b122-202c9f889e92.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/21/TipOfTheDayInterviewQuestionsAccessModifiersInC.aspx</link>
      <pubDate>Fri, 21 Aug 2009 04:06:04 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Here’s another question which is very basic,
and is mandatory to be able to answer for C# developers: &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b&gt;Question&lt;/b&gt;: What are the
various access modifiers in C#?&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b&gt;&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b&gt;Answer: &lt;/b&gt;public, private,
protected, internal, protected internal&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Depending on how the person answers the question
(e.g. if it’s obviously an easy question for them, I move on), I may follow up with
“So what does the protected keyword mean?”&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;So here’s the answers to each… you absolutely
need to know what each of these are!&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b&gt;Public&lt;/b&gt; – accessible to
anything &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b&gt;Private&lt;/b&gt; – can only be access
by code in the same class or struct&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b&gt;Internal&lt;/b&gt; – accessible only
within the same assembly&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b&gt;Protected&lt;/b&gt; – accessible
in the same class, or in a derived class&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Go here for some more info if needed:&amp;nbsp; &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms173121.aspx" target=_blank&gt;&lt;font face=Calibri size=3&gt;http://msdn.microsoft.com/en-us/library/ms173121.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=80361cb8-d014-4cc3-b122-202c9f889e92" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,80361cb8-d014-4cc3-b122-202c9f889e92.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=8c4e1e9c-694d-4f4a-8a3d-1bd92c0738ac</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,8c4e1e9c-694d-4f4a-8a3d-1bd92c0738ac.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,8c4e1e9c-694d-4f4a-8a3d-1bd92c0738ac.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8c4e1e9c-694d-4f4a-8a3d-1bd92c0738ac</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">
            <strong>Question</strong>: What are
the various ways of maintaining state in an ASP.Net application?</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">A lot of people answer this with the
different time of Session providers, but it’s not the same things. The key of this
question is two-fold, do you know the object, and do you know when/how to properly
use them (which leads to follow-up questions to gauge whether the person memorized
the answer, or truly understands the concept).</font>
        </p>
        <p class="MsoListParagraphCxSpFirst" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <span style="mso-list: Ignore">
                <font size="3">·</font>
                <span style="FONT: 7pt 'Times New Roman'">         </span>
              </span>
            </span>
            <font face="Calibri" size="3">Session</font>
          </font>
        </p>
        <p class="MsoListParagraphCxSpMiddle" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <span style="mso-list: Ignore">
                <font size="3">·</font>
                <span style="FONT: 7pt 'Times New Roman'">         </span>
              </span>
            </span>
            <font face="Calibri" size="3">ViewState</font>
          </font>
        </p>
        <p class="MsoListParagraphCxSpMiddle" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <span style="mso-list: Ignore">
                <font size="3">·</font>
                <span style="FONT: 7pt 'Times New Roman'">         </span>
              </span>
            </span>
            <font face="Calibri" size="3">Application</font>
          </font>
        </p>
        <p class="MsoListParagraphCxSpMiddle" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <span style="mso-list: Ignore">
                <font size="3">·</font>
                <span style="FONT: 7pt 'Times New Roman'">         </span>
              </span>
            </span>
            <font face="Calibri" size="3">Cache</font>
          </font>
        </p>
        <p class="MsoListParagraphCxSpMiddle" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <span style="mso-list: Ignore">
                <font size="3">·</font>
                <span style="FONT: 7pt 'Times New Roman'">         </span>
              </span>
            </span>
            <font face="Calibri" size="3">Cookies</font>
          </font>
        </p>
        <p class="MsoListParagraphCxSpMiddle" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <span style="mso-list: Ignore">
                <font size="3">·</font>
                <span style="FONT: 7pt 'Times New Roman'">         </span>
              </span>
            </span>
            <font face="Calibri" size="3">Hidden
Fields</font>
          </font>
        </p>
        <p class="MsoListParagraphCxSpMiddle" style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <span style="mso-list: Ignore">
                <font size="3">·</font>
                <span style="FONT: 7pt 'Times New Roman'">         </span>
              </span>
            </span>
            <font face="Calibri" size="3">Query
Strings</font>
          </font>
        </p>
        <p class="MsoListParagraphCxSpLast" style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1">
          <font color="#000000">
            <span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol">
              <span style="mso-list: Ignore">
                <font size="3">·</font>
                <span style="FONT: 7pt 'Times New Roman'">         </span>
              </span>
            </span>
            <font face="Calibri" size="3">Profile
Settings</font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">The big ones I look for are Session,
ViewState, Application and Cache. If they answer that, I drill down a bit for understanding.
For example, I might ask:</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b style="mso-bidi-font-weight: normal">Question</b>:
How does application and cache differ? </font>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b style="mso-bidi-font-weight: normal">Answer:</b> They
are both globally available to an application, but with cache, the server can free
this up if it needs resources. Additionally, you can expire it after a predefined
time, or is a file changes, etc.</font>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b style="mso-bidi-font-weight: normal">Question:</b> What
are the dangers/concerns of using viewstate?</font>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font size="3">
            <font color="#000000">
              <font face="Calibri">
                <b style="mso-bidi-font-weight: normal">Answer: </b>Page
size, performance, security, etc..</font>
            </font>
          </font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0in 0in 10pt">
          <font face="Calibri" color="#000000" size="3">The bottom line is that this question
is fundamental to ASP.Net development, and it’s important you fully understand the
implications of each. <span style="mso-spacerun: yes"> </span>Failure to answer
this question and any follow-ups is definitely damaging when I perform interviews.</font>
        </p>
        <p>
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=8c4e1e9c-694d-4f4a-8a3d-1bd92c0738ac" />
      </body>
      <title>Tip of the day: Interview Question: What are some of the ways of maintaining state in an asp.net application?</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,8c4e1e9c-694d-4f4a-8a3d-1bd92c0738ac.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/19/TipOfTheDayInterviewQuestionWhatAreSomeOfTheWaysOfMaintainingStateInAnAspnetApplication.aspx</link>
      <pubDate>Wed, 19 Aug 2009 19:34:53 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&lt;strong&gt;Question&lt;/strong&gt;: What are the various
ways of maintaining state in an ASP.Net application?&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;A lot of people answer this with the different
time of Session providers, but it’s not the same things. The key of this question
is two-fold, do you know the object, and do you know when/how to properly use them
(which leads to follow-up questions to gauge whether the person memorized the answer,
or truly understands the concept).&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpFirst style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Session&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;ViewState&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Application&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Cache&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Cookies&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Hidden
Fields&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpMiddle style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Query
Strings&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoListParagraphCxSpLast style="MARGIN: 0in 0in 10pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1"&gt;
&lt;font color=#000000&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;font size=3&gt;·&lt;/font&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face=Calibri size=3&gt;Profile
Settings&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The big ones I look for are Session, ViewState,
Application and Cache. If they answer that, I drill down a bit for understanding.
For example, I might ask:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Question&lt;/b&gt;:
How does application and cache differ? &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Answer:&lt;/b&gt; They
are both globally available to an application, but with cache, the server can free
this up if it needs resources. Additionally, you can expire it after a predefined
time, or is a file changes, etc.&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Question:&lt;/b&gt; What
are the dangers/concerns of using viewstate?&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;Answer: &lt;/b&gt;Page
size, performance, security, etc..&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;The bottom line is that this question is fundamental
to ASP.Net development, and it’s important you fully understand the implications of
each. &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;Failure to answer this question
and any follow-ups is definitely damaging when I perform interviews.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=8c4e1e9c-694d-4f4a-8a3d-1bd92c0738ac" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,8c4e1e9c-694d-4f4a-8a3d-1bd92c0738ac.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=9ce8b8f1-1639-45fd-819b-7ce942362179</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,9ce8b8f1-1639-45fd-819b-7ce942362179.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,9ce8b8f1-1639-45fd-819b-7ce942362179.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9ce8b8f1-1639-45fd-819b-7ce942362179</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've been doing technical interviews for about 5 years now for .Net, and hired a lot
of developers in that time. As a result, I have become proficient at quickly assessing
a level of technical expertise as well as how a developer may fit within an organization.
I will blog another time about what characteristics I look for in a candidate,
but for now, I will go through some of the technical questions I ask, answer them,
and explain why I ask the question.
</p>
        <p>
          <strong>Question:</strong> What's the difference between an abstract class and an
interface
</p>
        <p>
          <strong>Answer: </strong>They have some similarities in that they both define abstract
members which have to be implemented. An interface is really just a contract where
you are stating "if I implement this interface, I will implement these methods". However,
an abstract class <em>can</em> have an implementation, where an interface cannot.
An abstract class can also have constructors and field data. 
</p>
        <p>
One advantage of an interface is that you can implement more than one interface per
class, but you can only inherit from one class.
</p>
        <p>
Note there's a lot more you could talk about with them both (and you don't want to
overtalk any question), but the above will demonstrate you have a good knowledge of
OOP design, which is what I was looking for. It's surprising how many developers
cannot get this question right.
</p>
        <p>
To learn more, here's a <a href="http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx" target="_blank">good
article </a>which discusses them in more detail (more than you'd need to answer the
question for sure, but good knowledge to have!)
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9ce8b8f1-1639-45fd-819b-7ce942362179" />
      </body>
      <title>Tip of the Day: Technical Interview question: The difference between a abstract class and an interface</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,9ce8b8f1-1639-45fd-819b-7ce942362179.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/18/TipOfTheDayTechnicalInterviewQuestionTheDifferenceBetweenAAbstractClassAndAnInterface.aspx</link>
      <pubDate>Tue, 18 Aug 2009 15:02:10 GMT</pubDate>
      <description>&lt;p&gt;
I've been doing technical interviews for about 5 years now for .Net, and hired a lot
of developers in that time. As a result, I have become proficient at quickly assessing
a level of technical expertise as well as how a developer may fit within an organization.
I will blog another time about&amp;nbsp;what characteristics I look for in a candidate,
but for now, I will go through some of the technical questions I ask, answer them,
and explain why I ask the question.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Question:&lt;/strong&gt; What's the difference between an abstract class and an
interface
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Answer: &lt;/strong&gt;They have some similarities in that they both define abstract
members which have to be implemented. An interface is really just a contract where
you are stating "if I implement this interface, I will implement these methods". However,
an abstract class &lt;em&gt;can&lt;/em&gt; have an implementation, where an interface cannot.
An abstract class can also have constructors and field data. 
&lt;/p&gt;
&lt;p&gt;
One advantage of an interface is that you can implement more than one interface per
class, but you can only inherit from one class.
&lt;/p&gt;
&lt;p&gt;
Note there's a lot more you could talk about with them both (and you don't want to
overtalk any question), but the above will demonstrate you have a good knowledge of
OOP design, which is what I was looking for. It's&amp;nbsp;surprising how many developers
cannot get this question right.
&lt;/p&gt;
&lt;p&gt;
To learn more, here's a &lt;a href="http://www.codeproject.com/KB/cs/abstractsvsinterfaces.aspx" target=_blank&gt;good
article &lt;/a&gt;which discusses them in more detail (more than you'd need to answer the
question for sure, but good knowledge to have!)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9ce8b8f1-1639-45fd-819b-7ce942362179" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,9ce8b8f1-1639-45fd-819b-7ce942362179.aspx</comments>
      <category>All Things</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=bc6f5c00-7429-4ae3-911d-121870d05fe8</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,bc6f5c00-7429-4ae3-911d-121870d05fe8.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,bc6f5c00-7429-4ae3-911d-121870d05fe8.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=bc6f5c00-7429-4ae3-911d-121870d05fe8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As developers, we tend to get stuck in development boxes. By that, a lot of times
you're so busy heads down, things change around you and you don't get a chance to
do different things unless a problem comes up and you research the solution to it. 
</p>
        <p>
As new developers, the amount of information available can seem overwhelming. When
do I use a web service? What are Design Patterns? What's the recommended way to.....
you get the idea.
</p>
        <p>
Fortunately, there's a guide on CodePlex which present high level concepts and recommendations
for architects and would-be architects. It's a great reference, and best of all, it's
free! If you have not downloaded it, I highly recommend you rush <a href="http://www.codeplex.com/AppArchGuide/Release/ProjectReleases.aspx?ReleaseId=20586" target="_blank">here</a> and
get it.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=bc6f5c00-7429-4ae3-911d-121870d05fe8" />
      </body>
      <title>Tip of the Day: Get the Application Architecture guidelines!</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,bc6f5c00-7429-4ae3-911d-121870d05fe8.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/17/TipOfTheDayGetTheApplicationArchitectureGuidelines.aspx</link>
      <pubDate>Mon, 17 Aug 2009 00:21:50 GMT</pubDate>
      <description>&lt;p&gt;
As developers, we tend to get stuck in development boxes. By that, a lot of times
you're so busy heads down, things change around you and you don't get a chance to
do different things unless a problem comes up and you research the solution to it. 
&lt;/p&gt;
&lt;p&gt;
As new developers, the amount of information available can seem overwhelming. When
do I use a web service? What are Design Patterns? What's the recommended way to.....
you get the idea.
&lt;/p&gt;
&lt;p&gt;
Fortunately, there's a guide on CodePlex which present high level concepts and recommendations
for architects and would-be architects. It's a great reference, and best of all, it's
free! If you have not downloaded it, I highly recommend you rush &lt;a href="http://www.codeplex.com/AppArchGuide/Release/ProjectReleases.aspx?ReleaseId=20586" target=_blank&gt;here&lt;/a&gt; and
get it.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=bc6f5c00-7429-4ae3-911d-121870d05fe8" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,bc6f5c00-7429-4ae3-911d-121870d05fe8.aspx</comments>
      <category>All Things</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=a4c84cd2-f350-40bb-b2d5-95f2765fbe5f</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,a4c84cd2-f350-40bb-b2d5-95f2765fbe5f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,a4c84cd2-f350-40bb-b2d5-95f2765fbe5f.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a4c84cd2-f350-40bb-b2d5-95f2765fbe5f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Decided to look at my web stats, and when I was looking at the search criteria people
were using to find my site, I had to laugh at this one: hate llblgen
</p>
        <p>
I wonder if someone else was at the point of frustration I was. All I can say is this
-- don't blog about it!! :) I really ought to categorize this as a "Trick or Tip". 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a4c84cd2-f350-40bb-b2d5-95f2765fbe5f" />
      </body>
      <title>Search results.. and humor</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,a4c84cd2-f350-40bb-b2d5-95f2765fbe5f.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/16/SearchResultsAndHumor.aspx</link>
      <pubDate>Sun, 16 Aug 2009 17:19:47 GMT</pubDate>
      <description>&lt;p&gt;
Decided to look at my web stats, and when I was looking at the search criteria people
were using to find my site, I had to laugh at this one: hate llblgen
&lt;/p&gt;
&lt;p&gt;
I wonder if someone else was at the point of frustration I was. All I can say is this
-- don't blog about it!! :) I really ought to categorize this as a "Trick or Tip". 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a4c84cd2-f350-40bb-b2d5-95f2765fbe5f" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,a4c84cd2-f350-40bb-b2d5-95f2765fbe5f.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=e9eb693b-4bfb-464c-bbac-11053bfe6e8e</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,e9eb693b-4bfb-464c-bbac-11053bfe6e8e.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,e9eb693b-4bfb-464c-bbac-11053bfe6e8e.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e9eb693b-4bfb-464c-bbac-11053bfe6e8e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I needed to use LINQ to XML to grab some RSS feed information into a BusinessObject
I created to save to a database. Here's what I needed:
</p>
        <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">var</span> activityList = <span style="COLOR: blue">from</span> e <span style="COLOR: blue">in</span> doc.Descendants(<span style="COLOR: #a31515">"item"</span>)
</p>
          <p style="MARGIN: 0px">
                   
                   <span style="COLOR: blue">select</span><span style="COLOR: blue">new</span> RubiconPortal.BusinessObjects.<span style="COLOR: #2b91af">Activity</span></p>
          <p style="MARGIN: 0px">
                   
                  
{
</p>
          <p style="MARGIN: 0px">
                   
                   
   ActivityTypeID = <span style="COLOR: #2b91af">ActivityTypes</span>.Blog.Code,
</p>
          <p style="MARGIN: 0px">
                   
                   
   ActivityDate = e.Element(<span style="COLOR: #a31515">"pubDate"</span>).Value.RSSDateTime().ToShortDateString()
+ <span style="COLOR: #a31515">" "</span> + e.Element(<span style="COLOR: #a31515">"pubDate"</span>).Value.RSSDateTime().ToShortDateString(),
</p>
          <p style="MARGIN: 0px">
                   
                   
   ActivitySummary = <span style="COLOR: #2b91af">HttpUtility</span>.HtmlDecode(e.Element(<span style="COLOR: #a31515">"title"</span>).Value),
</p>
          <p style="MARGIN: 0px">
                   
                   
   ActivityDetailsURL = e.Element(<span style="COLOR: #a31515">"link"</span>).Value
</p>
          <p style="MARGIN: 0px">
                   
                  
};
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <font face="Verdana" size="2">Since the pubDate comes across in a format which is
different than I wanted, I decided to write an extension method called RSSDateTime()
to convert to a DateTime, from which I can format any way I want or work with. Here's
the method:</font>
          </p>
          <p style="MARGIN: 0px">
 
</p>
          <div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
            <p style="MARGIN: 0px">
              <span style="COLOR: blue">public</span>
              <span style="COLOR: blue">static</span>
              <span style="COLOR: #2b91af">DateTime</span> RSSDateTime(<span style="COLOR: blue">this</span><span style="COLOR: blue">string</span> date)
</p>
            <p style="MARGIN: 0px">
        {
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">DateTime</span> d;
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: blue">if</span> (<span style="COLOR: #2b91af">DateTime</span>.TryParse(date, <span style="COLOR: blue">out</span> d))
</p>
            <p style="MARGIN: 0px">
            {
</p>
            <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span><span style="COLOR: #2b91af">Convert</span>.ToDateTime(date);
</p>
            <p style="MARGIN: 0px">
            }
</p>
            <p style="MARGIN: 0px">
 
</p>
            <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span><span style="COLOR: #2b91af">DateTime</span>.Now;
</p>
            <p style="MARGIN: 0px">
 
</p>
            <p style="MARGIN: 0px">
        }
</p>
          </div>
          <!--EndFragment-->
        </div>
        <!--EndFragment-->
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=e9eb693b-4bfb-464c-bbac-11053bfe6e8e" />
      </body>
      <title>Tip of the Day: Creating an Extension method to convert RSS pubDate to DateTime</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,e9eb693b-4bfb-464c-bbac-11053bfe6e8e.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/15/TipOfTheDayCreatingAnExtensionMethodToConvertRSSPubDateToDateTime.aspx</link>
      <pubDate>Sat, 15 Aug 2009 20:18:49 GMT</pubDate>
      <description>&lt;p&gt;
I needed to use LINQ to XML to grab some RSS feed information into a BusinessObject
I created to save to a database. Here's what I needed:
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;var&lt;/span&gt; activityList = &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; e &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; doc.Descendants(&lt;span style="COLOR: #a31515"&gt;"item"&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;select&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; RubiconPortal.BusinessObjects.&lt;span style="COLOR: #2b91af"&gt;Activity&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; ActivityTypeID = &lt;span style="COLOR: #2b91af"&gt;ActivityTypes&lt;/span&gt;.Blog.Code,
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; ActivityDate = e.Element(&lt;span style="COLOR: #a31515"&gt;"pubDate"&lt;/span&gt;).Value.RSSDateTime().ToShortDateString()
+ &lt;span style="COLOR: #a31515"&gt;" "&lt;/span&gt; + e.Element(&lt;span style="COLOR: #a31515"&gt;"pubDate"&lt;/span&gt;).Value.RSSDateTime().ToShortDateString(),
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; ActivitySummary = &lt;span style="COLOR: #2b91af"&gt;HttpUtility&lt;/span&gt;.HtmlDecode(e.Element(&lt;span style="COLOR: #a31515"&gt;"title"&lt;/span&gt;).Value),
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; ActivityDetailsURL = e.Element(&lt;span style="COLOR: #a31515"&gt;"link"&lt;/span&gt;).Value
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;
};
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;font face=Verdana size=2&gt;Since the pubDate comes across in a format which is different
than I wanted, I decided to write an extension method called RSSDateTime() to convert
to a DateTime, from which I can format any way I want or work with. Here's the method:&lt;/font&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;div style="FONT-SIZE: 8pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt; RSSDateTime(&lt;span style="COLOR: blue"&gt;this&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; date)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt; d;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;.TryParse(date, &lt;span style="COLOR: blue"&gt;out&lt;/span&gt; d))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Convert&lt;/span&gt;.ToDateTime(date);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;DateTime&lt;/span&gt;.Now;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=e9eb693b-4bfb-464c-bbac-11053bfe6e8e" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,e9eb693b-4bfb-464c-bbac-11053bfe6e8e.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=308bd3f2-4d3c-48b6-84f2-1dbe04982eed</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,308bd3f2-4d3c-48b6-84f2-1dbe04982eed.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,308bd3f2-4d3c-48b6-84f2-1dbe04982eed.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=308bd3f2-4d3c-48b6-84f2-1dbe04982eed</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have to get some landscape rock put out before my home owner's association has a
cow, but I decided to do some more work on my activity aggregator. Today, I decided
to integrate my blog feed into it, so when I post here, it will automatically update
this activity on my home page (and soon to be in my developer's area).
</p>
        <p>
Here's what the end result looks (for now).
</p>
        <p>
          <img src="http://www.dotnettechnologies.com/content/binary/DevArea.png" border="0" />
        </p>
        <p>
Doing it was fairly easy with the design I implemented in my last <a href="http://www.dotnettechnologies.com/PermaLink,guid,058b6bdb-5cc4-470d-a4ff-3f7452a4a7b1.aspx" target="_blank">post</a>.
My BlogFeed class inherits the BaseFeed class, which means I need to implement the
ParseFeed() method. Since the RSS feed from my blog is XML, I was easily able to adapt the
same code from my TwitterFeed class to work for this RSS feed (which should actually
work for any RSS feed I pass in).
</p>
        <p>
I also created another Extension method (for practice) to convert the RSS feed date
time to a C# DateTime object. I will post that code as "Tip of the Day" but I have
to give Dan Wahlin <a href="http://weblogs.asp.net/dwahlin/archive/2006/09/28/Creating-an-ASP.NET-RSS-Blog-Roller.aspx" target="_blank">credit</a> for
it, as I adapted some sample code he provided.
</p>
        <p>
Here's how the RSS feed (aka BlogFeed) uses LINQ to XML for creating my activity object.
</p>
        <div style="FONT-SIZE: 7pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <span style="COLOR: #2b91af">
            <div style="FONT-SIZE: 7pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
              <p style="MARGIN: 0px">
    <span style="COLOR: blue">internal</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">BlogFeed</span> : <span style="COLOR: #2b91af">BaseFeed</span></p>
              <p style="MARGIN: 0px">
    {
</p>
              <p style="MARGIN: 0px">
 
</p>
              <p style="MARGIN: 0px">
        <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">int</span> ParseFeed(<span style="COLOR: #2b91af">XDocument</span> doc)
</p>
              <p style="MARGIN: 0px">
        {
</p>
              <p style="MARGIN: 0px">
            <span style="COLOR: blue">try</span></p>
              <p style="MARGIN: 0px">
            {
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">ReturnCode</span> code
= <span style="COLOR: #2b91af">ReturnCode</span>.Success;
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: blue">if</span> (doc
!= <span style="COLOR: blue">null</span>)
</p>
              <p style="MARGIN: 0px">
                {
</p>
              <p style="MARGIN: 0px">
                    <span style="COLOR: blue">var</span> activityList
= <span style="COLOR: blue">from</span> e <span style="COLOR: blue">in</span> doc.Descendants(<span style="COLOR: #a31515">"item"</span>)
</p>
              <p style="MARGIN: 0px">
                   
                   <span style="COLOR: blue">select</span><span style="COLOR: blue">new</span> RubiconPortal.BusinessObjects.<span style="COLOR: #2b91af">Activity</span></p>
              <p style="MARGIN: 0px">
                   
                  
{
</p>
              <p style="MARGIN: 0px">
                   
                   
   ActivityTypeID = <span style="COLOR: #2b91af">ActivityTypes</span>.Blog.Code,
</p>
              <p style="MARGIN: 0px">
                   
                   
   ActivityDate = e.Element(<span style="COLOR: #a31515">"pubDate"</span>).Value.RSSDateTime().ToShortDateString()
+ <span style="COLOR: #a31515">" "</span> + e.Element(<span style="COLOR: #a31515">"pubDate"</span>).Value.RSSDateTime().ToShortDateString(),
</p>
              <p style="MARGIN: 0px">
                   
                   
   ActivitySummary = <span style="COLOR: #2b91af">HttpUtility</span>.HtmlDecode(e.Element(<span style="COLOR: #a31515">"title"</span>).Value),
</p>
              <p style="MARGIN: 0px">
                   
                   
   ActivityDetailsURL = e.Element(<span style="COLOR: #a31515">"link"</span>).Value
</p>
              <p style="MARGIN: 0px">
                   
                  
};
</p>
              <p style="MARGIN: 0px">
 
</p>
              <p style="MARGIN: 0px">
                    <span style="COLOR: blue">foreach</span> (<span style="COLOR: #2b91af">Activity</span> item <span style="COLOR: blue">in</span> activityList)
</p>
              <p style="MARGIN: 0px">
                   
{
</p>
              <p style="MARGIN: 0px">
                   
    <span style="COLOR: green">//We need to check and see if the item
exists</span></p>
              <p style="MARGIN: 0px">
                   
    <span style="COLOR: blue">if</span> (!<span style="COLOR: #2b91af">Activity</span>.CheckEntryExists(item.ActivityTypeID,
item.ActivityDetailsURL))
</p>
              <p style="MARGIN: 0px">
                   
    {
</p>
              <p style="MARGIN: 0px">
                   
        <span style="COLOR: blue">int</span> results
= item.Save();
</p>
              <p style="MARGIN: 0px">
                   
        <span style="COLOR: blue">if</span> (results
!= <span style="COLOR: #2b91af">ReturnCode</span>.Success.Code)
</p>
              <p style="MARGIN: 0px">
                   
            code = <span style="COLOR: #2b91af">ReturnCode</span>.Failure;
</p>
              <p style="MARGIN: 0px">
                   
    }
</p>
              <p style="MARGIN: 0px">
                   
    <span style="COLOR: blue">else</span></p>
              <p style="MARGIN: 0px">
                   
        <span style="COLOR: blue">return</span> code.Code;   <span style="COLOR: green">//we
can break once we hit one we've already logged (for performance reasons</span></p>
              <p style="MARGIN: 0px">
 
</p>
              <p style="MARGIN: 0px">
 
</p>
              <p style="MARGIN: 0px">
                   
}
</p>
              <p style="MARGIN: 0px">
 
</p>
              <p style="MARGIN: 0px">
 
</p>
              <p style="MARGIN: 0px">
                }
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span> code.Code;
</p>
              <p style="MARGIN: 0px">
            }
</p>
              <p style="MARGIN: 0px">
            <span style="COLOR: blue">catch</span> (<span style="COLOR: #2b91af">Exception</span> ex)
</p>
              <p style="MARGIN: 0px">
            {
</p>
              <p style="MARGIN: 0px">
                ErrorHandler(ex, <span style="COLOR: #a31515">"An
unexpected error occurred in TwitterFeed.ParseFeed() - "</span> + ex.Message);
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span><span style="COLOR: #2b91af">ReturnCode</span>.Failure.Code;
</p>
              <p style="MARGIN: 0px">
            }
</p>
              <p style="MARGIN: 0px">
        }
</p>
              <p style="MARGIN: 0px">
    }
</p>
              <p style="MARGIN: 0px">
 
</p>
            </div>
            <!--EndFragment-->
            <p style="MARGIN: 0px">
              <!--EndFragment-->
            </p>
          </span>
          <font face="Verdana" size="2">My next step will be to integrate some AJAX
so when the user hovers over the link, they can see things like the date, more of
the topic, etc. I also need to integrate my "Useful Links" dicussion as well.</font>
        </div>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=308bd3f2-4d3c-48b6-84f2-1dbe04982eed" />
      </body>
      <title>Logging Blog Activity to my Activity Aggregator</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,308bd3f2-4d3c-48b6-84f2-1dbe04982eed.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/15/LoggingBlogActivityToMyActivityAggregator.aspx</link>
      <pubDate>Sat, 15 Aug 2009 20:13:22 GMT</pubDate>
      <description>&lt;p&gt;
I have to get some landscape rock put out before my home owner's association has a
cow, but I decided to do some more work on my activity aggregator. Today, I decided
to integrate my blog feed into it, so when I post here, it will automatically update
this activity on my home page (and soon to be in my developer's area).
&lt;/p&gt;
&lt;p&gt;
Here's what the end result looks (for now).
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.dotnettechnologies.com/content/binary/DevArea.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Doing it was fairly easy with the design I implemented in my last &lt;a href="http://www.dotnettechnologies.com/PermaLink,guid,058b6bdb-5cc4-470d-a4ff-3f7452a4a7b1.aspx" target=_blank&gt;post&lt;/a&gt;.
My BlogFeed class inherits the BaseFeed class, which means I need to implement the
ParseFeed() method. Since the RSS feed from my blog is XML, I was easily able to adapt&amp;nbsp;the
same code from my TwitterFeed class to work for this RSS feed (which should actually
work for any RSS feed I pass in).
&lt;/p&gt;
&lt;p&gt;
I also created another Extension method (for practice) to convert the RSS feed date
time to a C# DateTime object. I will post that code as "Tip of the Day" but I have
to give Dan Wahlin &lt;a href="http://weblogs.asp.net/dwahlin/archive/2006/09/28/Creating-an-ASP.NET-RSS-Blog-Roller.aspx" target=_blank&gt;credit&lt;/a&gt; for
it, as I adapted some sample code he provided.
&lt;/p&gt;
&lt;p&gt;
Here's how the RSS feed (aka BlogFeed) uses LINQ to XML for creating my activity object.
&lt;/p&gt;
&lt;div style="FONT-SIZE: 7pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt; 
&lt;div style="FONT-SIZE: 7pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;internal&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;BlogFeed&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;BaseFeed&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; ParseFeed(&lt;span style="COLOR: #2b91af"&gt;XDocument&lt;/span&gt; doc)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;ReturnCode&lt;/span&gt; code
= &lt;span style="COLOR: #2b91af"&gt;ReturnCode&lt;/span&gt;.Success;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (doc
!= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; activityList
= &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; e &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; doc.Descendants(&lt;span style="COLOR: #a31515"&gt;"item"&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;select&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; RubiconPortal.BusinessObjects.&lt;span style="COLOR: #2b91af"&gt;Activity&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; ActivityTypeID = &lt;span style="COLOR: #2b91af"&gt;ActivityTypes&lt;/span&gt;.Blog.Code,
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; ActivityDate = e.Element(&lt;span style="COLOR: #a31515"&gt;"pubDate"&lt;/span&gt;).Value.RSSDateTime().ToShortDateString()
+ &lt;span style="COLOR: #a31515"&gt;" "&lt;/span&gt; + e.Element(&lt;span style="COLOR: #a31515"&gt;"pubDate"&lt;/span&gt;).Value.RSSDateTime().ToShortDateString(),
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; ActivitySummary = &lt;span style="COLOR: #2b91af"&gt;HttpUtility&lt;/span&gt;.HtmlDecode(e.Element(&lt;span style="COLOR: #a31515"&gt;"title"&lt;/span&gt;).Value),
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; ActivityDetailsURL = e.Element(&lt;span style="COLOR: #a31515"&gt;"link"&lt;/span&gt;).Value
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;
};
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;Activity&lt;/span&gt; item &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; activityList)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//We need to check and see if the item
exists&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!&lt;span style="COLOR: #2b91af"&gt;Activity&lt;/span&gt;.CheckEntryExists(item.ActivityTypeID,
item.ActivityDetailsURL))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; results
= item.Save();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (results
!= &lt;span style="COLOR: #2b91af"&gt;ReturnCode&lt;/span&gt;.Success.Code)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; code = &lt;span style="COLOR: #2b91af"&gt;ReturnCode&lt;/span&gt;.Failure;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; code.Code;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//we
can break once we hit one we've already logged (for performance reasons&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; code.Code;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;catch&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;Exception&lt;/span&gt; ex)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ErrorHandler(ex, &lt;span style="COLOR: #a31515"&gt;"An
unexpected error occurred in TwitterFeed.ParseFeed() - "&lt;/span&gt; + ex.Message);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ReturnCode&lt;/span&gt;.Failure.Code;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;!--EndFragment--&gt;
&lt;/span&gt;&lt;font face=Verdana size=2&gt;My next step will be to integrate some AJAX so when
the user hovers over the link, they can see things like the date, more of the topic,
etc. I also need to integrate my "Useful Links" dicussion as well.&lt;/font&gt;&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=308bd3f2-4d3c-48b6-84f2-1dbe04982eed" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,308bd3f2-4d3c-48b6-84f2-1dbe04982eed.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=058b6bdb-5cc4-470d-a4ff-3f7452a4a7b1</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,058b6bdb-5cc4-470d-a4ff-3f7452a4a7b1.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,058b6bdb-5cc4-470d-a4ff-3f7452a4a7b1.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=058b6bdb-5cc4-470d-a4ff-3f7452a4a7b1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Tonight was a very enjoyable night of coding. I created the first phase of my "activity
aggregator". I actually had a more clever name for it, but being tired, it slips my
mind right now.
</p>
        <p>
Currently, I post several places.. short updates for on Twitter. Longer discussions
end up on here, my blog. I have some other sources I plan on integrating over time,
such as links I found useful (similar to Digg, but also where I can place why I found
it useful). That means growth, and when it comes to design, it's best to design change
into it up front.
</p>
        <p>
The first thing I needed to do was create my table and business object to collect
these activities. In my table, I store ActivityDate, what type of activity it was
(foreign key to another table -- ActivityType), a brief summary of the activity text,
and finally the url someone interested could click on to get more information. The
internal members of my activity class look like this:
</p>
        <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   15</span> <span style="COLOR: blue">   
    #region</span> Private Members
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   16</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   17</span>         <span style="COLOR: blue">private</span><span style="COLOR: blue">int</span> activityID;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   18</span>         <span style="COLOR: blue">private</span><span style="COLOR: blue">int</span> activityTypeID;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   19</span>         <span style="COLOR: blue">private</span><span style="COLOR: blue">string</span> activityDate;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   20</span>         <span style="COLOR: blue">private</span><span style="COLOR: blue">string</span> activitySummary;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   21</span>         <span style="COLOR: blue">private</span><span style="COLOR: blue">string</span> activityDetailsURL;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   22</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #2b91af">   23</span> <span style="COLOR: blue">   
    #endregion</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">Each private member
has a publically exposed property.</font>
            </span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">Most of my activities
will have XML feeds, such as the RSS feed of my blog, and the Twitter API. Therefore,
I enforce a similar implementation by creating an abstract base class, called BaseFeed,
which looks like this:</font>
            </span>
          </p>
          <span style="COLOR: blue">
            <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    1</span> <span style="COLOR: blue">using</span> System.Xml.Linq;
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    2</span> <span style="COLOR: blue">using</span> RubiconPortal.Common;
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    3</span> 
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    4</span> <span style="COLOR: blue">namespace</span> RubiconPortal.BusinessObjects
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    5</span> {
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    6</span>     <span style="COLOR: blue">internal</span><span style="COLOR: blue">abstract</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">BaseFeed</span> :
BaseClass
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    7</span>    
{
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    8</span> 
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    9</span>    
    <span style="COLOR: blue">public</span><span style="COLOR: blue">abstract</span><span style="COLOR: blue">int</span> ParseFeed(XDocument
doc);
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   10</span> 
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   11</span>     }
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   12</span> }
</p>
            </div>
            <!--EndFragment-->
          </span>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">So now I have a "contract"
that I need to use to have a similar method for any activity I want to log. I could
have used an interface for this, since there's no true implentation here, and I may
refactor it later to do so, but I do have some ideas where I may want to provide some
implementation, so that's why I chose an abstract class.</font>
            </span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">So the first item I
wanted to do was implement capturing my <a href="http://twitter.com/RubiconComp" target="_blank">Twitter
posts</a> in this activity, since I currently don't have a way to capture and post
them on my site. I will add the rest of the activities later. In a previous post,
I described how I took the Yedda Twitter API and modified it to return XDocuments,
and here's another chance to take advantage of that change with LINQ.</font>
            </span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">When I post to my Twitter
feed, I want to make sure my home page automatically reflects this activity. So I
implement a TwitterFeed object, which implements the BaseFeed method ParseFeed. Using
LINQ to XML, I pull out the pieces of the response I want, and populate the public
properties of my Activities class, then save my activity. Here's what my TwitterFeed
class looks like:</font>
            </span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <span style="COLOR: blue">
            <font face="Verdana" color="#000000">
              <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">    1</span> <span style="COLOR: blue">using</span> System;
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">    2</span> <span style="COLOR: blue">using</span> System.Linq;
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">    3</span> <span style="COLOR: blue">using</span> System.Web;
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">    4</span> <span style="COLOR: blue">using</span> System.Xml.Linq;
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">    5</span> <span style="COLOR: blue">using</span> Rubicon.Common;
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">    6</span> <span style="COLOR: blue">using</span> RubiconPortal.Common;
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">    7</span> 
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">    8</span> <span style="COLOR: blue">namespace</span> RubiconPortal.BusinessObjects
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">    9</span> {
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   10</span>     <span style="COLOR: blue">internal</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">TwitterFeed</span> :
BaseFeed
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   11</span>     {
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   12</span>         <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">int</span> ParseFeed(XDocument
doc)
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   13</span>        
{
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   14</span>        
    <span style="COLOR: blue">try</span></p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   15</span>        
    {
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   16</span>        
        <span style="COLOR: blue">if</span> (doc != <span style="COLOR: blue">null</span>)
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   17</span>        
        {
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   18</span>        
            <span style="COLOR: blue">var</span> activityList
= <span style="COLOR: blue">from</span> e <span style="COLOR: blue">in</span> doc.Descendants(<span style="COLOR: #a31515">"status"</span>)
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   19</span>        
                   
           <span style="COLOR: blue">select</span><span style="COLOR: blue">new</span> RubiconPortal.BusinessObjects.Activity
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   20</span>        
                   
           {
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   21</span>        
                   
               ActivityTypeID
= ActivityTypes.Twitter.Code,
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   22</span>        
                   
               ActivityDate
= (e.Element(<span style="COLOR: #a31515">"created_at"</span>).Value.ParseDateTime()).ToShortDateString()
+ <span style="COLOR: #a31515">" "</span> + (e.Element(<span style="COLOR: #a31515">"created_at"</span>).Value.ParseDateTime()).ToShortTimeString(),
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   23</span>        
                   
               ActivitySummary
= HttpUtility.HtmlDecode(e.Element(<span style="COLOR: #a31515">"text"</span>).Value),
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   24</span>        
                   
               ActivityDetailsURL
= <span style="COLOR: #a31515">"http://twitter.com/"</span> + e.Element(<span style="COLOR: #a31515">"user"</span>).Element(<span style="COLOR: #a31515">"screen_name"</span>).Value
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   25</span>        
                   
           };
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   26</span> 
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   27</span>        
            <span style="COLOR: blue">foreach</span> (RubiconPortal.BusinessObjects.Activity
item <span style="COLOR: blue">in</span> activityList)
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   28</span>        
            {
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   29</span>        
                item.Save();
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   30</span>        
            }
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   31</span>        
        }
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   32</span> 
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   33</span>        
        <span style="COLOR: blue">return</span> ReturnCode.Success.Code;
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   34</span>        
    }
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   35</span>        
    <span style="COLOR: blue">catch</span> (<span style="COLOR: #2b91af">Exception</span> ex)
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   36</span>        
    {
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   37</span>        
        ErrorHandler(ex, <span style="COLOR: #a31515">"An
unexpected error occurred in TwitterFeed.ParseFeed() - "</span> + ex.Message);
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   38</span>        
        <span style="COLOR: blue">return</span> ReturnCode.Failure.Code;
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   39</span>        
    } 
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   40</span>        
}
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   41</span> 
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   42</span>     }
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   43</span> 
</p>
                <p style="MARGIN: 0px">
                  <span style="COLOR: #2b91af">   44</span> }
</p>
              </div>
              <!--EndFragment-->
            </font>
          </span>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">Within the ParseFeed
method I am using LINQ to XML to populate my business object calling the save()
method to write it to the database. As you can see, using LINQ to XML can be
a lot simpler than using XML/XPath. Once in the database, I can query it in my user
control, and display it on my home page <a href="http://www.rubiconcomputing.com/" target="_blank">here</a>.</font>
            </span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">Now, when I make my
Twitter post, all I need to do is take the XDocument the Twitter API returns, and
pass it into the ParseFeed method, which looks like this...</font>
            </span>
          </p>
          <span style="COLOR: blue">
            <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   35</span>        
            <span style="COLOR: green">//Post
my tweet to Twitter</span></p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   36</span>        
            TwitterAPI twit = <span style="COLOR: blue">new</span> TwitterAPI();
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   37</span>        
            XDocument doc = twit.UpdateAsXML(Settings.TwitterUserName(),
Settings.TwitterPassword(), txtPost.Text);
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   38</span> 
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   39</span>        
            <span style="COLOR: green">//Save
it to the activity table for displaying the activity</span></p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   40</span>        
            TwitterFeed feed = <span style="COLOR: blue">new</span> TwitterFeed();
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   41</span>        
            feed.ParseFeed(doc);
</p>
            </div>
            <!--EndFragment-->
          </span>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">Simple and neat! Now
when I implement it for my blog, it will be just as quick and easy!</font>
            </span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">Props go out to this <a href="http://blogs.msdn.com/bursteg/archive/2009/05/29/twitter-api-from-c-getting-a-user-s-time-line.aspx" target="_blank">post </a>I
snagged an extension method for formatting the Twitter posting date to something a
human can use (and my C# class can use to manipulate and save!)</font>
            </span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">
              <font face="Verdana" color="#000000">
              </font>
            </span> 
</p>
        </div>
        <!--EndFragment-->
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=058b6bdb-5cc4-470d-a4ff-3f7452a4a7b1" />
      </body>
      <title>Creating my activity aggregator</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,058b6bdb-5cc4-470d-a4ff-3f7452a4a7b1.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/14/CreatingMyActivityAggregator.aspx</link>
      <pubDate>Fri, 14 Aug 2009 06:40:31 GMT</pubDate>
      <description>&lt;p&gt;
Tonight was a very enjoyable night of coding. I created the first phase of my "activity
aggregator". I actually had a more clever name for it, but being tired, it slips my
mind right now.
&lt;/p&gt;
&lt;p&gt;
Currently, I post several places.. short updates for on Twitter. Longer discussions
end up on here, my blog. I have some other sources I plan on integrating over time,
such as links I found useful (similar to Digg, but also where I can place why I found
it useful). That means growth, and when it comes to design, it's best to design change
into it up front.
&lt;/p&gt;
&lt;p&gt;
The first thing I needed to do was create my table and business object to collect
these activities. In my table, I store ActivityDate, what type of activity it was
(foreign key to another table -- ActivityType), a brief summary of the activity text,
and finally the url someone interested could click on to get more information. The
internal members of my activity class look like this:
&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; #region&lt;/span&gt; Private Members
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; activityID;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; activityTypeID;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; activityDate;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; activitySummary;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; activityDetailsURL;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;Each private member has
a publically exposed property.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;Most of my activities will
have XML feeds, such as the RSS feed of my blog, and the Twitter API. Therefore, I
enforce a similar implementation by creating an abstract base class, called BaseFeed,
which looks like this:&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="COLOR: blue"&gt; 
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Xml.Linq;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; RubiconPortal.Common;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; RubiconPortal.BusinessObjects
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;internal&lt;/span&gt; &lt;span style="COLOR: blue"&gt;abstract&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;BaseFeed&lt;/span&gt; :
BaseClass
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;abstract&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; ParseFeed(XDocument
doc);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;}
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/span&gt; 
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;So now I have a "contract"
that I need to use to have a similar method for any activity I want to log. I could
have used an interface for this, since there's no true implentation here, and I may
refactor it later to do so, but I do have some ideas where I may want to provide some
implementation, so that's why I chose an abstract class.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;So the first item I wanted
to do was implement capturing my &lt;a href="http://twitter.com/RubiconComp" target=_blank&gt;Twitter
posts&lt;/a&gt; in this activity, since I currently don't have a way to capture and post
them on my site. I will add the rest of the activities later. In a previous post,
I described how I took the Yedda Twitter API and modified it to return XDocuments,
and here's another chance to take advantage of that change with LINQ.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;When I post to my Twitter
feed, I want to make sure my home page automatically reflects this activity. So I
implement a TwitterFeed object, which implements the BaseFeed method ParseFeed. Using
LINQ to XML, I pull out the pieces of the response I want, and populate the public
properties of my Activities class, then save my activity. Here's what my TwitterFeed
class looks like:&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt; 
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Linq;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Web;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Xml.Linq;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; Rubicon.Common;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; RubiconPortal.Common;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; RubiconPortal.BusinessObjects
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;internal&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TwitterFeed&lt;/span&gt; :
BaseFeed
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; ParseFeed(XDocument
doc)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (doc != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; activityList
= &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; e &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; doc.Descendants(&lt;span style="COLOR: #a31515"&gt;"status"&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;select&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; RubiconPortal.BusinessObjects.Activity
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; ActivityTypeID
= ActivityTypes.Twitter.Code,
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; ActivityDate
= (e.Element(&lt;span style="COLOR: #a31515"&gt;"created_at"&lt;/span&gt;).Value.ParseDateTime()).ToShortDateString()
+ &lt;span style="COLOR: #a31515"&gt;" "&lt;/span&gt; + (e.Element(&lt;span style="COLOR: #a31515"&gt;"created_at"&lt;/span&gt;).Value.ParseDateTime()).ToShortTimeString(),
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; ActivitySummary
= HttpUtility.HtmlDecode(e.Element(&lt;span style="COLOR: #a31515"&gt;"text"&lt;/span&gt;).Value),
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; ActivityDetailsURL
= &lt;span style="COLOR: #a31515"&gt;"http://twitter.com/"&lt;/span&gt; + e.Element(&lt;span style="COLOR: #a31515"&gt;"user"&lt;/span&gt;).Element(&lt;span style="COLOR: #a31515"&gt;"screen_name"&lt;/span&gt;).Value
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;25&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; };
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;26&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;27&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (RubiconPortal.BusinessObjects.Activity
item &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; activityList)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;28&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;29&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; item.Save();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;31&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;32&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;33&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; ReturnCode.Success.Code;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;34&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;35&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;catch&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;Exception&lt;/span&gt; ex)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;36&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;37&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ErrorHandler(ex, &lt;span style="COLOR: #a31515"&gt;"An
unexpected error occurred in TwitterFeed.ParseFeed() - "&lt;/span&gt; + ex.Message);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;38&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; ReturnCode.Failure.Code;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;39&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;40&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;41&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;42&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;43&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;44&lt;/span&gt;&amp;nbsp;}
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/font&gt;&lt;/span&gt; 
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;Within&amp;nbsp;the ParseFeed
method I am&amp;nbsp;using LINQ to XML to populate my business object calling the save()
method&amp;nbsp;to write it to the database. As you can see, using LINQ to XML can be
a lot simpler than using XML/XPath. Once in the database, I can query it in my user
control, and display it on my home page &lt;a href="http://www.rubiconcomputing.com/" target=_blank&gt;here&lt;/a&gt;.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;Now, when I make my Twitter
post, all I need to do is take the XDocument the Twitter API returns, and pass it
into the ParseFeed method, which looks like this...&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="COLOR: blue"&gt; 
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;35&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//Post
my tweet to Twitter&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;36&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TwitterAPI twit = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; TwitterAPI();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;37&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; XDocument doc = twit.UpdateAsXML(Settings.TwitterUserName(),
Settings.TwitterPassword(), txtPost.Text);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;38&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;39&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//Save
it to the activity table for displaying the activity&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;40&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; TwitterFeed feed = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; TwitterFeed();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;41&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; feed.ParseFeed(doc);
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/span&gt; 
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;Simple and neat! Now when
I implement it for my blog, it will be just as quick and easy!&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;Props go out to this &lt;a href="http://blogs.msdn.com/bursteg/archive/2009/05/29/twitter-api-from-c-getting-a-user-s-time-line.aspx" target=_blank&gt;post &lt;/a&gt;I
snagged an extension method for formatting the Twitter posting date to something a
human can use (and my C# class can use to manipulate and save!)&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&lt;font face=Verdana color=#000000&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=058b6bdb-5cc4-470d-a4ff-3f7452a4a7b1" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,058b6bdb-5cc4-470d-a4ff-3f7452a4a7b1.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=c0cbc280-544f-45b1-943c-3715fb32920c</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,c0cbc280-544f-45b1-943c-3715fb32920c.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,c0cbc280-544f-45b1-943c-3715fb32920c.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=c0cbc280-544f-45b1-943c-3715fb32920c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Tonight was a short night of development, as my folks were in town as my dad needed
to go to the doctor. I did get some database work done, and my business objects done.
I use a hybrid of Rockford Lhotka's CSLA. I don't need all the functionality (such
as layers of undo) so I trimmed them back the amount of functionality I needed and
created CodeSmith templates to generate my classes. Let me just say I can code really
fast now. :) If you haven't taken a look at Lhotka's Business Objects book, I highly
recommend taking a look at them. I began using his concepts in VB, and they have proven
very reliable and scalable.
</p>
        <p>
QDJ: Do you use ORM's, and if so, what flavor do you like?
</p>
        <p>
I have to admit, I am not the biggest fan of the various ORMs I have tried. They do
serve a purpose though, but I have found most inflexible. I am currently using nHibernate,
and while they make themselves readily available to code generation, so far, it seems
like a lot of code. See my previous comments about another ORM I tried. My brother
uses it, and seems to be happy with it. I just thought the learning curve was very
steep, and the documentation was very lacking. I took a beating for that opinion.
:)
</p>
        <p>
So tonight, I want to post a couple of links I used today. Soon there will be a control
for this on the <a href="http://www.rubiconcomputing.com/" target="_blank">Rubicon
Computing</a> site, but until then, I will post them here.
</p>
        <p>
First, I referred to this before, but here's a site with a lot of good links to various
"cheat sheets". Some are really good and useful. You can find those <a href="http://john-sheehan.com/blog/net-cheat-sheets/" target="_blank">here</a>.
</p>
        <p>
Next, I found some neat add-ins for Visual Studio 2008. The first is the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/bea9ed59-8857-4032-9666-9af1c1a33969" target="_blank">Source
Code Power Toy</a>. It outlines your code in a treeview, which makes navigating your
code, especially in complex classes, very easy. Best of all, it's free! It's available
for VS2005 as well.
</p>
        <p>
I also installed the <a href="http://code.msdn.microsoft.com/PowerCommands" target="_blank">Power
Commands</a> for the VS 2008 IDE. It has some useful right-click functionality, such
as opening a command prompt, and opening the containing folder, and that's just a
small glimpse of what it can do. It seems to be well documented, and I look forward
to exploring all it's functionality. And best thing, this one is free too.
</p>
        <p>
I'll probably post some useful CodeSmith templates I created. I love <a href="http://www.codesmithtools.com/" target="_blank">CodeSmith</a>,
but sometimes it's tough to find out exactly how to do things, so I will spare the
world the trial-and-error where I can. In the current project I am working on, our
team saved 1,100+ hours, and over $50,000 dollars last month alone by generating nHibernate
code from the templates we created. Yeah, I earned my rate last month for sure. :)
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=c0cbc280-544f-45b1-943c-3715fb32920c" />
      </body>
      <title>Some neat things I found today...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,c0cbc280-544f-45b1-943c-3715fb32920c.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/12/SomeNeatThingsIFoundToday.aspx</link>
      <pubDate>Wed, 12 Aug 2009 05:31:11 GMT</pubDate>
      <description>&lt;p&gt;
Tonight was a short night of development, as my folks were in town as my dad needed
to go to the doctor. I did get some database work done, and my business objects done.
I use a hybrid of Rockford Lhotka's CSLA. I don't need all the functionality (such
as layers of undo) so I trimmed them back the amount of functionality I needed and
created CodeSmith templates to generate my classes. Let me just say I can code really
fast now. :) If you haven't taken a look at Lhotka's Business Objects book, I highly
recommend taking a look at them. I began using his concepts in VB, and they have proven
very reliable and scalable.
&lt;/p&gt;
&lt;p&gt;
QDJ: Do you use ORM's, and if so, what flavor do you like?
&lt;/p&gt;
&lt;p&gt;
I have to admit, I am not the biggest fan of the various ORMs I have tried. They do
serve a purpose though, but I have found most inflexible. I am currently using nHibernate,
and while they make themselves readily available to code generation, so far, it seems
like a lot of code. See my previous comments about another ORM I tried. My brother
uses it, and seems to be happy with it. I just thought the learning curve was very
steep, and the documentation was very lacking. I took a beating for that opinion.
:)
&lt;/p&gt;
&lt;p&gt;
So tonight, I want to post a couple of links I used today. Soon there will be a control
for this on the&amp;nbsp;&lt;a href="http://www.rubiconcomputing.com/" target=_blank&gt;Rubicon
Computing&lt;/a&gt;&amp;nbsp;site, but until then, I will post them here.
&lt;/p&gt;
&lt;p&gt;
First, I referred to this before, but here's a site with a lot of good links to various
"cheat sheets". Some are really good and useful. You can find those &lt;a href="http://john-sheehan.com/blog/net-cheat-sheets/" target=_blank&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Next, I found some neat add-ins for Visual Studio 2008. The first is the &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/bea9ed59-8857-4032-9666-9af1c1a33969" target=_blank&gt;Source
Code Power Toy&lt;/a&gt;. It outlines your code in a treeview, which makes navigating your
code, especially in complex classes, very easy. Best of all, it's free! It's available
for VS2005 as well.
&lt;/p&gt;
&lt;p&gt;
I also installed the &lt;a href="http://code.msdn.microsoft.com/PowerCommands" target=_blank&gt;Power
Commands&lt;/a&gt; for the VS 2008 IDE. It has some useful right-click functionality, such
as opening a command prompt, and opening the containing folder, and that's just a
small glimpse of what it can do.&amp;nbsp;It seems to be well documented, and I look forward
to exploring all it's functionality. And best thing, this one is free too.
&lt;/p&gt;
&lt;p&gt;
I'll probably post some useful CodeSmith templates I created. I love &lt;a href="http://www.codesmithtools.com/" target=_blank&gt;CodeSmith&lt;/a&gt;,
but sometimes it's tough to find out exactly how to do things, so I will spare the
world the trial-and-error where I can. In the current project I am working on, our
team saved 1,100+ hours, and over $50,000 dollars last month alone by generating nHibernate
code from the templates we created. Yeah, I earned my rate last month for sure. :)
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=c0cbc280-544f-45b1-943c-3715fb32920c" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,c0cbc280-544f-45b1-943c-3715fb32920c.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=de920c29-c8b9-40e4-bb75-cb7daa2af822</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,de920c29-c8b9-40e4-bb75-cb7daa2af822.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,de920c29-c8b9-40e4-bb75-cb7daa2af822.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=de920c29-c8b9-40e4-bb75-cb7daa2af822</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Tonight I didn't get as much time to work on the site as I would have liked, so I
focused on getting the admin pages up on the production server so I could do some
"behind-the-scenes" work remotely. This required some security, which I started last
night, but the data migration for that was a bit more daunting, so I needed to finish
it tonight. While the authentication providers and controls do handle a LOT, it has
an interesting learning-curve, and deployment can be a challenge as well. All-in-all,
it sure beats writing all that code by myself. 
</p>
        <p>
I tried to use a lot of caching and cached settings to help improve the performance
on certain pages, especially my client list. On my admin pages, I made sure to create
a means to reset that cache without having to do a complete server reset. Actually,
the same approach I took would work well for high availability sites, as the method
I used to complete this would not require a server reset to re-load systems. When
I was int he banking industry, high-availability was a huge issue, and simple config
changes meant waiting for a scheduled system outage or worse, an emergency outage.
When I redesigned that site, that was one of the top priorities I had.
</p>
        <p>
It occurred to me how much time it takes to set up the infrastructure of a site: master
pages, common libraries, configuration files, CSS, etc. Once those are done, if done
properly, the rest of the site should go fast. One thing I have found to speed that
up was the use of Visual Studio Project Templates. Combined with code generation like
CodeSmith, you can really generate web sites extremely fast, and get on to coding
the "fun" items. I will write about both of those in the future (CodeSmith and Project
Templates) once the site is stabilized.
</p>
        <p>
Tomorrow night may not have a lot of development, as my parents will be in town. Later
this week, I will be coding my next control: the activity feed. When posts and feeds
are made or read, this control will snag it, and place a brief "teaser" on the home
page.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=de920c29-c8b9-40e4-bb75-cb7daa2af822" />
      </body>
      <title>As we march across the Rubicon, we have Admin pages!</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,de920c29-c8b9-40e4-bb75-cb7daa2af822.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/11/AsWeMarchAcrossTheRubiconWeHaveAdminPages.aspx</link>
      <pubDate>Tue, 11 Aug 2009 05:05:59 GMT</pubDate>
      <description>&lt;p&gt;
Tonight I didn't get as much time to work on the site as I would have liked, so I
focused on getting the admin pages up on the production server so I could do some
"behind-the-scenes" work remotely. This required some security, which I started last
night, but the data migration for that was a bit more daunting, so I needed to finish
it tonight. While the authentication providers and controls do handle a LOT, it has
an interesting learning-curve, and deployment can be a challenge as well. All-in-all,
it sure beats writing all that code by myself. 
&lt;/p&gt;
&lt;p&gt;
I tried to use a lot of caching and cached settings to help improve the performance
on certain pages, especially my client list. On my admin pages, I made sure to create
a means to reset that cache without having to do a complete server reset. Actually,
the same approach I took would work well for high availability sites, as the method
I used to complete this would not require a server reset to re-load systems. When
I was int he banking industry, high-availability was a huge issue, and simple config
changes meant waiting for a scheduled system outage or worse, an emergency outage.
When I redesigned that site, that was one of the top priorities I had.
&lt;/p&gt;
&lt;p&gt;
It occurred to me how much time it takes to set up the infrastructure of a site: master
pages, common libraries, configuration files, CSS, etc. Once those are done, if done
properly, the rest of the site should go fast. One thing I have found to speed that
up was the use of Visual Studio Project Templates. Combined with code generation like
CodeSmith, you can really generate web sites extremely fast, and get on to coding
the "fun" items. I will write about both of those in the future (CodeSmith and Project
Templates) once the site is stabilized.
&lt;/p&gt;
&lt;p&gt;
Tomorrow night may not have a lot of development, as my parents will be in town. Later
this week, I will be coding my next control: the activity feed. When posts and feeds
are made or read, this control will snag it, and place a brief "teaser" on the home
page.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=de920c29-c8b9-40e4-bb75-cb7daa2af822" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,de920c29-c8b9-40e4-bb75-cb7daa2af822.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=031d112b-9b09-493a-bf48-8f168ce1018c</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,031d112b-9b09-493a-bf48-8f168ce1018c.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,031d112b-9b09-493a-bf48-8f168ce1018c.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=031d112b-9b09-493a-bf48-8f168ce1018c</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I finally managed to get my client list online today. From a technological standpoint,
it was pretty straight forward. I store the information in the database, and use my
CodeSmith templates to create a class for extracting the data, and then use a Repeater
to present the information in a table format. I still need to make some changes to
it, but all in all, it works well. Since the data won't be changing often, I did cache
the data to make it come back faster. 
</p>
        <p>
I started working on security for my Administration pages. I need to get that set
up before I can activate the admin pages, but I have run into some issues getting
it all configured. I ran into this once before with the ASP.Net forms authentication
security provider, but this time is a little different, as I only want to secure one
folder. Certainly not too difficult to do, but not as easy as I would have hoped either.
</p>
        <p>
Once I get the security and login page worked out, I'll begin working on my "links"
page. The idea here is that when I blog, or post to twitter, or a few other ideas
I have, it will update the dark blue control on the home page with a summary and hopefully
someone will click through to get the rest of the details. This should be fairly straightforward
to do. Since most of the services respond in XML, I'll just use a factory method to
instantiate the proper object, which will know exactly what information I want to
extract from the XML feed. As I add more items I want to track, I will simply have
to implement the same interface and it will plug right in to my "updater". For the
items which return XML (e.g. RSS or Twitter), I will use LINQ for XML to grab just
want I want and populate the data right into my classes.
</p>
        <p>
Which brings up a point...
</p>
        <p>
I could probably do this almost as easy with XPath. When does it make sense to move
to the more "sexier" technology as opposed something proven and works well? For example,
a lot of times, when a new technology is rolled out, it tends to be buggy and some
of them historically have not performed well (e.g. early XML for those who have been
around a while). All things equal, when does it make sense? Just a rhetorical question,
but one I got hit with recently.
</p>
        <p>
I was in a technical interview for a job I wasn't planning on taking (drive was too
far -- the company I was representing knew this as well, they just wanted me to be
on their radar for the future). I was asked about a particular implementation of the
new List object. Honestly, I know how to use the List object, and he was asking about
some of the internals I really hadn't needed to know. 
</p>
        <p>
If I was having performance issues, I would want to know, and then I would look into
it further. In this case, I was able to provide at least 4 other reasonable implementations
based on the criteria I was given, yet, I still couldn't get the "sexy" answer he
was looking for. At what point does it really matter? For my part, I didn't like NOT
knowing, and I did look it up when I left, but in the big picture, when does it become
relevant? In my book, the practical solution to a relevant problem always supercedes
technical "sexiness". 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=031d112b-9b09-493a-bf48-8f168ce1018c" />
      </body>
      <title>More progress on my site -- Client List!</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,031d112b-9b09-493a-bf48-8f168ce1018c.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/10/MoreProgressOnMySiteClientList.aspx</link>
      <pubDate>Mon, 10 Aug 2009 04:58:40 GMT</pubDate>
      <description>&lt;p&gt;
I finally managed to get my client list online today. From a technological standpoint,
it was pretty straight forward. I store the information in the database, and use my
CodeSmith templates to create a class for extracting the data, and then use a Repeater
to present the information in a table format. I still need to make some changes to
it, but all in all, it works well. Since the data won't be changing often, I did cache
the data to make it come back faster. 
&lt;/p&gt;
&lt;p&gt;
I started working on security for my Administration pages. I need to get that set
up before I can activate the admin pages, but I have run into some issues getting
it all configured. I ran into this once before with the ASP.Net forms authentication
security provider, but this time is a little different, as I only want to secure one
folder. Certainly not too difficult to do, but not as easy as I would have hoped either.
&lt;/p&gt;
&lt;p&gt;
Once I get the security and login page worked out, I'll begin working on my "links"
page. The idea here is that when I blog, or post to twitter, or a few other ideas
I have, it will update the dark blue control on the home page with a summary and hopefully
someone will click through to get the rest of the details. This should be fairly straightforward
to do. Since most of the services respond in XML, I'll just use a factory method to
instantiate the proper object, which will know exactly what information I want to
extract from the XML feed. As I add more items I want to track, I will simply have
to implement the same interface and it will plug right in to my "updater". For the
items which return XML (e.g. RSS or Twitter), I will use LINQ for XML to grab just
want I want and populate the data right into my classes.
&lt;/p&gt;
&lt;p&gt;
Which brings up a point...
&lt;/p&gt;
&lt;p&gt;
I could probably do this almost as easy with XPath. When does it make sense to move
to the more "sexier" technology as opposed something proven and works well? For example,
a lot of times, when a new technology is rolled out, it tends to be buggy and some
of them historically have not performed well (e.g. early XML for those who have been
around a while). All things equal, when does it make sense? Just a rhetorical question,
but one I got hit with recently.
&lt;/p&gt;
&lt;p&gt;
I was in a technical interview for a job I wasn't planning on taking (drive was too
far -- the company I was representing knew this as well, they just wanted me to be
on their radar for the future). I was asked about a particular implementation of the
new List object. Honestly, I know how to use the List object, and he was asking about
some of the internals I really hadn't needed to know. 
&lt;/p&gt;
&lt;p&gt;
If I was having performance issues, I would want to know, and then I would look into
it further. In this case, I was able to provide at least 4 other reasonable implementations
based on the criteria I was given, yet, I still couldn't get the "sexy" answer he
was looking for. At what point does it really matter? For my part, I didn't like NOT
knowing, and I did look it up when I left, but in the big picture, when does it become
relevant? In my book, the practical solution to a relevant problem always supercedes
technical "sexiness". 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=031d112b-9b09-493a-bf48-8f168ce1018c" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,031d112b-9b09-493a-bf48-8f168ce1018c.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=71a6f346-d8d1-4b6d-ba7e-731960fe2e46</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,71a6f346-d8d1-4b6d-ba7e-731960fe2e46.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,71a6f346-d8d1-4b6d-ba7e-731960fe2e46.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=71a6f346-d8d1-4b6d-ba7e-731960fe2e46</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I finally got around to updating my resume, and I pasted it temporarily on my
home page at <a href="http://www.rubiconcomputing.com/" target="_blank">Rubicon Computing
Solutions</a>. That's my company, and it's been a great run of 13 years.  I say
temporarily simply because it will better positioned later, but I realized I really
should have it on there so it gets picked up by some search engines, recruiters and
in general people looking for .Net development in the Phoenix area.
</p>
        <p>
I am in some talks with some other very senior developers I have had the pleasure
of working with over the past couple of years about banding our talent together. I've
tried that before, but these developers have been on their own for a long time, so
we have a very similar background and strong work ethic to build upon. I have always
struggled in the past with partnering up with other developers, as I have very high
expectations of any project I work on. In fact, this is why I have had trouble hiring
help, as my standards of quality aren't met by most developers without substantial
coaching. These developers already have that skill, along with maturity and experience,
which makes this a very exciting opportunity. Interesting how this economy drags some
people down, yet others, like myself see it as an opportunity.
</p>
        <p>
One of the limiting factors I have always had was that I was limited on the size of
projects I could take alone. This changes that dynamic dramatically.
</p>
        <p>
So if you're looking for some quality application development (web or windows), I
specialize in quality service and coding in a Microsoft environment. I can work alone,
with a team, or build and lead teams. You can find more details about those skills <a href="http://www.rubiconcomputing.com/resume/resume.html" target="_blank">here</a>.
Thanks!
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=71a6f346-d8d1-4b6d-ba7e-731960fe2e46" />
      </body>
      <title>A not-so-shameless plug</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,71a6f346-d8d1-4b6d-ba7e-731960fe2e46.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/07/ANotsoshamelessPlug.aspx</link>
      <pubDate>Fri, 07 Aug 2009 05:02:11 GMT</pubDate>
      <description>&lt;p&gt;
I finally got around&amp;nbsp;to updating my resume, and I pasted it temporarily on my
home page at &lt;a href="http://www.rubiconcomputing.com/" target=_blank&gt;Rubicon Computing
Solutions&lt;/a&gt;. That's my company, and it's been a great run of 13 years.&amp;nbsp; I say
temporarily simply because it will better positioned later, but I realized I really
should have it on there so it gets picked up by some search engines, recruiters and
in general people looking for .Net development in the Phoenix area.
&lt;/p&gt;
&lt;p&gt;
I am in some talks with some other very senior developers I have had the pleasure
of working with over the past couple of years about banding our talent together. I've
tried that before, but these developers have been on their own for a long time, so
we have a very similar background and strong work ethic to build upon. I have always
struggled in the past with partnering up with other developers, as I have very high
expectations of any project I work on. In fact, this is why I have had trouble hiring
help, as my standards of quality aren't met by most developers without substantial
coaching. These developers already have that skill, along with maturity and experience,
which makes this a very exciting opportunity. Interesting how this economy drags some
people down, yet others, like myself see it as an opportunity.
&lt;/p&gt;
&lt;p&gt;
One of the limiting factors I have always had was that I was limited on the size of
projects I could take alone. This changes that dynamic dramatically.
&lt;/p&gt;
&lt;p&gt;
So if you're looking for some quality application development (web or windows), I
specialize in quality service and coding in a Microsoft environment. I can work alone,
with a team, or build and lead teams. You can find more details about those skills &lt;a href="http://www.rubiconcomputing.com/resume/resume.html" target=_blank&gt;here&lt;/a&gt;.
Thanks!
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=71a6f346-d8d1-4b6d-ba7e-731960fe2e46" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,71a6f346-d8d1-4b6d-ba7e-731960fe2e46.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Web Services</category>
      <category>Windows</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=93b87350-9e5d-45df-b06e-3ac75edeb809</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,93b87350-9e5d-45df-b06e-3ac75edeb809.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,93b87350-9e5d-45df-b06e-3ac75edeb809.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=93b87350-9e5d-45df-b06e-3ac75edeb809</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Tonight's coding session went by WAY too fast. I integrated <a href="http://devblog.yedda.com/index.php/twitter-c-library/" target="_blank">Yedda's
Twitter API</a> into my admin pages so I could post directly without having to use
another client or browse to Twitter to do it. The next step will be to read my blog
feed and Tweet automatically about the topic. That's for another night though, as
tomorrow night is poker night, and yes, I still play. :)
</p>
        <p>
One change I made to the Yedda library (ok, two.. I ran into an issue with an error
code 471 being returned, but a quick Google search fixed that (sometimes I how effeciently
we coded before Google). I wanted to use LINQ to XML to parse out my response code.
So Instead of returning the XML Document, I convert it to an XDocument using the Parse
method, and return that, like this:
</p>
        <font color="#0000ff" size="2">
          <font color="#0000ff" size="2">
            <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
              <p style="MARGIN: 0px">
                <span style="COLOR: blue">         public</span>
                <span style="COLOR: #2b91af">XDocument</span> UpdateAsXML(<span style="COLOR: blue">string</span> userName, <span style="COLOR: blue">string</span> password, <span style="COLOR: blue">string</span> text)
</p>
              <p style="MARGIN: 0px">
        {
</p>
              <p style="MARGIN: 0px">
            <span style="COLOR: blue">string</span> output
= Update(userName, password, text, <span style="COLOR: #2b91af">OutputFormatType</span>.XML);
</p>
              <p style="MARGIN: 0px">
            <span style="COLOR: blue">if</span> (!<span style="COLOR: blue">string</span>.IsNullOrEmpty(output))
</p>
              <p style="MARGIN: 0px">
            {
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">XDocument</span> xmlDocument
= <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">XDocument</span>();
</p>
              <p style="MARGIN: 0px">
                xmlDocument
= <span style="COLOR: #2b91af">XDocument</span>.Parse(output);
</p>
              <p style="MARGIN: 0px">
 
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: blue">return</span> xmlDocument;
</p>
              <p style="MARGIN: 0px">
            }
</p>
              <p style="MARGIN: 0px">
 
</p>
              <p style="MARGIN: 0px">
            <span style="COLOR: blue">return</span><span style="COLOR: blue">null</span>;
</p>
              <p style="MARGIN: 0px">
        }
</p>
            </div>
            <!--EndFragment-->
          </font>
        </font>
        <font size="2">
          <p>
Next, if I want to grab the status from of the post to Twitter, I can use LINQ as
follows (in this case, I want the id so I can see if it was successful):
</p>
          <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">TwitterAPI</span> twit = <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">TwitterAPI</span>();
</p>
            <p style="MARGIN: 0px">
                    <span style="COLOR: #2b91af">XDocument</span> doc
= twit.UpdateAsXML(<span style="COLOR: #2b91af">Settings</span>.TwitterUserName(), <span style="COLOR: #2b91af">Settings</span>.TwitterPassword(),
txtPost.Text);
</p>
            <p style="MARGIN: 0px">
 
</p>
            <p style="MARGIN: 0px">
                    <span style="COLOR: blue">var</span> status
= <span style="COLOR: blue">from</span> s <span style="COLOR: blue">in</span> doc.Descendants(<span style="COLOR: #a31515">"status"</span>)
</p>
            <p style="MARGIN: 0px">
                   
             <span style="COLOR: blue">select</span> (<span style="COLOR: blue">string</span>)s.Element(<span style="COLOR: #a31515">"id"</span>);
</p>
            <p style="MARGIN: 0px">
 
</p>
            <p style="MARGIN: 0px">
                    <span style="COLOR: blue">bool</span> found
= <span style="COLOR: blue">false</span>;
</p>
            <p style="MARGIN: 0px">
                    <span style="COLOR: blue">foreach</span> (<span style="COLOR: blue">string</span> id <span style="COLOR: blue">in</span> status)
</p>
            <p style="MARGIN: 0px">
                   
    found = <span style="COLOR: blue">true</span>;
</p>
          </div>
          <!--EndFragment-->
          <p>
I am sure there is a better way to determine if it was successful, but this will work
for now, as there are other things I want to do with the response as well. Since this
worked so well, I plan on converting all the XML calls to XDocuments so I can use
LINQ to work with the response.
</p>
          <p>
That's it for today!
</p>
        </font>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=93b87350-9e5d-45df-b06e-3ac75edeb809" />
      </body>
      <title>Yedda library, Twitter Responses and LINQ to XML</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,93b87350-9e5d-45df-b06e-3ac75edeb809.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/05/YeddaLibraryTwitterResponsesAndLINQToXML.aspx</link>
      <pubDate>Wed, 05 Aug 2009 05:34:05 GMT</pubDate>
      <description>&lt;p&gt;
Tonight's coding session went by WAY too fast. I integrated &lt;a href="http://devblog.yedda.com/index.php/twitter-c-library/" target=_blank&gt;Yedda's
Twitter API&lt;/a&gt; into my admin pages so I could post directly without having to use
another client or browse to Twitter to do it. The next step will be to read my blog
feed and Tweet automatically about the topic. That's for another night though, as
tomorrow night is poker night, and yes, I still play. :)
&lt;/p&gt;
&lt;p&gt;
One change I made to the Yedda library (ok, two.. I ran into an issue with an error
code 471 being returned, but a quick Google search fixed that (sometimes I how effeciently
we coded before Google). I wanted to use LINQ to XML to parse out my response code.
So Instead of returning the XML Document, I convert it to an XDocument using the Parse
method, and return that, like this:
&lt;/p&gt;
&lt;font color=#0000ff size=2&gt;&lt;font color=#0000ff size=2&gt; 
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;XDocument&lt;/span&gt; UpdateAsXML(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; userName, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; password, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; text)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; output
= Update(userName, password, text, &lt;span style="COLOR: #2b91af"&gt;OutputFormatType&lt;/span&gt;.XML);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;.IsNullOrEmpty(output))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;XDocument&lt;/span&gt; xmlDocument
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;XDocument&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; xmlDocument
= &lt;span style="COLOR: #2b91af"&gt;XDocument&lt;/span&gt;.Parse(output);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; xmlDocument;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt; 
&lt;p&gt;
Next, if I want to grab the status from of the post to Twitter, I can use LINQ as
follows (in this case, I want the id so I can see if it was successful):
&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;TwitterAPI&lt;/span&gt; twit = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TwitterAPI&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;XDocument&lt;/span&gt; doc
= twit.UpdateAsXML(&lt;span style="COLOR: #2b91af"&gt;Settings&lt;/span&gt;.TwitterUserName(), &lt;span style="COLOR: #2b91af"&gt;Settings&lt;/span&gt;.TwitterPassword(),
txtPost.Text);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;var&lt;/span&gt; status
= &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; s &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; doc.Descendants(&lt;span style="COLOR: #a31515"&gt;"status"&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;select&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;)s.Element(&lt;span style="COLOR: #a31515"&gt;"id"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; found
= &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; id &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; status)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; found = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;
&lt;p&gt;
I am sure there is a better way to determine if it was successful, but this will work
for now, as there are other things I want to do with the response as well. Since this
worked so well, I plan on converting all the XML calls to XDocuments so I can use
LINQ to work with the response.
&lt;/p&gt;
&lt;p&gt;
That's it for today!
&lt;/p&gt;
&lt;/font&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=93b87350-9e5d-45df-b06e-3ac75edeb809" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,93b87350-9e5d-45df-b06e-3ac75edeb809.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item xml:lang="en-US">
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=42b37674-1b23-41ec-b6af-d7a24f8fe980</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,42b37674-1b23-41ec-b6af-d7a24f8fe980.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,42b37674-1b23-41ec-b6af-d7a24f8fe980.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=42b37674-1b23-41ec-b6af-d7a24f8fe980</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today has been a very productive day in general for my .Net development. I came up
with a few ideas of integrating Twitter with the site, as well as some longer range
plans for using trending APIs for a concept I will tentatively call sociolytics<sup>®</sup> (I
would have preferred socialytics<sup>®</sup>, but the name was taken, so I will coin
both and trademark them both). :) 
</p>
        <p>
So today's topic will encompass some of the design considerations. First, I needed
to create an admin page to allow me "behind the scenes" access to posting and functionality.
I made sure to create the page it its own subdirectory to simplify access control
to those pages. I created a separate master page for this section, as I might need
more real estate for the controls which will reside on this page. Which brings up
another topicI will bring up at some point --&gt; control oriented encapsulation.
</p>
        <p>
One of the controls was to allow me to post to Twitter directly from the page. I debated
a couple ways to do this.. limit my control to 140 characters, or allow more, and
do multiple posts. I opted one post per submit, as I want to make sure my posts are
complete. I wil add a link to create "tiny URLs" via a web service next, to aid in
quickly creating short links for things I want to tweet. I picked up a nice article
on that over at <a href="http://www.codeproject.com/KB/aspnet/ZetaTinyUrl.aspx" target="_blank">CodeProject</a>.
</p>
        <p>
But the topic of this post relates to a cool feature in the Visual Studio 2008 IDE.
Maybe this has been there all along, and I didn't notice it, but today I did. I needed
to create a control which allows me to quickly encrypt values. For example, until
I get OAuth implemented, I want to hide my Twitter credentials. However, when I post
this functionality, I really don't want the world playing with this functionality
if they manage to hit this page.
</p>
        <p>
So enter the conditional compilation. I wrap the calls in the following code, and
when I compile for release, it's not included. What's nice is that the IDE even reflects
the code won't be available when compiling in Release mode. Pretty nifty!!
</p>
        <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">            try</span>
          </p>
          <p style="MARGIN: 0px">
            {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">#if</span> DEBUG
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">           
    if (txtValue.Text.Trim().Length &gt; 0)</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">           
    {</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">           
        lblResult.Text = Settings.EncryptString(txtValue.Text);</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">           
    }</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">           
    else</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">           
        lblResult.Text = String.Empty;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">#endif</span>
          </p>
          <p style="MARGIN: 0px">
            }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">catch</span> (<span style="COLOR: #2b91af">Exception</span> ex)
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
BTW, thanks to <a href="http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/" target="_blank">CopySourceAsHTML</a> for
making posting snippets so easy!
</p>
          <p style="MARGIN: 0px">
 
</p>
        </div>
        <!--EndFragment-->
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=42b37674-1b23-41ec-b6af-d7a24f8fe980" />
      </body>
      <title>Conditional Compilation and the VS2008 IDE</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,42b37674-1b23-41ec-b6af-d7a24f8fe980.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/04/ConditionalCompilationAndTheVS2008IDE.aspx</link>
      <pubDate>Tue, 04 Aug 2009 05:15:10 GMT</pubDate>
      <description>&lt;p&gt;
Today has been a very productive day in general for my .Net development. I came up
with a few ideas of integrating Twitter with the site, as well as some longer range
plans for using trending APIs for a concept I will tentatively call sociolytics&lt;sup&gt;®&lt;/sup&gt; (I
would have preferred socialytics&lt;sup&gt;®&lt;/sup&gt;, but the name was taken, so I will coin
both and trademark them both). :) 
&lt;/p&gt;
&lt;p&gt;
So today's topic will encompass some of the design considerations. First, I needed
to create an admin page to allow me "behind the scenes" access to posting and functionality.
I made sure to create the page it its own subdirectory to simplify access control
to those pages. I created a separate master page for this section, as I might need
more real estate for the controls which will reside on this page. Which brings up
another topicI will bring up at some point --&amp;gt; control oriented encapsulation.
&lt;/p&gt;
&lt;p&gt;
One of the controls was to allow me to post to Twitter directly from the page. I debated
a couple ways to do this.. limit my control to 140 characters, or allow more, and
do multiple posts. I opted one post per submit, as I want to make sure my posts are
complete. I wil add a link to create "tiny URLs" via a web service next, to aid in
quickly creating short links for things I want to tweet. I picked up a nice article
on that over at &lt;a href="http://www.codeproject.com/KB/aspnet/ZetaTinyUrl.aspx" target=_blank&gt;CodeProject&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
But the topic of this post relates to a cool feature in the Visual Studio 2008 IDE.
Maybe this has been there all along, and I didn't notice it, but today I did. I needed
to create a control which allows me to quickly encrypt values. For example, until
I get OAuth implemented, I want to hide my Twitter credentials. However, when I post
this functionality, I really don't want the world playing with this functionality
if they manage to hit this page.
&lt;/p&gt;
&lt;p&gt;
So enter the conditional compilation. I wrap the calls in the following code, and
when I compile for release, it's not included. What's nice is that the IDE even reflects
the code won't be available when compiling in Release mode. Pretty nifty!!
&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;#if&lt;/span&gt; DEBUG
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (txtValue.Text.Trim().Length &amp;gt; 0)&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; lblResult.Text = Settings.EncryptString(txtValue.Text);&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; lblResult.Text = String.Empty;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;#endif&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;catch&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;Exception&lt;/span&gt; ex)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
BTW, thanks to &lt;a href="http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/" target=_blank&gt;CopySourceAsHTML&lt;/a&gt; for
making posting snippets so easy!
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=42b37674-1b23-41ec-b6af-d7a24f8fe980" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,42b37674-1b23-41ec-b6af-d7a24f8fe980.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=8e641840-54a8-4e88-ada1-e98f308e611f</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,8e641840-54a8-4e88-ada1-e98f308e611f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,8e641840-54a8-4e88-ada1-e98f308e611f.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8e641840-54a8-4e88-ada1-e98f308e611f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As the main site is developed, I'll detail what decisions I used to create the
site, then a high level overview of how I designed it. Just a warning though, some
of the decisions will seem very arbitrary, as they were. I made them simply because
working on your own site gives you a luxury of trying things you normally can't do
with a client. In my case, a lot of my decisions will be over-engineered, because
I may want to re-use them later.
</p>
        <p>
Of course, the first thing I had to come up with was an overall site layout. I won't
go into that here, as one thing I will never profess to be is a layout guru. I got
a decent design, and I set them up as a master page so the rest of the site development
will go easy. I used VS2008 and C#, and began implementing AJAX where it made sense.
For example, there's a control which updates the current time every 30 seconds or
so, so I could use the update panel and timer control.
</p>
        <p>
The first real functionality I wanted to add was a link to this blog. So I created
a user control, and placed it on the front page. However, I do plan on posting a lot
more here, so I knew it wouldn't be feasible to show every post, so I decided to limit
it to the latest three posts. I wanted to display the title, the date and the first
bit of the post to hopefully catch a reader's attention.
</p>
        <p>
But reading from a feed from sites at two different hosting providers can be tricky.
Not from a security standpoint, as RSS feeds are open, but more from a performance
standpoint. Anyone coming to my portal site should be able to see the latest posts,
and quickly. The fastest way of doing this would be to create a Windows service which
periodically reads the feed, and stores the information in a database. However, I
am not sure I would be able to install a Windows service on my service provider's
server. So......
</p>
        <p>
What<em>  </em>I <em>can</em> do however is read the feed, and place it in cache.
Periodically, I can expire the cache and re-load it, and unless you are the unlucky
soul to have to wait while it loads, the majority of the users will have a quick response.
For that poor soul who waits while cache is refreshed, I used Ajax and the UpdateProgress
control to provide some visual feedback that the page is doing something.
</p>
        <p>
The rest was pretty straightforward. I either request the XML from the RSS feed (or
cache), and use XSLT to display it. It's been a while since I have used XSLT, but
there is a lot of potential there, I expect I will be using a lot more of it in future
controls. I created the class generically so that I could pull any RSS feed
I wanted from it as well.
</p>
        <p>
One great use I found for XSLT was on a high-availability web site which sent a lot
of emails. We wanted to be able to change the email format frequently without bringing
the site down. Using XSLT, we could change the email template files any time to create
very nice HTML based email messages. I read a great article recently about calling
C# functions in your XSLT templates using extension methods, which I plan to use extensively,
as C# is my main domain. Maybe I will use them... I say that as I really would like
to improve my XSLT skills, as I think the technology is highy underused in the .Net
world.
</p>
        <p>
So now I am playing with Twitter feeds and getting the rest of the site content set
up. I also used the AJAX popup control to help prevent any 404 errors as I complete
the functionality. If you've been putting off using the AJAX Control Toolkit for some
reason.. STOP! The amount of functionality these controls offer is amazing, and you
can't beat the price.
</p>
        <p>
That's it for now! If you want more details on how I accomplished this or some sample
code, just send me a comment. Upcoming posts will address the development of the rest
of the site, along with some major wins recently using CodeSmith.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=8e641840-54a8-4e88-ada1-e98f308e611f" />
      </body>
      <title>First Control -- RSS Feed</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,8e641840-54a8-4e88-ada1-e98f308e611f.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/02/FirstControlRSSFeed.aspx</link>
      <pubDate>Sun, 02 Aug 2009 14:54:16 GMT</pubDate>
      <description>&lt;p&gt;
As the main site is developed, I'll detail what&amp;nbsp;decisions I used to create the
site, then a high level overview of how I designed it. Just a warning though, some
of the decisions will seem very arbitrary, as they were. I made them simply because
working on your own site gives you a luxury of trying things you normally can't do
with a client. In my case, a lot of my decisions will be over-engineered, because
I may want to re-use them later.
&lt;/p&gt;
&lt;p&gt;
Of course, the first thing I had to come up with was an overall site layout. I won't
go into that here, as one thing I will never profess to be is a layout guru. I got
a decent design, and I set them up as a master page so the rest of the site development
will go easy. I used VS2008 and C#, and began implementing AJAX where it made sense.
For example, there's a control which updates the current time every 30 seconds or
so, so I could use the update panel and timer control.
&lt;/p&gt;
&lt;p&gt;
The first real functionality I wanted to add was a link to this blog. So I created
a user control, and placed it on the front page. However, I do plan on posting a lot
more here, so I knew it wouldn't be feasible to show every post, so I decided to limit
it to the latest three posts. I wanted to display the title, the date and the first
bit of the post to hopefully catch a reader's attention.
&lt;/p&gt;
&lt;p&gt;
But reading from a feed from sites at two different hosting providers can be tricky.
Not from a security standpoint, as RSS feeds are open, but more from a performance
standpoint. Anyone coming to my portal site should be able to see the latest posts,
and quickly. The fastest way of doing this would be to create a Windows service which
periodically reads the feed, and stores the information in a database. However, I
am not sure I would be able to install a Windows service on my service provider's
server. So......
&lt;/p&gt;
&lt;p&gt;
What&lt;em&gt;&amp;nbsp; &lt;/em&gt;I &lt;em&gt;can&lt;/em&gt; do however is read the feed, and place it in cache.
Periodically, I can expire the cache and re-load it, and unless you are the unlucky
soul to have to wait while it loads, the majority of the users will have a quick response.
For that poor soul who waits while cache is refreshed, I used Ajax and the UpdateProgress
control to provide some visual feedback that the page is doing something.
&lt;/p&gt;
&lt;p&gt;
The rest was pretty straightforward. I either request the XML from the RSS feed (or
cache), and use XSLT to display it. It's been a while since I have used XSLT, but
there is a lot of potential there, I expect I will be using a lot more of it in future
controls. I created the class&amp;nbsp;generically so&amp;nbsp;that I could pull any RSS feed
I wanted from it as well.
&lt;/p&gt;
&lt;p&gt;
One great use I found for XSLT was on a high-availability web site which sent a lot
of emails. We wanted to be able to change the email format frequently without bringing
the site down. Using XSLT, we could change the email template files any time to create
very nice HTML based email messages. I read a great article recently about calling
C# functions in your XSLT templates using extension methods, which I plan to use extensively,
as C# is my main domain. Maybe I will use them... I say that as I really would like
to improve my XSLT skills, as I think the technology is highy underused in the .Net
world.
&lt;/p&gt;
&lt;p&gt;
So now I am playing with Twitter feeds and getting the rest of the site content set
up. I also used the AJAX popup control to help prevent any 404 errors as I complete
the functionality. If you've been putting off using the AJAX Control Toolkit for some
reason.. STOP! The amount of functionality these controls offer is amazing, and you
can't beat the price.
&lt;/p&gt;
&lt;p&gt;
That's it for now! If you want more details on how I accomplished this or some sample
code, just send me a comment. Upcoming posts will address the development of the rest
of the site, along with some major wins recently using CodeSmith.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=8e641840-54a8-4e88-ada1-e98f308e611f" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,8e641840-54a8-4e88-ada1-e98f308e611f.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>Design</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=017c4821-2e6b-48b7-afc0-97f7bd171a24</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,017c4821-2e6b-48b7-afc0-97f7bd171a24.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,017c4821-2e6b-48b7-afc0-97f7bd171a24.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=017c4821-2e6b-48b7-afc0-97f7bd171a24</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The past three years have been spent more managing teams of developers than actually
doing development. On my current gig, I have gotten more of an opportunity to get
back into the code, and I have to say, I mhave missed it immensely. 
</p>
        <p>
As a result, I have started doing coding purely for myself, and I have to say it has
been immeasuably enjoyable. So I put my company's website back online, but this time
it uses AJAX, RSS feeds, and soon, Twitter!
</p>
        <p>
It's been an interesting and fun hiatus from pure coding, but now I am really looking
forward to updating my skills again, and writing about it along the way. 
</p>
        <p>
This post will be the first "real" test of my onsite RSS reader. So in a bit, it should
appear on the front page of my all new company portal site... <a href="http://www.rubiconcomputing.com/" target="_blank">Rubicon
Computing Solutions!</a></p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=017c4821-2e6b-48b7-afc0-97f7bd171a24" />
      </body>
      <title>New web site, new technologies, and new horizons!</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,017c4821-2e6b-48b7-afc0-97f7bd171a24.aspx</guid>
      <link>http://www.dotnettechnologies.com/2009/08/02/NewWebSiteNewTechnologiesAndNewHorizons.aspx</link>
      <pubDate>Sun, 02 Aug 2009 00:30:11 GMT</pubDate>
      <description>&lt;p&gt;
The past three years have been spent more managing teams of developers than actually
doing development. On my current gig, I have gotten more of an opportunity to get
back into the code, and I have to say, I mhave missed it immensely. 
&lt;/p&gt;
&lt;p&gt;
As a result, I have started doing coding purely for myself, and I have to say it has
been immeasuably enjoyable. So I put my company's website back online, but this time
it uses AJAX, RSS feeds, and soon, Twitter!
&lt;/p&gt;
&lt;p&gt;
It's been an interesting and fun hiatus from pure coding, but now I am really looking
forward to updating my skills again, and writing about it along the way. 
&lt;/p&gt;
&lt;p&gt;
This post will be the first "real" test of my onsite RSS reader. So in a bit, it should
appear on the front page of my all new company portal site... &lt;a href="http://www.rubiconcomputing.com/" target=_blank&gt;Rubicon
Computing Solutions!&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=017c4821-2e6b-48b7-afc0-97f7bd171a24" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,017c4821-2e6b-48b7-afc0-97f7bd171a24.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=e889b6b0-390d-4c5a-a94c-1702a2d7d8e5</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,e889b6b0-390d-4c5a-a94c-1702a2d7d8e5.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,e889b6b0-390d-4c5a-a94c-1702a2d7d8e5.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e889b6b0-390d-4c5a-a94c-1702a2d7d8e5</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There's a pretty useful feature (IMHO) in the .Net 2.0 Exception object which
I hadn't noticed before. The Exception object contains a new Data interface, which
is essentially an IDictionary for applying additional values to the exception object.
I am currently using it with my integration of the new VS2005 Enterprise Library into
our framework. 
</p>
        <p>
I want to log exceptions to a database, but I have found it useful in the past to
have an Error #. In the old days (VB 6, for example) I could usually look at the error
number of an application and tell exactly what the problem was. When .Net came into
being, we lost the error number, and there was no easy way to get around it. You could
roll your own exception classes of course and add these properties, but this is only
a limited solution because other exception handlers wouldn't be capable of handling
the additional features by default.
</p>
        <p>
Now this feature is going to allow me to take advantage of error numbers by classifying
each exception type, and appending an error number to the exception object. I can
use this information in my database to classify and group errors by type to identify
weak areas in an application as well. Not Earth shattering, but still a useful feature
full of all kinds of possibilities.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=e889b6b0-390d-4c5a-a94c-1702a2d7d8e5" />
      </body>
      <title>New feature in .Net 2.0 Exception object</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,e889b6b0-390d-4c5a-a94c-1702a2d7d8e5.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/06/13/NewFeatureInNet20ExceptionObject.aspx</link>
      <pubDate>Tue, 13 Jun 2006 15:42:38 GMT</pubDate>
      <description>&lt;p&gt;
There's a pretty useful feature (IMHO)&amp;nbsp;in the .Net 2.0 Exception object which
I hadn't noticed before. The Exception object contains a new Data interface, which
is essentially an IDictionary for applying additional values to the exception object.
I am currently using it with my integration of the new VS2005 Enterprise Library into
our framework. 
&lt;/p&gt;
&lt;p&gt;
I want to log exceptions to a database, but I have found it useful in the past to
have an Error #. In the old days (VB 6, for example) I could usually look at the error
number of an application and tell exactly what the problem was. When .Net came into
being, we lost the error number, and there was no easy way to get around it. You could
roll your own exception classes of course and add these properties, but this is only
a limited solution because other exception handlers wouldn't be capable of handling
the additional features by default.
&lt;/p&gt;
&lt;p&gt;
Now this feature is going to allow me to take advantage of error numbers by classifying
each exception type, and appending an error number to the exception object. I can
use this information in my database to classify and group errors by type to identify
weak areas in an application as well. Not Earth shattering, but still a useful feature
full of all kinds of possibilities.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=e889b6b0-390d-4c5a-a94c-1702a2d7d8e5" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,e889b6b0-390d-4c5a-a94c-1702a2d7d8e5.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>Debugging</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=29bdfb36-397e-47b3-b62d-04782a8e5e98</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,29bdfb36-397e-47b3-b62d-04782a8e5e98.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,29bdfb36-397e-47b3-b62d-04782a8e5e98.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=29bdfb36-397e-47b3-b62d-04782a8e5e98</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Still working on getting posts over at <a href="http://www.developernation.net/" target="_blank">developernation.net</a>,
and ran out of time on a series I am writing. This week looks to slow down a bit,
so hopefully by the end of the week I can finish my series on a web service for paging
and sorting data. Until then, I just ran across a situation where I needed to programmatically
determine the current database name from T-SQL. Sounds easy, right? Well,
fortunately it is, but the function to do it is documented poorly, so I figured I
would post a tip so others could find it easily.
</p>
        <p>
SELECT db_name()<br /></p>
        <p>
The documentation says you need to pass in the db id, as does the example. However,
if you read very closely, it appears you don't need to pass in the id, and it will
return the current db for the connection. I wish they would have followed the documentation
standard of using optional parameters with brackets [], and it would have saved some
time.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=29bdfb36-397e-47b3-b62d-04782a8e5e98" />
      </body>
      <title>Tip of the Day -- Determine current database name using T-SQL</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,29bdfb36-397e-47b3-b62d-04782a8e5e98.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/05/16/TipOfTheDayDetermineCurrentDatabaseNameUsingTSQL.aspx</link>
      <pubDate>Tue, 16 May 2006 15:38:30 GMT</pubDate>
      <description>&lt;p&gt;
Still working on getting posts over at &lt;a href="http://www.developernation.net/" target=_blank&gt;developernation.net&lt;/a&gt;,
and ran out of time on a series I am writing. This week looks to slow down a bit,
so hopefully by the end of the week I can finish my series on a web service for paging
and sorting data. Until then, I just ran across a situation where I needed to programmatically
determine the current&amp;nbsp;database name&amp;nbsp;from T-SQL. Sounds easy, right? Well,
fortunately it is, but the function to do it is documented poorly, so I figured I
would post a tip so others could find it easily.
&lt;/p&gt;
&lt;p&gt;
SELECT db_name()&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
The documentation says you need to pass in the db id, as does the example. However,
if you read very closely, it appears you don't need to pass in the id, and it will
return the current db for the connection. I wish they would have followed the documentation
standard of using optional parameters with brackets [], and it would have saved some
time.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=29bdfb36-397e-47b3-b62d-04782a8e5e98" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,29bdfb36-397e-47b3-b62d-04782a8e5e98.aspx</comments>
      <category>All Things</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=e71c0a9e-e77d-4544-8698-d2c8674e7435</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,e71c0a9e-e77d-4544-8698-d2c8674e7435.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,e71c0a9e-e77d-4544-8698-d2c8674e7435.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e71c0a9e-e77d-4544-8698-d2c8674e7435</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
So it has been hit or miss posting here, but I am trying to correct it by bringing
on some additional help. I set up a new blog, <a href="http://www.developernation.net">developernation.net</a>,
and begun getting some content on there. Likely I'll crosspost on here too (my content
anyways) but likely most new entries are going to be there first. I figured if I could
get someone else on there helping doing some content, it will have more regular posts.
This blog will continue, just a lag a few days on the content of theother site, and
contain more personal observations.
</p>
        <p>
So swing on by and pop in. I've started off with a bang, and I am in the process of
posting a web service design I created and tested which handles paging and sorting
of data on the server, which my initial tests have shown to be highly efficient. I
am walking through the entire design, and by the end of the weekend I hope to have
the series done and the code posted. If not, you can wait a few days and I will post
it all here as well. 
</p>
        <p>
Thanks!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=e71c0a9e-e77d-4544-8698-d2c8674e7435" />
      </body>
      <title>A change of directions...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,e71c0a9e-e77d-4544-8698-d2c8674e7435.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/04/28/AChangeOfDirections.aspx</link>
      <pubDate>Fri, 28 Apr 2006 15:38:06 GMT</pubDate>
      <description>&lt;p&gt;
So it has been hit or miss posting here, but I am trying to correct it by bringing
on some additional help. I set up a new blog, &lt;a href="http://www.developernation.net"&gt;developernation.net&lt;/a&gt;,
and begun getting some content on there. Likely I'll crosspost on here too (my content
anyways) but likely most new entries are going to be there first. I figured if I could
get someone else on there helping doing some content, it will have more regular posts.
This blog will continue, just a lag a few days on the content of theother site, and
contain more personal observations.
&lt;/p&gt;
&lt;p&gt;
So swing on by and pop in. I've started off with a bang, and I am in the process of
posting a web service design I created and tested which handles paging and sorting
of data on the server, which my initial tests have shown to be highly efficient. I
am walking through the entire design, and by the end of the weekend I hope to have
the series done and the code posted. If not, you can wait a few days and I will post
it all here as well. 
&lt;/p&gt;
&lt;p&gt;
Thanks!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=e71c0a9e-e77d-4544-8698-d2c8674e7435" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,e71c0a9e-e77d-4544-8698-d2c8674e7435.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Debugging</category>
      <category>Design</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
      <category>VB.Net</category>
      <category>Web Services</category>
      <category>Windows</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=8ca727bf-8f09-4f56-bf20-110daa00a309</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,8ca727bf-8f09-4f56-bf20-110daa00a309.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,8ca727bf-8f09-4f56-bf20-110daa00a309.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8ca727bf-8f09-4f56-bf20-110daa00a309</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was talking with someone this morning about bugs, and I remembered a request I received
many years ago. There was a really large Access database project, and I had inherited
it. Unfortunately, it had become a total kludge, and I continually requested the client
invest the time and money in upgrading it into a more appropriate technology, such
as VB.
</p>
        <p>
As is often the case, when it comes to the money discussion, it's tough sometimes
to convince a client a re-write is actually less expensive over time, especially when
the scope has changed so many times, and looking forward it looks like it is going
to do the same. This is actually where agile development methodologies are at their
best. So in this case, when I explained that the changes would have a huge impact
on the project, and it would likely introduce bugs into the system (they also didn't
like to pay for testing, feeling they could test it in use), they advised me to continue. 
</p>
        <p>
Just as I predicted, the changes did introduce a lot of issues into their work processes.
As I recalled the notes and admonitions I made regarding the changes, I received a
rather novel and (to me) humerous response....
</p>
        <p>
Here's the gist of the conversation...
</p>
        <p>
(Client) This is an Access database, right?
</p>
        <p>
(Me) Yes, it is. 
</p>
        <p>
(Client) And you are always running custom queries for us, right?
</p>
        <p>
(Me) Yes, I do.
</p>
        <p>
(Client) So maybe you could just run a query to identify all the bugs in the system?
</p>
        <p>
(Me) If I could do that, I'd be retired and very well off right now..
</p>
        <p>
Sometimes a poker face is a wonderful consulting tool. :) 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=8ca727bf-8f09-4f56-bf20-110daa00a309" />
      </body>
      <title>Something funny I remembered...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,8ca727bf-8f09-4f56-bf20-110daa00a309.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/03/27/SomethingFunnyIRemembered.aspx</link>
      <pubDate>Mon, 27 Mar 2006 15:49:48 GMT</pubDate>
      <description>&lt;p&gt;
I was talking with someone this morning about bugs, and I remembered a request I received
many years ago. There was a really large Access database project, and I had inherited
it. Unfortunately, it had become a total kludge, and I continually requested the client
invest the time and money in upgrading it into a more appropriate technology, such
as VB.
&lt;/p&gt;
&lt;p&gt;
As is often the case, when it comes to the money discussion, it's tough sometimes
to convince a client a re-write is actually less expensive over time, especially when
the scope has changed so many times, and looking forward it looks like it is going
to do the same. This is actually where agile development methodologies are at their
best. So in this case, when I explained that the changes would have a huge impact
on the project, and it would likely introduce bugs into the system (they also didn't
like to pay for testing, feeling they could test it in use), they advised me to continue. 
&lt;/p&gt;
&lt;p&gt;
Just as I predicted, the changes did introduce a lot of issues into their work processes.
As I recalled the notes and admonitions I made regarding the changes, I received a
rather novel and (to me) humerous response....
&lt;/p&gt;
&lt;p&gt;
Here's the gist of the conversation...
&lt;/p&gt;
&lt;p&gt;
(Client) This is an Access database, right?
&lt;/p&gt;
&lt;p&gt;
(Me) Yes, it is. 
&lt;/p&gt;
&lt;p&gt;
(Client) And you are always running custom queries for us, right?
&lt;/p&gt;
&lt;p&gt;
(Me) Yes, I do.
&lt;/p&gt;
&lt;p&gt;
(Client) So maybe you could just run a query to identify all the bugs in the system?
&lt;/p&gt;
&lt;p&gt;
(Me) If I could do that, I'd be retired and very well off right now..
&lt;/p&gt;
&lt;p&gt;
Sometimes a poker face is a wonderful consulting tool. :) 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=8ca727bf-8f09-4f56-bf20-110daa00a309" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,8ca727bf-8f09-4f56-bf20-110daa00a309.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=5dafa1e9-5ed0-4f7e-bb5e-bf0aa92b019f</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,5dafa1e9-5ed0-4f7e-bb5e-bf0aa92b019f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,5dafa1e9-5ed0-4f7e-bb5e-bf0aa92b019f.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5dafa1e9-5ed0-4f7e-bb5e-bf0aa92b019f</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I had a great need again for WinCV today, and was beginning to work out in my mind
how I would rewrite it, as I posted earlier. However, it hit me that <a href="http://www.aisto.com/roeder/dotnet/" target="_blank">Lutz
Roeder's Reflector for .Net</a> might actually do what I needed. It does, it turns
out. I did have to modify the .cfg file to look at the new assemblies for VS2005,
but once I did that, the search functionality worked wonders. So, even though it would
have proven to be a great learning experience, I am going to forego putting a rehash
together, and stick with something that works very nicely..
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=5dafa1e9-5ed0-4f7e-bb5e-bf0aa92b019f" />
      </body>
      <title>Solution to the WinCV issue...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,5dafa1e9-5ed0-4f7e-bb5e-bf0aa92b019f.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/03/22/SolutionToTheWinCVIssue.aspx</link>
      <pubDate>Wed, 22 Mar 2006 23:00:20 GMT</pubDate>
      <description>&lt;p&gt;
I had a great need again for WinCV today, and was beginning to work out in my mind
how I would rewrite it, as I posted earlier. However, it hit me that &lt;a href="http://www.aisto.com/roeder/dotnet/" target=_blank&gt;Lutz
Roeder's Reflector for .Net&lt;/a&gt; might actually do what I needed. It does, it turns
out. I did have to modify the .cfg file to look at the new assemblies for VS2005,
but once I did that, the search functionality worked wonders. So, even though it would
have proven to be a great learning experience, I am going to forego putting a rehash
together, and stick with something that works very nicely..
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=5dafa1e9-5ed0-4f7e-bb5e-bf0aa92b019f" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,5dafa1e9-5ed0-4f7e-bb5e-bf0aa92b019f.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>General</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=48b279f9-c7e2-406f-aa87-64856644c179</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,48b279f9-c7e2-406f-aa87-64856644c179.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,48b279f9-c7e2-406f-aa87-64856644c179.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=48b279f9-c7e2-406f-aa87-64856644c179</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I found some details on WinCV for VS2005 (or the lack thereof). As near as I can ascertain,
if you have VS2005 only, and place WinCV on that system it will work for the .Net
2.0 libraries. I don't know how that works as it seems the information is
hardcoded into WinCV.
</p>
        <p>
So, it was such a great utility, and I think it lends itself to some great enhancements,
so I think I am going to write a version which is VS2005+ compliant. Some features
I want to add:
</p>
        <ul>
          <li>
Quick linking to the help topic for a class/method</li>
          <li>
Ability to easily add external assemblies WITHOUT having to use the command line</li>
        </ul>
        <p>
I plan on keeping the same basic interface though, as it was simple and effective.
Not sure how much I willl get to work on this, or how long it will take, but I will
post it here and probably CodeProject when I get it finished.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=48b279f9-c7e2-406f-aa87-64856644c179" />
      </body>
      <title>WinCV v2 revisited</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,48b279f9-c7e2-406f-aa87-64856644c179.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/03/22/WinCVV2Revisited.aspx</link>
      <pubDate>Wed, 22 Mar 2006 15:44:55 GMT</pubDate>
      <description>&lt;p&gt;
I found some details on WinCV for VS2005 (or the lack thereof). As near as I can ascertain,
if you have VS2005 only, and place WinCV on that system it will work for the .Net
2.0 libraries.&amp;nbsp;I don't know how that works&amp;nbsp;as it seems the information is
hardcoded into WinCV.
&lt;/p&gt;
&lt;p&gt;
So, it was such a great utility, and I think it lends itself to some great enhancements,
so I think I am going to write a version which is VS2005+ compliant. Some features
I want to add:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Quick linking to the help topic for a class/method&lt;/li&gt;
&lt;li&gt;
Ability to easily add external assemblies WITHOUT having to use the command line&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I plan on keeping the same basic interface though, as it was simple and effective.
Not sure how much I willl get to work on this, or how long it will take, but I will
post it here and probably CodeProject when I get it finished.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=48b279f9-c7e2-406f-aa87-64856644c179" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,48b279f9-c7e2-406f-aa87-64856644c179.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=2c537831-a01e-4f1a-83a6-3861b8ec6ba9</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,2c537831-a01e-4f1a-83a6-3861b8ec6ba9.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,2c537831-a01e-4f1a-83a6-3861b8ec6ba9.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2c537831-a01e-4f1a-83a6-3861b8ec6ba9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Is it just my installation, or is WinCV missing from the latest version of .Net? Granted,
I can still use the old WinCV by changing the config file, but why was such a useful
tool pulled from VS2005?
</p>
        <p>
If you've never used WinCV, check it out for VS2003 and prior version. It essentially
lets you search the framework for a certain keyword. For example, if you want to find
out which namespace "Registry" is in, type it in, and see the entire implementation.
By using the configuration file, you can add additional assemblies for WinCV, to search
your own libraries or those of third party vendors.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=2c537831-a01e-4f1a-83a6-3861b8ec6ba9" />
      </body>
      <title>WinCV, where for art thou?</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,2c537831-a01e-4f1a-83a6-3861b8ec6ba9.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/03/21/WinCVWhereForArtThou.aspx</link>
      <pubDate>Tue, 21 Mar 2006 13:48:01 GMT</pubDate>
      <description>&lt;p&gt;
Is it just my installation, or is WinCV missing from the latest version of .Net? Granted,
I can still use the old WinCV by changing the config file, but why was such a useful
tool pulled from VS2005?
&lt;/p&gt;
&lt;p&gt;
If you've never used WinCV, check it out for VS2003 and prior version. It essentially
lets you search the framework for a certain keyword. For example, if you want to find
out which namespace "Registry" is in, type it in, and see the entire implementation.
By using the configuration file, you can add additional assemblies for WinCV, to search
your own libraries or those of third party vendors.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=2c537831-a01e-4f1a-83a6-3861b8ec6ba9" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,2c537831-a01e-4f1a-83a6-3861b8ec6ba9.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=29051ab7-c28e-491a-af04-f7f02b6ccce6</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,29051ab7-c28e-491a-af04-f7f02b6ccce6.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,29051ab7-c28e-491a-af04-f7f02b6ccce6.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=29051ab7-c28e-491a-af04-f7f02b6ccce6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've been playing a bit of poker recently, and having mixed results. Earlier this
year, I was on a tear, and couldn't lose. Lately though, it's been a bit dry. I played
in a tournament on Sunday at a local casino, and finally made the final table again,
and even did ok in te cash game leading up to it. 
</p>
        <p>
Tonight was a humorous night though. I decided to play again, as I am in the running
for a finals tournament at the casino I placed on Sunday. First, I played against
a handicapped player, and we came up with a device to help quadraplegics to play poker
with less assistance than it normally takes. Now I just have to find the parts and
see if I can put it together, as it looks like a very viable solution to help him.
But secondly, I have to say tonights tournament was the "worst" I have ever had. Although
I managed to stay alive for 2.5 hours (mainly due to the lack of playable hands or
situations), I did not win a single hand. However, I DID manage to chop one, so I
will count that as 1/2 of a hand, but all I won were half the blinds. If you count
the cash game I played prior to the tournament, I think you could take that losing
streak to 4 hours of not winning one hand. Fortunately, losses were minimal, as the
hands I was starting with were poor quality, and I just rode out the blinds. I think
that is the longest I have ever gone. What a test of patience!
</p>
        <p>
Such is poker...
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=29051ab7-c28e-491a-af04-f7f02b6ccce6" />
      </body>
      <title>Rough night of poker..</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,29051ab7-c28e-491a-af04-f7f02b6ccce6.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/03/17/RoughNightOfPoker.aspx</link>
      <pubDate>Fri, 17 Mar 2006 05:39:58 GMT</pubDate>
      <description>&lt;p&gt;
I've been playing a bit of poker recently, and having mixed results. Earlier this
year, I was on a tear, and couldn't lose. Lately though, it's been a bit dry. I played
in a tournament on Sunday at a local casino, and finally made the final table again,
and even did ok in te cash game leading up to it. 
&lt;/p&gt;
&lt;p&gt;
Tonight was a humorous night though. I decided to play again, as I am in the running
for a finals tournament at the casino I placed on Sunday. First, I played against
a handicapped player, and we came up with a device to help quadraplegics to play poker
with less assistance than it normally takes. Now I just have to find the parts and
see if I can put it together, as it looks like a very viable solution to help him.
But secondly, I have to say tonights tournament was the "worst" I have ever had. Although
I managed to stay alive for 2.5 hours (mainly due to the lack of playable hands or
situations), I did not win a single hand. However, I DID manage to chop one, so I
will count that as 1/2 of a hand, but all I won were half the blinds. If you count
the cash game I played prior to the tournament, I think you could take that losing
streak to 4 hours of not winning one hand. Fortunately, losses were minimal, as the
hands I was starting with were poor quality, and I just rode out the blinds. I think
that is the longest I have ever gone. What a test of patience!
&lt;/p&gt;
&lt;p&gt;
Such is poker...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=29051ab7-c28e-491a-af04-f7f02b6ccce6" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,29051ab7-c28e-491a-af04-f7f02b6ccce6.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=85fc9c9c-5e1e-4b33-8873-86b05c0d443d</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,85fc9c9c-5e1e-4b33-8873-86b05c0d443d.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,85fc9c9c-5e1e-4b33-8873-86b05c0d443d.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=85fc9c9c-5e1e-4b33-8873-86b05c0d443d</wfw:commentRss>
      <title>Web Service Issues Part II: The Underlying Connection was closed</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,85fc9c9c-5e1e-4b33-8873-86b05c0d443d.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/03/16/WebServiceIssuesPartIITheUnderlyingConnectionWasClosed.aspx</link>
      <pubDate>Thu, 16 Mar 2006 05:19:42 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;Previously, I discussed how I worked around a firewall
issue where the HTTPS port was re-mapped, and the return URL was different than the
request URL as a result of that remapping. So I trudged on, and hit a real stumper.
Here’s the new issue:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;
&lt;o:p&gt;
&lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;&lt;em&gt;&lt;strong&gt;The underlying connection was closed: Could
not establish secure channel for SSL/TLS. Inner Exception: The function completed
successfully, but must be called again to complete the context&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;I ran across Jan Tielen’s blog post (&lt;/font&gt;&lt;a href="http://weblogs.asp.net/jan/archive/2004/05/08/128394.aspx" target=_blank&gt;&lt;font face=Arial&gt;http://weblogs.asp.net/jan/archive/2004/05/08/128394.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face=Arial color=#000000&gt;)
where he provided a code snippet to override the GetWebRequest method in the Reference.cs
file. I implemented it, and it worked great --- on my development machine! However,
when rolled out to the same test environment, the problem remained. However, I modified
it futher, and got it to work..&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face="Times New Roman" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;///&lt;/span&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Set
web request properties here&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="uri"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;uri &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: blue"&gt;protected&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;override&lt;/span&gt;&lt;font color=#000000&gt; System.Net.WebRequest
GetWebRequest(System.Uri uri) 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;System.Net.HttpWebRequest
webRequest = (System.Net.HttpWebRequest)WebRequest.Create(uri);&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;webRequest.AllowWriteStreamBuffering
= &lt;/font&gt;&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;&lt;font color=#000000&gt;;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;webRequest.KeepAlive
= &lt;/font&gt;&lt;span style="COLOR: blue"&gt;false&lt;/span&gt;&lt;font color=#000000&gt;;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt;&lt;font color=#000000&gt; webRequest;&lt;/font&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;
&lt;o:p&gt;
&lt;font color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;Sort of. When I tried to use DIME with the above code,
it gave me an error “Client found response content type of '', but expected 'text/xml'”.
That was not going to work. I found some more code, and it seemed to work great once
again, until I tried to make a DIME call. Here was that attempt.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face="Times New Roman" color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="COLOR: blue"&gt;protected&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;override&lt;/span&gt;&lt;font color=#000000&gt; System.Net.WebRequest
GetWebRequest(System.Uri uri) 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;WebRequest
request = &lt;/font&gt;&lt;span style="COLOR: blue"&gt;base&lt;/span&gt;&lt;font color=#000000&gt;.GetWebRequest(uri);
;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 4"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt;&lt;font color=#000000&gt; (requestPropertyInfo==&lt;/font&gt;&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;&lt;font color=#000000&gt;) 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 5"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;requestPropertyInfo
= request.GetType().GetProperty(&lt;/font&gt;&lt;span style="COLOR: red"&gt;"Request"&lt;/span&gt;&lt;font color=#000000&gt;); 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;HttpWebRequest
webRequest = (HttpWebRequest)requestPropertyInfo.GetValue(request,&lt;/font&gt;&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;&lt;font color=#000000&gt;); 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;webRequest.KeepAlive
= &lt;/font&gt;&lt;span style="COLOR: blue"&gt;false&lt;/span&gt;&lt;font color=#000000&gt;; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;webRequest.ProtocolVersion
=&amp;nbsp;System.Net.HttpVersion.Version10; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 4"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt;&lt;font color=#000000&gt; request; 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;
&lt;o:p&gt;
&lt;font color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;Once again, it worked fine during my WSE calls, but
failed when trying to use DIME attachments with the following error:&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;em&gt;&lt;strong&gt;found
response content 'application/dime', but expected 'text/xml'&lt;/strong&gt;&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;To save any readers some time, I will go through everything
I tried to resolve the problem, and finally, how I ended up resolving it. Here’s the
items which didn’t work:&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;-- tried setting the SoapActor&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;-- tried turning off the Document protocol&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;-- tried setting the request and return URI&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;-- tried overding the GetWebRequest function a few
different ways&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;-- tried using wsdl instead of asmx in setting up the
Web Reference&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;-- tried setting the URI target/destination seperately&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;-- moved web service to the same machine as the calling
web site (but still had to make an external call)&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;-- turned on tracing input and output and analyzed
the logs created by WSE 2.0&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;font face=Arial color=#000000&gt;So what finally worked? I ended up abandoning DIME,
and encoded the file as a string, and passed it as an element of my XML. Here’s the
code to encode the file as a string.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;o:p&gt;
&lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;///&lt;/span&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;///&lt;/span&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'"&gt; Encodes
the file in a Base64 string format.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;///&lt;/span&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/summary&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;///&lt;/span&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;param
name="file"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'"&gt;Name
of the file.&lt;/span&gt;&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;/param&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;///&lt;/span&gt;&lt;span style="COLOR: green; FONT-FAMILY: 'Courier New'"&gt; &lt;/span&gt;&lt;span style="COLOR: gray; FONT-FAMILY: 'Courier New'"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="COLOR: blue; FONT-FAMILY: 'Courier New'"&gt;private&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;font color=#000000&gt; EncodeFile(HtmlInputFile
file)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;try&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 2"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt;&lt;font color=#000000&gt; (file.PostedFile.ContentLength
&amp;gt; 0)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&lt;font color=#000000&gt;[]
fsBytes = &lt;/font&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&lt;font color=#000000&gt;[file.PostedFile.ContentLength];&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;System.IO.Stream
fileStream = file.PostedFile.InputStream;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;fileStream.Read(fsBytes,
0, file.PostedFile.ContentLength);&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 2"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt;&lt;font color=#000000&gt; Convert.ToBase64String(fsBytes);&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 2"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;else&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 3"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt;&lt;font color=#000000&gt; String.Empty;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 1"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;catch&lt;/span&gt;&lt;font color=#000000&gt; (Exception
ex)&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//Handle
the Error&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;span style="mso-tab-count: 2"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt;&lt;font color=#000000&gt; String.Empty;&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font color=#000000&gt;}&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;
&lt;o:p&gt;
&lt;font face=Arial color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;
&lt;span style="FONT-FAMILY: 'Courier New'"&gt;&lt;font face=Arial color=#000000&gt;What a trip
it was to get there, but the resulting service has performed well, and I don’t have
the issues I had with DIME. Don’t get me wrong, DIME worked great. But deployment
of the web service in a secure environment proved to be quite a challenge. If you
need more detail in resolving your issue, feel free to leave a comment or shoot me
an email, and I will be glad to save you some of the pain I had to go through!&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=85fc9c9c-5e1e-4b33-8873-86b05c0d443d" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,85fc9c9c-5e1e-4b33-8873-86b05c0d443d.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>Debugging</category>
      <category>General</category>
      <category>Web Services</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=a37ea5f6-5b2c-497c-b13c-cafeb5557e35</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,a37ea5f6-5b2c-497c-b13c-cafeb5557e35.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,a37ea5f6-5b2c-497c-b13c-cafeb5557e35.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a37ea5f6-5b2c-497c-b13c-cafeb5557e35</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Just a little tip, as I didn't read the error message generated as closely as I should
have. I was working this weekend on the Microsoft <a href="http://msdn.microsoft.com/asp.net/downloads/providers/">Code
Template for Building a Provider Based Feature</a> and was migrating some existing
libraries I had for VS2003 to take advantage of the features in VS2005. 
</p>
        <p>
First, let me say I love things in VS2005 like Generics, and the implementation of
the Provider Model. I was migrating my data access libraries and error handling libraries,
and was setting up some tests in nUnit as part of ongoing testing. Although I haven't
changed my data and error handling models in a long time, I figured it was a great
design idea to be able to change them dynamically using the Provider Model.
</p>
        <p>
To make a long story short, I was running my tests for the data library, and when
I invoked my Data Access classes, I was getting a "TypeInitializationException" error.
I checked and double-checked my configuration file, and it appeared to all be correct.
I looked at the InnerException, and it didn't seem to be much more help. <em>However</em>,
I went further to look at the InnerException of the InnerException, and there's where
I found the solution. The Rosetta Stone? 
</p>
        <ul>
          <li>
            <font color="#0000ff">Only one &lt;configSections&gt; element allowed per config file
and <strong>if present must be the first child of the root &lt;configuration&gt; element.</strong></font>
          </li>
        </ul>
        <p>
          <font color="#000000">A quick check indicated that I hadn't made the configSection
the first element. Doh!</font>
        </p>
        <p>
          <font color="#000000">So there are a few lessons to learn here. 1) Make sure
your configSections is first (normally not a problem, just a cut and paste issue here)
and 2) Make sure you dig <em>REAL</em> deep into the InnerExceptions for the details
and 3) the new Visualizers in vs2005 were too cool and very helpful. </font>
        </p>
        <p>
          <font color="#000000">Hats off to the VS2005 IDE team! It's spawned a few visualizers
I can think of, so if time permits in the future, I will be publishing those right
here!</font>
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a37ea5f6-5b2c-497c-b13c-cafeb5557e35" />
      </body>
      <title>VS2005 Provider Model and the config file</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,a37ea5f6-5b2c-497c-b13c-cafeb5557e35.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/03/14/VS2005ProviderModelAndTheConfigFile.aspx</link>
      <pubDate>Tue, 14 Mar 2006 17:52:31 GMT</pubDate>
      <description>&lt;p&gt;
Just a little tip, as I didn't read the error message generated as closely as I should
have. I was working this weekend on the Microsoft &lt;a href="http://msdn.microsoft.com/asp.net/downloads/providers/"&gt;Code
Template for Building a Provider Based Feature&lt;/a&gt;&amp;nbsp;and was migrating some existing
libraries I had for VS2003 to take advantage of the features in VS2005. 
&lt;/p&gt;
&lt;p&gt;
First, let me say I love things in VS2005 like Generics, and the implementation of
the Provider Model. I was migrating my data access libraries and error handling libraries,
and was setting up some tests in nUnit as part of ongoing testing. Although I haven't
changed my data and error handling models in a long time, I figured it was a great
design idea to be able to change them dynamically using the Provider Model.
&lt;/p&gt;
&lt;p&gt;
To make a long story short, I was running my tests for the data library, and when
I invoked my Data Access classes, I was getting a "TypeInitializationException" error.
I checked and double-checked my configuration file, and it appeared to all be correct.
I looked at the InnerException, and it didn't seem to be much more help. &lt;em&gt;However&lt;/em&gt;,
I went further to look at the InnerException of the InnerException, and there's where
I found the solution. The Rosetta Stone? 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;font color=#0000ff&gt;Only one &amp;lt;configSections&amp;gt; element allowed per config file
and &lt;strong&gt;if present must be the first child of the root &amp;lt;configuration&amp;gt; element.&lt;/strong&gt;&lt;/font&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;font color=#000000&gt;A quick check indicated that I hadn't made the configSection the
first element. Doh!&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;So there are a&amp;nbsp;few lessons to learn here. 1) Make sure your
configSections is first (normally not a problem, just a cut and paste issue here)
and 2) Make sure you dig &lt;em&gt;REAL&lt;/em&gt; deep into the InnerExceptions for the details
and 3) the new Visualizers in vs2005 were too cool and very helpful. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Hats off to the VS2005 IDE team! It's spawned a few visualizers
I can think of, so if time permits in the future, I will be publishing those right
here!&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a37ea5f6-5b2c-497c-b13c-cafeb5557e35" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,a37ea5f6-5b2c-497c-b13c-cafeb5557e35.aspx</comments>
      <category>All Things</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Debugging</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=0babb540-55a5-42f0-ba2c-448a60d9aae9</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,0babb540-55a5-42f0-ba2c-448a60d9aae9.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,0babb540-55a5-42f0-ba2c-448a60d9aae9.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0babb540-55a5-42f0-ba2c-448a60d9aae9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
At my current client, security is taken to a whole new level, which is a good thing.
But as a result, sometimes there is more of a challenge to resolve issues you may
not normally encounter. For example, I was tasked with writing a web service which
would facilitate file transfers of documents and images from a web page (and Windows
client), store them on a secured server, and serve them up to an authenticated user
on the internet. To do so, we have to deal with proxy server issues and firewall issues.
</p>
        <p>
After writing and testing the web service locally, I deployed it to our production
server. Locally, it all worked fine. However, when I deployed the web portion of the
application to our test server outside our intranet, the real fun began. The next
several posts I will discuss the problems I encountered, and how I ultimately resolved
the issue. Hopefully this will help any readers out there who have a similar issue,
as well as become documentation for the process I used so I can later reference it.
</p>
        <p>
The first issue I saw was the following error: 
</p>
        <p align="center">
          <em>
            <font color="#0000ff">The &lt;To&gt; header must match the value of an incoming
message's HTTP Request Url if the soap receiver does not have an actor name.</font>
          </em>
        </p>
        <p align="left">
          <font color="#000000">I'd love to give the person I found the solution at credit,
but it's been such a long time I can't find the original document I used. I modified
the solution to make it a little more "generic" so that the web service can be moved
without requiring a recompile of the application. </font>
        </p>
        <p align="left">
          <font color="#000000">First, you'll need to locate the Reference.cs file for the web
service reference(for C# users. Reference.vb is the similar file for VB.Net, but all
code here will be in C#). In this file, add the following reference:</font>
        </p>
        <p align="center">
          <font color="#0000ff">using Microsoft.Web.Services2.Addressing;</font>
        </p>
        <p align="left">
          <font color="#000000">Next, locate the consructor for the WSE portion of the Reference.cs.
In this case, mine will be <em>FileServiceWse().</em> Here's the code you'll need
to replace the this.Url reference already in there.</font>
        </p>
        <div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0pt; FONT-SIZE: 10pt; BACKGROUND: white; PADDING-BOTTOM: 0pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 0pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">public</span> FileServiceWse() 
</p>
          <p style="MARGIN: 0px">
        {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: green">//these
two setting are the &lt;TO&gt; and Response URLs. For example, in our case the response
was</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: green">//coming
back with the redirected port appended to the url.</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: green">//The
Web service &lt;TO&gt; looked like https://mycompany.com/FileService/FileService.asmx</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: green">//but
the response was https://mycompany.com:1234/FileService/FileService.asmx</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: green">//The
endpointreference call to the Destination tells the application to expect the return
url to look differently than the</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: green">//&lt;TO&gt;
reference</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">string</span> urlSetting
= System.Configuration.ConfigurationSettings.AppSettings[<span style="COLOR: red">"FileService"</span>];
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">string</span> urlReturnSetting
= System.Configuration.ConfigurationSettings.AppSettings[<span style="COLOR: red">"FileService.ReturnURL"</span>];
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">if</span> ((urlSetting
!= <span style="COLOR: blue">null</span>) &amp;&amp; (urlReturnSetting != <span style="COLOR: blue">null</span>)) 
</p>
          <p style="MARGIN: 0px">
            {
</p>
          <p style="MARGIN: 0px">
                Uri sourceUri
= <span style="COLOR: blue">new</span> Uri(urlSetting);
</p>
          <p style="MARGIN: 0px">
                Uri returnUri
= <span style="COLOR: blue">new</span> Uri(urlReturnSetting);
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">this</span>.Destination
= <span style="COLOR: blue">new</span> EndpointReference(sourceUri, returnUri);
</p>
          <p style="MARGIN: 0px">
            }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">else</span></p>
          <p style="MARGIN: 0px">
            {
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">if</span> ((urlSetting
!= <span style="COLOR: blue">null</span>)) 
</p>
          <p style="MARGIN: 0px">
                {
</p>
          <p style="MARGIN: 0px">
                    <span style="COLOR: blue">this</span>.Url
= <span style="COLOR: blue">string</span>.Concat(urlSetting, <span style="COLOR: red">""</span>);
</p>
          <p style="MARGIN: 0px">
                }
</p>
          <p style="MARGIN: 0px">
                <span style="COLOR: blue">else</span></p>
          <p style="MARGIN: 0px">
                {
</p>
          <p style="MARGIN: 0px">
                    <span style="COLOR: green">//this
is the default URL of the file service if all else fails.</span></p>
          <p style="MARGIN: 0px">
                    <span style="COLOR: blue">this</span>.Url
= <span style="COLOR: red">"https://mycompany.com/FileService/FileService.asmx"</span>;
</p>
          <p style="MARGIN: 0px">
                }
</p>
          <p style="MARGIN: 0px">
            }
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
        }
</p>
        </div>
        <p>
 
</p>
        <p>
What this code does is set the Destination property (if the <font color="#ff0000">FileService</font> and <font color="#ff0000">FileService.ReturnURL </font>settings
are placed in the web.config file) to expect a different response than the requested
web service URL. In our case, since our request was going through a firewall
which remapped the ports, we had a port attached to the url for our web service which
triggered this error.
</p>
        <p>
The code also has failover. If I forget to make the settings, it will try the original
URL reference. In my case the call won't work, but I believe in at least attempting
to code some failover when human error can take place in moving files, etc.
</p>
        <p>
But this only solved one of the many challenges I encountered in deploying
this web service. Stay tuned for the next resolution to tricky WSE issues!
</p>
        <p>
          <!--EndFragment-->
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0babb540-55a5-42f0-ba2c-448a60d9aae9" />
      </body>
      <title>Web Service Adventures - The &amp;lt;To&amp;gt; header must match the value of an incoming message's HTTP Request Url if the soap receiver does not have an actor name.</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,0babb540-55a5-42f0-ba2c-448a60d9aae9.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/03/09/WebServiceAdventuresTheLtTogtHeaderMustMatchTheValueOfAnIncomingMessagesHTTPRequestUrlIfTheSoapReceiverDoesNotHaveAnActorName.aspx</link>
      <pubDate>Thu, 09 Mar 2006 16:12:20 GMT</pubDate>
      <description>&lt;p&gt;
At my current client, security is taken to a whole new level, which is a good thing.
But as a result, sometimes there is more of a challenge to resolve issues you may
not normally encounter. For example, I was tasked with writing a web service which
would facilitate file transfers of documents and images from a web page (and Windows
client), store them on a secured server, and serve them up to an authenticated user
on the internet. To do so, we have to deal with proxy server issues and firewall issues.
&lt;/p&gt;
&lt;p&gt;
After writing and testing the web service locally, I deployed it to our production
server. Locally, it all worked fine. However, when I deployed the web portion of the
application to our test server outside our intranet, the real fun began. The next
several posts I will discuss the problems I encountered, and how I ultimately resolved
the issue. Hopefully this will help any readers out there who have a similar issue,
as well as become documentation for the process I used so I can later reference it.
&lt;/p&gt;
&lt;p&gt;
The first issue I saw was the following error: 
&lt;/p&gt;
&lt;p align=center&gt;
&lt;em&gt;&lt;font color=#0000ff&gt;The &amp;lt;To&amp;gt; header must match the value of an incoming
message's HTTP Request Url if the soap receiver does not have an actor name.&lt;/font&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;p align=left&gt;
&lt;font color=#000000&gt;I'd love to give the person I found the solution&amp;nbsp;at credit,
but it's been such a long time I can't find the original document&amp;nbsp;I used. I modified
the solution to make it a little more "generic" so that the web service can be moved
without requiring a recompile of the application. &lt;/font&gt;
&lt;/p&gt;
&lt;p align=left&gt;
&lt;font color=#000000&gt;First, you'll need to locate the Reference.cs file for the web
service reference(for C# users. Reference.vb is the similar file for VB.Net, but all
code here will be in C#). In this file, add the following reference:&lt;/font&gt;
&lt;/p&gt;
&lt;p align=center&gt;
&lt;font color=#0000ff&gt;using Microsoft.Web.Services2.Addressing;&lt;/font&gt;
&lt;/p&gt;
&lt;p align=left&gt;
&lt;font color=#000000&gt;Next, locate the consructor for the WSE portion of the Reference.cs.
In this case, mine will be &lt;em&gt;FileServiceWse().&lt;/em&gt; Here's the code you'll need
to replace the this.Url reference already in there.&lt;/font&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0pt; FONT-SIZE: 10pt; BACKGROUND: white; PADDING-BOTTOM: 0pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 0pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; FileServiceWse() 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//these
two setting are the &amp;lt;TO&amp;gt; and Response URLs. For example, in our case the response
was&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//coming
back with the redirected port appended to the url.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//The
Web service &amp;lt;TO&amp;gt; looked like https://mycompany.com/FileService/FileService.asmx&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//but
the response was https://mycompany.com:1234/FileService/FileService.asmx&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//The
endpointreference call to the Destination tells the application to expect the return
url to look differently than the&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//&amp;lt;TO&amp;gt;
reference&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; urlSetting
= System.Configuration.ConfigurationSettings.AppSettings[&lt;span style="COLOR: red"&gt;"FileService"&lt;/span&gt;];
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; urlReturnSetting
= System.Configuration.ConfigurationSettings.AppSettings[&lt;span style="COLOR: red"&gt;"FileService.ReturnURL"&lt;/span&gt;];
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; ((urlSetting
!= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;) &amp;amp;&amp;amp; (urlReturnSetting != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)) 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Uri sourceUri
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; Uri(urlSetting);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Uri returnUri
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; Uri(urlReturnSetting);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Destination
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; EndpointReference(sourceUri, returnUri);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; ((urlSetting
!= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)) 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Url
= &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;.Concat(urlSetting, &lt;span style="COLOR: red"&gt;""&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//this
is the default URL of the file service if all else fails.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.Url
= &lt;span style="COLOR: red"&gt;"https://mycompany.com/FileService/FileService.asmx"&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
What this code does is set the Destination property (if the &lt;font color=#ff0000&gt;FileService&lt;/font&gt; and &lt;font color=#ff0000&gt;FileService.ReturnURL &lt;/font&gt;settings
are placed in the web.config file) to expect a different response than the requested
web service URL. In our case, since&amp;nbsp;our request&amp;nbsp;was going through a firewall
which remapped the ports, we had a port attached to the url for our web service which
triggered this error.
&lt;/p&gt;
&lt;p&gt;
The code also has failover. If I forget to make the settings, it will try the original
URL reference. In my case the call won't work, but I believe in at least attempting
to code some failover when human error can take place in moving files, etc.
&lt;/p&gt;
&lt;p&gt;
But this only solved one of the many&amp;nbsp;challenges&amp;nbsp;I encountered in deploying
this web service. Stay tuned for the next resolution to tricky WSE issues!
&lt;/p&gt;
&lt;p&gt;
&lt;!--EndFragment--&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0babb540-55a5-42f0-ba2c-448a60d9aae9" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,0babb540-55a5-42f0-ba2c-448a60d9aae9.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>General</category>
      <category>Web Services</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=3ccf5eec-36d6-4c45-b34b-18ba2705c042</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,3ccf5eec-36d6-4c45-b34b-18ba2705c042.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,3ccf5eec-36d6-4c45-b34b-18ba2705c042.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3ccf5eec-36d6-4c45-b34b-18ba2705c042</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It's not a record for longest time between posts, but it sure has been a while. I
finlly got off my butt and upgraded das Blog to the latest version, and enabled comments
again. So now maybe it will be worthwhile to begin blogging again!
</p>
        <p>
The past few months have been interesting to say the least. I have a catalog of things
to post about, such as solving some bizarre web service issues with DIME (well, solution
is not quite the word... a workaround is more like it) as well as beginning the trek
into VS2005.
</p>
        <p>
So if there's anyone still out there readin this, I do have a ton to write about,
now lets see if I can find the time to do it!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=3ccf5eec-36d6-4c45-b34b-18ba2705c042" />
      </body>
      <title>Not a record, but....</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,3ccf5eec-36d6-4c45-b34b-18ba2705c042.aspx</guid>
      <link>http://www.dotnettechnologies.com/2006/03/09/NotARecordBut.aspx</link>
      <pubDate>Thu, 09 Mar 2006 04:52:50 GMT</pubDate>
      <description>&lt;p&gt;
It's not a record for longest time between posts, but it sure has been a while. I
finlly got off my butt and upgraded das Blog to the latest version, and enabled comments
again. So now maybe it will be worthwhile to begin blogging again!
&lt;/p&gt;
&lt;p&gt;
The past few months have been interesting to say the least. I have a catalog of things
to post about, such as solving some bizarre web service issues with DIME (well, solution
is not quite the word... a workaround is more like it) as well as beginning the trek
into VS2005.
&lt;/p&gt;
&lt;p&gt;
So if there's anyone still out there readin this, I do have a ton to write about,
now lets see if I can find the time to do it!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=3ccf5eec-36d6-4c45-b34b-18ba2705c042" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,3ccf5eec-36d6-4c45-b34b-18ba2705c042.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=7102e2b7-c6d6-4344-b524-367a47224330</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,7102e2b7-c6d6-4344-b524-367a47224330.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,7102e2b7-c6d6-4344-b524-367a47224330.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7102e2b7-c6d6-4344-b524-367a47224330</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I just had to comment on this. First, the article: <a href="http://www.informationweek.com/story/showArticle.jhtml?articleID=174901240" target="_blank">http://www.informationweek.com/story/showArticle.jhtml?articleID=174901240</a> 
</p>
        <p>
A guy's XBox 360 fails, so he files a class action lawsuit. What the heck ever happened
to RETURNING THE UNIT? I guess this loser (IMHO) can't be faulted. For years we've
been blitzed by the legal community that someone has to be blamed. And in assigning
that blame, there has to some monetary penalties for it. And when states get involved,
it actually becomes a new form of “taxation“ in order to generate additional
reveneues.
</p>
        <p>
Want examples? Just look at all the antitrust legislation against MS. Just look at
the lawsuits and huge penalties against tobacco companies. Cigarette packages have
all kinds of warnings on them (and have for a LONG time) to the point they might
as well have a skull and crossbones emblem on them, a la poison. Yet, states and individuals
lined up to get cash from them. Take a look at <a href="http://www.overlawyered.com/" target="_blank">http://www.overlawyered.com</a> if
you want plenty of things to get your blood pressure up. 
</p>
        <p>
But back to the original point. If the unit wasn't working, do what we did for years.
TAKE IT BACK. If you don't think MS has a good unit, BUY THE COMPETITOR'S UNIT. Pretty
simple. It worked for years. I wish he could be counter-sued if he loses. And I hope
like hell he does. I have no great love of MS these days because I think they have
turned on the development community to a degree, but still, fair is fair.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7102e2b7-c6d6-4344-b524-367a47224330" />
      </body>
      <title>It's the end of the world as we know it....</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,7102e2b7-c6d6-4344-b524-367a47224330.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/12/09/ItsTheEndOfTheWorldAsWeKnowIt.aspx</link>
      <pubDate>Fri, 09 Dec 2005 22:01:47 GMT</pubDate>
      <description>&lt;p&gt;
I just had to comment on this. First, the article: &lt;a href="http://www.informationweek.com/story/showArticle.jhtml?articleID=174901240" target=_blank&gt;http://www.informationweek.com/story/showArticle.jhtml?articleID=174901240&lt;/a&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
A guy's XBox 360 fails, so he files a class action lawsuit. What the heck ever happened
to RETURNING THE UNIT? I guess this loser (IMHO) can't be faulted. For years we've
been blitzed by the legal community that someone has to be blamed. And in assigning
that blame, there has to some monetary penalties for it. And when states get involved,
it actually becomes a new form of &amp;#8220;taxation&amp;#8220; in order to generate additional
reveneues.
&lt;/p&gt;
&lt;p&gt;
Want examples? Just look at all the antitrust legislation against MS. Just look at
the lawsuits and huge penalties against tobacco companies. Cigarette packages have
all kinds of warnings on them (and have for&amp;nbsp;a LONG time) to the point they might
as well have a skull and crossbones emblem on them, a la poison. Yet, states and individuals
lined up to get cash from them. Take a look at &lt;a href="http://www.overlawyered.com/" target=_blank&gt;http://www.overlawyered.com&lt;/a&gt;&amp;nbsp;if
you want plenty of things to get your blood pressure up. 
&lt;/p&gt;
&lt;p&gt;
But back to the original point. If the unit wasn't working, do what we did for years.
TAKE IT BACK. If you don't think MS has a good unit, BUY THE COMPETITOR'S UNIT. Pretty
simple. It worked for years. I wish he could be counter-sued if he loses. And I hope
like hell he does. I have no great love of MS these days because I think they have
turned on the development community to a degree, but still, fair is fair.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7102e2b7-c6d6-4344-b524-367a47224330" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,7102e2b7-c6d6-4344-b524-367a47224330.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=5876a92e-efe9-4698-ab08-cf57d4ed2112</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,5876a92e-efe9-4698-ab08-cf57d4ed2112.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,5876a92e-efe9-4698-ab08-cf57d4ed2112.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5876a92e-efe9-4698-ab08-cf57d4ed2112</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Lucida Sans Typewriter" color="#000000">A year ago, I completed my MCSD
for .Net. One of the attractive<br />
benefits of this certification (as well as the MCDBA) was a $500<br />
discount on a one-year MSDN Universal subscription during the first<br />
year of certification.<br /><br />
Although the MCSD benefits page still lists this benefit<br />
(</font>
          <a href="http://www.microsoft.com/learning/mcp/mcsd/benefits.asp" target="_blank">
            <font face="Lucida Sans Typewriter" color="#9136ad">http://www.microsoft.com/learning/mcp/mcsd/benefits.asp</font>
          </a>
          <font face="Lucida Sans Typewriter" color="#000000">),
they<br />
quietly removed it as of April 2005. The text on the page still<br />
states the following:<br />
Rebates or discounts on a one-year subscription to MSDN during the<br />
first year of certification.<br /><br />
If you call or write to get the certificate as I did, you'll get the<br />
terse response it's no longer available, and they just haven't<br />
updated the site. I figured I would help them get the word out since<br />
they didn't deem it important enough to change on their site or<br />
announce. It would be a shame if anyone expected this benefit based<br />
on the MS web site information.</font>
        </p>
        <p>
-------------------------------------------------------------------------
</p>
        <p>
Above is what I posted to our local .Net community group on Yahoo. Now I am going
to add some personal comments. Once again, MS has dropped the ball in supporting the
developer community. Earlier this year, MS announced the MSDN Universal would not
include the new .Net Team Development system (or some name like that -- I am too lazy
to go look it up). Fortunately, enough of an uproar went out that they reversed that
decision. Their waning support of VB also caused a petition/uproar. Likely, since
the MCSD/MCDBA community is a lot smaller, there isn't likely to be a huge outcry
on this issue.
</p>
        <p>
This is a HUGE mistake on MS's behalf. Someone that is likely to spend the extra time
and money to get certifications are the ones MS should really cater to. There's always
been a criticism that the certifications are worthless, and that benefit alone
made it real easy to justify spending the money on books, training materials and exam
costs for achieving the certification. I won't argue the merits of the certifications
here, but I have a lot of them -- MCP, MCDBA, MCSD for VB, MCSD for .Net (C#), and
MCAD. Will I continue? I may have to given I am an Independent Contractor and it helps
to get me in the door. Will I recommend it to someone not in my position? Not likely.
</p>
        <p>
Don't get me wrong, the MSDN Universal is still a great deal. My disgust over this
situation is that the benefit is <strong>still</strong> listed, as well as no announcement
in April 2005 when they made this decision (or if they did, I sure didn't see it).
I have been one of the most stalwart supporters of Microsoft over the years,
and I have personally been involved in projects which have generated millions in
licensing revenues for Microsoft in the last 10 years. The past 1.5 years I have watched
MS anger the core base of developers.
</p>
        <p>
I think this is indicative of the internal problems at MS, and why Google is going
to be a viable competitor to MS. In a paraphrase of the words of Stephen King, and
the Dark Tower series, MS has forgotten the face of their father. One of the reasons
MS dominated the market over Apple was that MS supported developers way beyond the
norm. In the name of profit, I think we are seeing this slowly change.<br /></p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=5876a92e-efe9-4698-ab08-cf57d4ed2112" />
      </body>
      <title>MSDN Universal Discount for MCSD/MCDBA </title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,5876a92e-efe9-4698-ab08-cf57d4ed2112.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/10/07/MSDNUniversalDiscountForMCSDMCDBA.aspx</link>
      <pubDate>Fri, 07 Oct 2005 15:57:27 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face="Lucida Sans Typewriter" color=#000000&gt;A year ago, I completed my MCSD
for .Net. One of the attractive&lt;br&gt;
benefits of this certification (as well as the MCDBA) was a $500&lt;br&gt;
discount on a one-year MSDN Universal subscription during the first&lt;br&gt;
year of certification.&lt;br&gt;
&lt;br&gt;
Although the MCSD benefits page still lists this benefit&lt;br&gt;
(&lt;/font&gt;&lt;a href="http://www.microsoft.com/learning/mcp/mcsd/benefits.asp" target=_blank&gt;&lt;font face="Lucida Sans Typewriter" color=#9136ad&gt;http://www.microsoft.com/learning/mcp/mcsd/benefits.asp&lt;/font&gt;&lt;/a&gt;&lt;font face="Lucida Sans Typewriter" color=#000000&gt;),
they&lt;br&gt;
quietly removed it as of April 2005. The text on the page still&lt;br&gt;
states the following:&lt;br&gt;
Rebates or discounts on a one-year subscription to MSDN during the&lt;br&gt;
first year of certification.&lt;br&gt;
&lt;br&gt;
If you call or write to get the certificate as I did, you'll get the&lt;br&gt;
terse response it's no longer available, and they just haven't&lt;br&gt;
updated the site. I figured I would help them get the word out since&lt;br&gt;
they didn't deem it important enough to change on their site or&lt;br&gt;
announce. It would be a shame if anyone expected this benefit based&lt;br&gt;
on the MS web site information.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
-------------------------------------------------------------------------
&lt;/p&gt;
&lt;p&gt;
Above is what I posted to our local .Net community group on Yahoo. Now I am going
to add some personal comments. Once again, MS has dropped the ball in supporting the
developer community. Earlier this year, MS announced the MSDN Universal would not
include the new .Net Team Development system (or some name like that -- I am too lazy
to go look it up). Fortunately, enough of an uproar went out that they reversed that
decision. Their waning support of VB also caused a petition/uproar. Likely, since
the MCSD/MCDBA&amp;nbsp;community is a lot smaller, there isn't likely to be a huge outcry
on this issue.
&lt;/p&gt;
&lt;p&gt;
This is a HUGE mistake on MS's behalf. Someone that is likely to spend the extra time
and money to get certifications are the ones MS should really cater to. There's always
been a criticism that the certifications are worthless, and that benefit&amp;nbsp;alone
made it real easy to justify spending the money on books, training materials and exam
costs for achieving the certification. I won't argue the merits of the certifications
here, but I have a lot of them -- MCP, MCDBA, MCSD for VB, MCSD for .Net (C#), and
MCAD. Will I continue? I may have to given I am an Independent Contractor and it helps
to get me in the door. Will I recommend it to someone not in my position? Not likely.
&lt;/p&gt;
&lt;p&gt;
Don't get me wrong, the MSDN Universal is still a great deal. My disgust over this
situation is that the benefit is &lt;strong&gt;still&lt;/strong&gt; listed, as well as no announcement
in April 2005 when they made this decision (or if they did, I sure didn't see it).
I have&amp;nbsp;been one of the most stalwart supporters of Microsoft over the years,
and I have personally been involved in projects which have generated millions&amp;nbsp;in
licensing revenues for Microsoft in the last 10 years. The past 1.5 years I have watched
MS anger the core base of developers.
&lt;/p&gt;
&lt;p&gt;
I think this is indicative of the internal problems at MS, and why Google is going
to be a viable competitor to MS. In a paraphrase of the words of Stephen King, and
the Dark Tower series, MS has forgotten the face of their father. One of the reasons
MS dominated the market over Apple was that MS supported developers way beyond the
norm. In the name of profit, I think we are seeing this slowly change.&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=5876a92e-efe9-4698-ab08-cf57d4ed2112" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,5876a92e-efe9-4698-ab08-cf57d4ed2112.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
      <category>VB.Net</category>
      <category>Windows</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=42aee519-178f-4c39-a2d0-0318ad74be2b</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,42aee519-178f-4c39-a2d0-0318ad74be2b.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,42aee519-178f-4c39-a2d0-0318ad74be2b.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=42aee519-178f-4c39-a2d0-0318ad74be2b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Once again I have disappeared from blogging. Let's face it, I rarely get to do it.
I also need to upgrade this DasBlog but I have been so busy I haven't been able to
do that, even though someone kindly wrote me and told me it would solve my spam comment
problem. Maybe this weekend...
</p>
        <p>
But I wanted to blog because I found a weird problem, with a weirder solution. I wrote
a Windows service in C# which periodically loads some data, based on the time since
the last load. So dates are a bit important in this process.
</p>
        <p>
First, the cryptic message: “<font color="#191970">Internal Query Processor
Error: The query processor could not produce a query plan. Contact your primary support
provider for more information</font>”.  A Google search turned up several
solutions, but most of them relied on a service patch. What's wierder is that the
error was intermittant. The procs would run fine in Query Analyzer, but not from
C#.
</p>
        <p>
Finally, I tried the unlikely. Instead of passing in my parameters as  DateTime
values, I passed them in as SqlDbType.Varchar, and in the proc made sure and converted
them to DateTime values. Lo and behold, the problem went away.....Go figure!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=42aee519-178f-4c39-a2d0-0318ad74be2b" />
      </body>
      <title>Bizarre error, bizarre solution...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,42aee519-178f-4c39-a2d0-0318ad74be2b.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/09/20/BizarreErrorBizarreSolution.aspx</link>
      <pubDate>Tue, 20 Sep 2005 22:50:34 GMT</pubDate>
      <description>&lt;p&gt;
Once again I have disappeared from blogging. Let's face it, I rarely get to do it.
I also need to upgrade this DasBlog but I have been so busy I haven't been able to
do that, even though someone kindly wrote me and told me it would solve my spam comment
problem. Maybe this weekend...
&lt;/p&gt;
&lt;p&gt;
But I wanted to blog because I found a weird problem, with a weirder solution. I wrote
a Windows service in C# which periodically loads some data, based on the time since
the last load. So dates are a bit important in this process.
&lt;/p&gt;
&lt;p&gt;
First, the cryptic message: &amp;#8220;&lt;font color=#191970&gt;Internal Query Processor Error:
The query processor could not produce a query plan. Contact your primary support provider
for more information&lt;/font&gt;&amp;#8221;.&amp;nbsp; A Google search turned up several solutions,
but most of them relied on a service patch. What's wierder is that the error was intermittant.&amp;nbsp;The
procs would run fine in Query Analyzer, but not from C#.
&lt;/p&gt;
&lt;p&gt;
Finally, I tried the unlikely. Instead of passing in my parameters as&amp;nbsp;&amp;nbsp;DateTime
values, I passed them in as SqlDbType.Varchar, and in the proc made sure and converted
them to DateTime values. Lo and behold, the problem went away.....Go figure!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=42aee519-178f-4c39-a2d0-0318ad74be2b" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,42aee519-178f-4c39-a2d0-0318ad74be2b.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
      <category>VB.Net</category>
      <category>Windows</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=0daedfad-25eb-4be1-a1cc-4f67de0b6619</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,0daedfad-25eb-4be1-a1cc-4f67de0b6619.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,0daedfad-25eb-4be1-a1cc-4f67de0b6619.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0daedfad-25eb-4be1-a1cc-4f67de0b6619</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I like poker. A lot. However, I don't like spam. A lot. Unfortunately the poker spammers
have hijacked my blog comments. So until I upgrade my dasblog or come up with another
solution, I am going to have to turn off comments. I am likely going to have time
this weekend to resolve it, and possibly even start posting again as I think I have
finished some of the side work I was working on. In the meantime, if anyone reading
this want to post a comment, email me at daryl at rubiconcomputing.com and I will
post it for you. Grrr.....
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0daedfad-25eb-4be1-a1cc-4f67de0b6619" />
      </body>
      <title>Finally caught up to me...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,0daedfad-25eb-4be1-a1cc-4f67de0b6619.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/08/05/FinallyCaughtUpToMe.aspx</link>
      <pubDate>Fri, 05 Aug 2005 13:33:34 GMT</pubDate>
      <description>&lt;p&gt;
I like poker. A lot. However, I don't like spam. A lot. Unfortunately the poker spammers
have hijacked my blog comments. So until I upgrade my dasblog or come up with another
solution, I am going to have to turn off comments. I am likely going to have time
this weekend to resolve it, and possibly even start posting again as I think I have
finished some of the side work I was working on. In the meantime, if anyone reading
this want to post a comment, email me at daryl at rubiconcomputing.com and I will
post it for you. Grrr.....
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0daedfad-25eb-4be1-a1cc-4f67de0b6619" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,0daedfad-25eb-4be1-a1cc-4f67de0b6619.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=303d10f5-f6ad-43aa-b22c-35d4768481da</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,303d10f5-f6ad-43aa-b22c-35d4768481da.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,303d10f5-f6ad-43aa-b22c-35d4768481da.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=303d10f5-f6ad-43aa-b22c-35d4768481da</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
OK, time for a little fairness in the world. When I wrote my blog entry on Monday,
I was certainly frustrated with LLBLGen. Franz Bouma has responded to my comments
about LLBLGen (little did I know I had such illustrious visitors!). So in fairness,
I want to make sure anyone out there reading my blog sees those comments so they can
see both sides of the review and form opinions on more than just my emotional outbursts,
and my semi-apology for blogging while frustrated. :)
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=303d10f5-f6ad-43aa-b22c-35d4768481da" />
      </body>
      <title>See the LLBLGen comments from July 18th...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,303d10f5-f6ad-43aa-b22c-35d4768481da.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/07/20/SeeTheLLBLGenCommentsFromJuly18th.aspx</link>
      <pubDate>Wed, 20 Jul 2005 20:31:12 GMT</pubDate>
      <description>&lt;p&gt;
OK, time for a little fairness in the world. When I wrote my blog entry on Monday,
I was certainly frustrated with LLBLGen. Franz Bouma has responded to my comments
about LLBLGen (little did I know I had such illustrious visitors!). So in fairness,
I want to make sure anyone out there reading my blog sees those comments so they can
see both sides of the review and form opinions on more than just my emotional outbursts,
and my semi-apology for blogging while frustrated. :)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=303d10f5-f6ad-43aa-b22c-35d4768481da" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,303d10f5-f6ad-43aa-b22c-35d4768481da.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=9884adf4-7314-4f4e-a5d5-e2855a819af8</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,9884adf4-7314-4f4e-a5d5-e2855a819af8.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,9884adf4-7314-4f4e-a5d5-e2855a819af8.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9884adf4-7314-4f4e-a5d5-e2855a819af8</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have tons I need to blog about but no time to do it, as once again I am up to my
head in projects. So this entry is going to be to vent....
</p>
        <p>
One of my current clients is requiring me to use a product called LLBLGen Pro (see
it at <a href="http://www.llblgen.com/" target="_blank">http://www.llblgen.com</a>).
I am certain it's a powerful product, and while it generates enough code to make a
COBOL program to look efficient, it seems to perform OK, although my gut tells me
this thing would be a pig in a high-demand environment. But here's my gripe -- the
documentation is <em>horrendous</em>. I have spent at least 50 hours trying to get
this thing to generate code effectively as well as consistantly. And even then, I
don't understand a tenth of what's generated. I understand enough to make minor changes,
and after a lot of wrestling, I can finally get it to generate code. OK, 50 hours
may not seem like a lot to learn a new paradigm which might reap a lot of benefits
later, but let me tell you what that 50 hours (billable to my client, I might add,
since I begged them after 10 hours to scrap it) bought you. I managed to add 2 fields
to a table, and add two tables. The two new table still don't work right. 
</p>
        <p>
Let's put that into perspective. First, I code lightning fast. Not spaghetti code
mind you, but robust code which typically is right the first time. In that 50 hours,
I could have re-written a good chunk of the app, and believe me, it needs it. Fortunately,
I did my consultant's duty to bring that point up. It would have taken me three hours
tops to make the changes which we are looking at 50 hours and still not working.  
</p>
        <p>
Second, the code is difficult to read at best. The project has fallen behind because
of the insistance we use this tool, so they brought on two other developers. Guess
what, they are having the same problems. They have spent two solid days now, and not
one line of code written. Using standard objects, any developer with experience in
.Net can peruse the object model quickly and begin coding. Not with this tool!
</p>
        <p>
You can't compare CodeSmith, which I have praised before, with LLBLGen. LLBLGen is
far more sophisticated, unfortunately to the point of being unusable. I know there
are a few people who swear by it, and that's great, but I get paid to come in and
make a difference fast, and LLBLGen has proven to be more an expensive hindrance than
a solution.
</p>
        <p>
OK, that's the end of the vent. I have been deploying some web services for another
client, and once we have everything debugged, I have a ton of tips related to web
services and deployment which I promise will save a ton of hours to other developers
entering into this domain. Until then!
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9884adf4-7314-4f4e-a5d5-e2855a819af8" />
      </body>
      <title>When code generation goes bad....</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,9884adf4-7314-4f4e-a5d5-e2855a819af8.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/07/19/WhenCodeGenerationGoesBad.aspx</link>
      <pubDate>Tue, 19 Jul 2005 04:49:51 GMT</pubDate>
      <description>&lt;p&gt;
I have tons I need to blog about but no time to do it, as once again I am up to my
head in projects. So this entry is going to be to vent....
&lt;/p&gt;
&lt;p&gt;
One of my current clients is requiring me to use a product called LLBLGen Pro (see
it at &lt;a href="http://www.llblgen.com/" target=_blank&gt;http://www.llblgen.com&lt;/a&gt;).
I am certain it's a powerful product, and while it generates enough code to make a
COBOL program to look efficient, it seems to perform OK, although my gut tells me
this thing would be a pig in a high-demand environment. But here's my gripe -- the
documentation is &lt;em&gt;horrendous&lt;/em&gt;. I have spent at least 50 hours trying to get
this thing to generate code effectively as well as consistantly. And even then, I
don't understand a tenth of what's generated. I understand enough to make minor changes,
and after a lot of wrestling, I can finally get it to generate code. OK, 50 hours
may not seem like a lot to learn a new paradigm which might reap a lot of benefits
later, but let me tell you what that 50 hours (billable to my client, I might add,
since I begged them after 10 hours to scrap it) bought you. I managed to add 2 fields
to a table, and add two tables. The two new table still don't work right. 
&lt;/p&gt;
&lt;p&gt;
Let's put that into perspective. First, I code lightning fast. Not spaghetti code
mind you, but robust code which typically is right the first time. In that 50 hours,
I could have re-written a good chunk of the app, and believe me, it needs it. Fortunately,
I did my consultant's duty to bring that point up.&amp;nbsp;It would have taken me three&amp;nbsp;hours
tops to make the changes which we are looking at 50 hours and still not working.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Second, the code is difficult to read at best. The project has fallen behind because
of the insistance we use this tool, so they brought on two other developers. Guess
what, they are having the same problems. They have spent two solid days now, and not
one line of code written. Using standard objects, any developer with experience in
.Net can peruse the object model quickly and begin coding. Not with this tool!
&lt;/p&gt;
&lt;p&gt;
You can't compare CodeSmith, which I have praised before, with LLBLGen. LLBLGen is
far more sophisticated, unfortunately to the point of being unusable. I know there
are a few people who swear by it, and that's great, but I get paid to come in and
make a difference fast, and LLBLGen has proven to be more an expensive hindrance than
a solution.
&lt;/p&gt;
&lt;p&gt;
OK, that's the end of the vent. I have been deploying some web services for another
client, and once we have everything debugged, I have a ton of tips related to web
services and deployment which I promise will save a ton of hours to other developers
entering into this domain. Until then!
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9884adf4-7314-4f4e-a5d5-e2855a819af8" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,9884adf4-7314-4f4e-a5d5-e2855a819af8.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Design</category>
      <category>General</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=faefbcf2-c211-4893-820b-0aaab66e31be</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,faefbcf2-c211-4893-820b-0aaab66e31be.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,faefbcf2-c211-4893-820b-0aaab66e31be.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=faefbcf2-c211-4893-820b-0aaab66e31be</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Extremes in anything (IMHO) are typically not good. Extreme temperatures, religeons,
attitudes -- you name it, likely there is a downside. In programming, it's no different.
Now, while not a big fan of Extreme Programming, there's a couple of extremes from
it that bother me. One is that you shouldn't include documentation. The other, which
I suspect  was someone's personal preference, was not to use the “Region”
directives in C# (or I guess VB.Net either). Here's a little history...
</p>
        <p>
This guy was a former Java programmer working for a large chip manufacturer. He was
supposed to be a XP guru, so he was transferred to the local site to help a team in
it's transition to the XP methodology. 
</p>
        <p>
Strike 1 -- he knew the methodology well, but he was by no means an expert in the
language of the group. Why was this a strike? I guess technological bias in that his
preferences to his other language directed him to want to make the .Net environment
the same as a java environment. 
</p>
        <p>
Strike 2 -- It was his way or the highway. The environment was such that one or two
developers had 95% of the say on development decisions. Part of the reason for this
is that wacky trend in which everyone is ranked from best to worst in terms of raises,
options and promotion (for more info what I am talking about, read this article, which
is the same process -- <a href="http://www.sqlservercentral.com/newsletter/view_newsletter.asp?dt=5/26/2005" target="_blank">Saying
Goodbye</a>). No one would ever argue with the two for fear of getting a bad ranking
for being considered a troublemaker.
</p>
        <p>
Regardless, I digress, but I do think it's important to understand why sometimes these
extremes come about in an environment. I was a contractor brought on to bring some
quick wins for a project, and it was my first (and likely last) venture into the XP
methodology. They needed code, and they needed it fast. 
</p>
        <p>
One problem I addressed was the lack of uniformity on the project. We had three developers,
which meant three different styles of programming. Even with XP, that meant one of
us was alone, and the other two would spend the pair time arguning over which style
was a standard and best (even though standards existed -- they were just never used
because of informal rules imposed by the 2 'chiefs'). I decided to create a template
which would standardize (and speed up) our development. I organized the code within
the controls into regions, and deployed them onto our machines with anticipation I
easily saved our team15-20 minutes each time we created a new control.
</p>
        <p>
Alas, it was scrapped instantly. Why? Well, it seems in my templates, I placed the
code into logical “regions” -- e.g. Public Properties, Public Methods,
Private Methods, etc. I was “informed” (even though I had been using regions
for a couple of months now) that regions were not allowed, because all they did was
hide bad code. WHAT???!! Well, I liked the contract, and knew the results if I stood
up to them, so I bit my tongue and moved on. It has bothered me ever since, but I
never took the time to formulate an argument as to why regions are actually a good
idea. 
</p>
        <p>
Why bring this up today after a year has passed? Well, I was coding something, and
the constructor was hidden by a region. I was thinking “Hmm, if we just left
the constructors out of regions, it would be easy to read, because the regions would
hide the internal implementations I don't care about, yet at a glance I can see how
to instantiate the object” (hmm, I think they call that encapsulation) and use
it. Now that right there justifies the use of regions alone.... I can actually think
of a lot of reasons to use regions, and I do it religeously where my client has no
opition about it. 
</p>
        <p>
Just a flashback from the past.... anyone got a counter opinion? Regardless, it just
goes to show extreme anything typically isn't a good thing in my mind. You have to
be flexible in your approach to life if you plan on growing...
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=faefbcf2-c211-4893-820b-0aaab66e31be" />
      </body>
      <title>It just occurred to me...why extremes are bad in programming</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,faefbcf2-c211-4893-820b-0aaab66e31be.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/05/27/ItJustOccurredToMewhyExtremesAreBadInProgramming.aspx</link>
      <pubDate>Fri, 27 May 2005 17:28:46 GMT</pubDate>
      <description>&lt;p&gt;
Extremes in anything (IMHO) are typically not good. Extreme temperatures, religeons,
attitudes -- you name it, likely there is a downside. In programming, it's no different.
Now, while not a big fan of Extreme Programming, there's a couple of extremes from
it that bother me. One is that you shouldn't include documentation. The other, which
I suspect&amp;nbsp; was someone's personal preference, was not to use the &amp;#8220;Region&amp;#8221;
directives in C# (or I guess VB.Net either). Here's a little history...
&lt;/p&gt;
&lt;p&gt;
This guy was a former Java programmer working for a large chip manufacturer. He was
supposed to be a XP guru, so he was transferred to the local site to help a team in
it's transition to the XP methodology. 
&lt;/p&gt;
&lt;p&gt;
Strike 1 -- he knew the methodology well, but he was by no means an expert in the
language of the group. Why was this a strike? I guess technological bias in that his
preferences to his other language directed him to want to make the .Net environment
the same as a java environment. 
&lt;/p&gt;
&lt;p&gt;
Strike 2 -- It was his way or the highway. The environment was such that one or two
developers had 95% of the say on development decisions. Part of the reason for this
is that wacky trend in which everyone is ranked from best to worst in terms of raises,
options and promotion (for more info what I am talking about, read this article, which
is the same process -- &lt;a href="http://www.sqlservercentral.com/newsletter/view_newsletter.asp?dt=5/26/2005" target=_blank&gt;Saying
Goodbye&lt;/a&gt;). No one would ever argue with the two for fear of getting a bad ranking
for being considered a troublemaker.
&lt;/p&gt;
&lt;p&gt;
Regardless, I digress, but I do think it's important to understand why sometimes these
extremes come about in an environment. I was a contractor brought on to bring some
quick wins for a project, and it was my first (and likely last) venture into the XP
methodology. They needed code, and they needed it fast. 
&lt;/p&gt;
&lt;p&gt;
One problem I addressed was the lack of uniformity on the project. We had three developers,
which meant three different styles of programming. Even with XP, that meant one of
us was alone, and the other two would spend the pair time arguning over which style
was a standard and best (even though standards existed -- they were just never used
because of informal rules imposed by the 2 'chiefs'). I decided to create a template
which would standardize (and speed up) our development. I organized the code within
the controls into regions, and deployed them onto our machines with anticipation I
easily saved our team15-20 minutes each time we created a new control.
&lt;/p&gt;
&lt;p&gt;
Alas, it was scrapped instantly. Why? Well, it seems in my templates, I placed the
code into logical &amp;#8220;regions&amp;#8221; -- e.g. Public Properties, Public Methods,
Private Methods, etc. I was &amp;#8220;informed&amp;#8221; (even though I had been using regions
for a couple of months now) that regions were not allowed, because all they did was
hide bad code. WHAT???!! Well, I liked the contract, and knew the results if I stood
up to them, so I bit my tongue and moved on. It has bothered me ever since, but I
never took the time to formulate an argument as to why regions are actually a good
idea. 
&lt;/p&gt;
&lt;p&gt;
Why bring this up today after a year has passed? Well, I was coding something, and
the constructor was hidden by a region. I was thinking &amp;#8220;Hmm, if we just left
the constructors out of regions, it would be easy to read, because the regions would
hide the internal implementations I don't care about, yet at a glance I can see how
to instantiate the object&amp;#8221; (hmm, I think they call that encapsulation) and use
it. Now that right there justifies the use of regions alone.... I can actually think
of a lot of reasons to use regions, and I do it religeously where my client has no
opition about it. 
&lt;/p&gt;
&lt;p&gt;
Just a flashback from the past.... anyone got a counter opinion? Regardless, it just
goes to show extreme anything typically isn't a good thing in my mind. You have to
be flexible in your approach to life if you plan on growing...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=faefbcf2-c211-4893-820b-0aaab66e31be" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,faefbcf2-c211-4893-820b-0aaab66e31be.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=d98820c4-cb7c-4348-8d80-b59c6d514d01</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,d98820c4-cb7c-4348-8d80-b59c6d514d01.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,d98820c4-cb7c-4348-8d80-b59c6d514d01.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d98820c4-cb7c-4348-8d80-b59c6d514d01</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Tentatively, my current project is set to end in October. No big deal there, as I
have had absolutely no bench days in the past 10 years as an Independent Contractor.
In fact, during most of those 10 years I have been working 55-80+ hours per week and
having a great time doing it. I don't do the book thing or magazine article thing
because quite frankly, I don't have time because I am busy doing billable work which
pays a lot more. I havn't needed self-promotion thing either because almost all my
business comes from referrals from current or past customers.
</p>
        <p>
Then along come kids, and dang if you don't suddenly want to spend more time at home
and improve their quality of life (and mine). My current project wants to bring me
on full time, and we've had some preliminary discussions on it, and I am willing to
take the pay cut in my pay for one simple thing: I want to work remotely
and raise my kids in the country. Their attitude is like mine, which is that should
be fine since I have a strong work ethic and can get things done, what does it matter
where I work as long as I have a phone and internet connection. However, there are
data security concerns and management concerns which would need to be overcome. 
</p>
        <p>
I have plenty of time, since barring disaster, the contract won't be over until
October sometime. But I figure I will start self-promoting just in case someone from
a company who doesn't mind remote employees stumbles on this blog. Towards October,
I will go full bore trying to close something out, and in the meantime I plan on blogging
much more so I can display what talents I can bring to the table. 
</p>
        <p>
If any companies out there that come up on this, and want a great employee (C#/VB
developer with lots of SQL Server and architect/designer/coding and full-life cycle
development) that brings a lot of experience, a great professional attitude and
presence as well as the ability to code like the wind (and good code at that..), then
drop me a line and let's talk. 
</p>
        <p>
Here's a <a href="http://www.rubiconcomputing.com/resume/resume.html" target="_blank">resume </a>just
in case.. 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=d98820c4-cb7c-4348-8d80-b59c6d514d01" />
      </body>
      <title>Self Promotion</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,d98820c4-cb7c-4348-8d80-b59c6d514d01.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/05/26/SelfPromotion.aspx</link>
      <pubDate>Thu, 26 May 2005 23:33:35 GMT</pubDate>
      <description>&lt;p&gt;
Tentatively, my current project is set to end in October. No big deal there, as I
have had absolutely no bench days in the past 10 years as an Independent Contractor.
In fact, during most of those 10 years I have been working 55-80+ hours per week and
having a great time doing it. I don't do the book thing or magazine article thing
because quite frankly, I don't have time because I am busy doing billable work which
pays a lot more. I havn't needed self-promotion thing either because almost all my
business comes from referrals from current or past customers.
&lt;/p&gt;
&lt;p&gt;
Then along come kids, and dang if you don't suddenly want to spend more time at home
and improve their quality of life (and mine). My current project wants to bring me
on full time, and we've had some preliminary discussions on it, and I am willing to
take&amp;nbsp;the pay&amp;nbsp;cut in my pay for one simple thing: I want to work remotely
and raise my kids in the country. Their attitude is like mine, which is that should
be fine since I have a strong work ethic and can get things done, what does it matter
where I work as long as I have a phone and internet connection. However, there are
data security concerns and management concerns which would need to be overcome. 
&lt;/p&gt;
&lt;p&gt;
I&amp;nbsp;have plenty of time, since barring disaster, the contract won't be over until
October sometime. But I figure I will start self-promoting just in case someone from
a company who doesn't mind remote employees stumbles on this blog. Towards October,
I will go full bore trying to close something out, and in the meantime I plan on blogging
much more so I can display what talents I can bring to the table. 
&lt;/p&gt;
&lt;p&gt;
If any companies out there that come up on this, and want a great employee (C#/VB
developer with lots of SQL Server and architect/designer/coding and full-life cycle
development)&amp;nbsp;that brings a lot of experience, a great professional attitude and
presence as well as the ability to code like the wind (and good code at that..), then
drop me a line and let's talk. 
&lt;/p&gt;
&lt;p&gt;
Here's a &lt;a href="http://www.rubiconcomputing.com/resume/resume.html" target=_blank&gt;resume &lt;/a&gt;just
in case.. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=d98820c4-cb7c-4348-8d80-b59c6d514d01" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,d98820c4-cb7c-4348-8d80-b59c6d514d01.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
      <category>VB.Net</category>
      <category>Windows</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=9371af86-0405-4beb-bd2e-b0b1f0884ae1</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,9371af86-0405-4beb-bd2e-b0b1f0884ae1.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,9371af86-0405-4beb-bd2e-b0b1f0884ae1.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9371af86-0405-4beb-bd2e-b0b1f0884ae1</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I bought CodeSmith back in v2, but I was so busy I never got a chance to do more than
play around with it. So now v3 is released, and I was looking at the improvements
(like Intellisense) and decided I would take a look at it again. Boy, was I glad I
did..
</p>
        <p>
Don't get me wrong, I wasn't putting it off because I think code generation and templates
are bad. In fact, quite the opposite. When I first started my business, I had a few
people working with me part-time, and then finally full time as the business grew.
What I found was that in the end, I apparently hold my coding standards to a higher
value than others and I would end up coding 90% of the application myself. I realized
quickly there were a few huge advantages to automated code generation. Here's a few:
</p>
        <ul>
          <li>
Fewer errors (as long as you fix the templates as errors are encountered)</li>
          <li>
One developer can do the work of 4-5 once you get a good architecture set up</li>
          <li>
Standards enforcement is a no-brainer when you are all working off the same templates</li>
          <li>
You can spend more time on UI usability and data structure because 90% of the infrastructure
stuff is done automatically</li>
          <li>
Changes are easy. Change the structure and regenerate the code, and you are off again.</li>
        </ul>
        <p>
I could go on and on about it. I had written a series of VB6 addins which I used based
off Rocky Lhotka's BusinessObjects book for VB5. In hours I could generate almost
all of my middle and data tier code. A tweak here and there, and I was doing the fun
stuff like UI coding. 
</p>
        <p>
Along comes .Net, and my addins were irrelevant. I created a couple of quick and dirty
addins, but I was so busy heads-down coding, I didn't have time to create new templates
to reflect the impact of .Net. I did create some common libraries of functions which
got me through a good chunk of redundant coding, so that was going to have to do the
job for the time.  I had always intended on going back and re-coding some new
templates, but it never happened. 
</p>
        <p>
I am currently working on a project and we are horribly understaffed, and there's
no relief in sight. There are some huge deadlines coming up, and it's time to make
the rubber hit the road. I already code fast (and tight), but I needed to clone myself
a couple times over to make the deadlines. So when the announcement came this week
of CodeSmith 3.0, I decided I would take a new serious look at it and see what it
could do for me. 
</p>
        <p>
Holy crap! In a matter of hours I had some pretty solid templates up and running,
which will save the team many, many hours of redundant coding tasks in building this
application. I have so many ideas for new templates it's scary, and I have only
scratched the surface for what the tool can do. If you haven't looked at it yet, I
recommend immediately going to <a href="http://www.codesmithtools.com/" target="_blank">CodeSmith</a> and
downloading a trial.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9371af86-0405-4beb-bd2e-b0b1f0884ae1" />
      </body>
      <title>CodeSmith rocks!</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,9371af86-0405-4beb-bd2e-b0b1f0884ae1.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/05/26/CodeSmithRocks.aspx</link>
      <pubDate>Thu, 26 May 2005 23:19:32 GMT</pubDate>
      <description>&lt;p&gt;
I bought CodeSmith back in v2, but I was so busy I never got a chance to do more than
play around with it. So now v3 is released, and I was looking at the improvements
(like Intellisense) and decided I would take a look at it again. Boy, was I glad I
did..
&lt;/p&gt;
&lt;p&gt;
Don't get me wrong, I wasn't putting it off because I think code generation and templates
are bad. In fact, quite the opposite. When I first started my business, I had a few
people working with me part-time, and then finally full time as the business grew.
What I found was that in the end, I apparently hold my coding standards to a higher
value than others and I would end up coding 90% of the application myself. I realized
quickly there were a few huge advantages to automated code generation. Here's a few:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Fewer errors (as long as you fix the templates as errors are encountered)&lt;/li&gt;
&lt;li&gt;
One developer can do the work of 4-5 once you get a good architecture set up&lt;/li&gt;
&lt;li&gt;
Standards enforcement is a no-brainer when you are all working off the same templates&lt;/li&gt;
&lt;li&gt;
You can spend more time on UI usability and data structure because 90% of the infrastructure
stuff is done automatically&lt;/li&gt;
&lt;li&gt;
Changes are easy. Change the structure and regenerate the code, and you are off again.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I could go on and on about it. I had written a series of VB6 addins which I used based
off Rocky Lhotka's BusinessObjects book for VB5. In hours I could generate almost
all of my middle and data tier code. A tweak here and there, and I was doing the fun
stuff like UI coding. 
&lt;/p&gt;
&lt;p&gt;
Along comes .Net, and my addins were irrelevant. I created a couple of quick and dirty
addins, but I was so busy heads-down coding, I didn't have time to create new templates
to reflect the impact of .Net. I did create some common libraries of functions which
got me through a good chunk of redundant coding, so that was going to have to do the
job for the time.&amp;nbsp; I had always intended on going back and re-coding some new
templates, but it never happened. 
&lt;/p&gt;
&lt;p&gt;
I am currently working on a project and we are horribly understaffed, and there's
no relief in sight. There are some huge deadlines coming up, and it's time to make
the rubber hit the road. I already code fast (and tight), but I needed to clone myself
a couple times over to make the deadlines. So when the announcement came this week
of CodeSmith 3.0, I decided I would take a new serious look at it and see what it
could do for me. 
&lt;/p&gt;
&lt;p&gt;
Holy crap! In a matter of hours I had some pretty solid templates up and running,
which will save the team many, many hours of redundant coding tasks in building this
application. I have so many ideas for new templates it's scary, and&amp;nbsp;I have only
scratched the surface for what the tool can do. If you haven't looked at it yet, I
recommend immediately going to &lt;a href="http://www.codesmithtools.com/" target=_blank&gt;CodeSmith&lt;/a&gt; and
downloading a trial.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9371af86-0405-4beb-bd2e-b0b1f0884ae1" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,9371af86-0405-4beb-bd2e-b0b1f0884ae1.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=14bee00c-2e56-4024-ba74-c52a804be4c5</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,14bee00c-2e56-4024-ba74-c52a804be4c5.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,14bee00c-2e56-4024-ba74-c52a804be4c5.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=14bee00c-2e56-4024-ba74-c52a804be4c5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you are using DIME attachments, and you want to use them in a Windows client, this
tip will save you some time. I created a File Upload/Download web service for a client
I am currently working with, and until this week is was used solely on a web front
end. However, there was a request for a Windows client, so I set out to create one
using the same code. 
</p>
        <p>
All seemed well, until I went to compile. My Web Service is called FileService (for
the purposes of this discussion), and in order the use DIME attachments after setting
a web reference, you need to use the FileServiceWse version of the web reference (the
wse class). The problem was, one wasn't generated in the proxy. I debated using the
proxy for the web application, but then decided to try something a little different.
</p>
        <p>
I removed the existing Web Reference, added a reference to System.Web to my project,
then added the Web Reference again. Viola! My wse version was available now, and my
code compiles! I decided to post this to save someone else a bit of time, as well
as a reminder to myself in the future.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=14bee00c-2e56-4024-ba74-c52a804be4c5" />
      </body>
      <title>Tip of the day: Using Web Services in a Windows environment </title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,14bee00c-2e56-4024-ba74-c52a804be4c5.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/04/23/TipOfTheDayUsingWebServicesInAWindowsEnvironment.aspx</link>
      <pubDate>Sat, 23 Apr 2005 20:36:27 GMT</pubDate>
      <description>&lt;p&gt;
If you are using DIME attachments, and you want to use them in a Windows client, this
tip will save you some time. I created a File Upload/Download web service for a client
I am currently working with, and until this week is was used solely on a web front
end. However, there was a request for a Windows client, so I set out to create one
using the same code. 
&lt;/p&gt;
&lt;p&gt;
All seemed well, until I went to compile. My Web Service is called FileService (for
the purposes of this discussion), and in order the use DIME attachments after setting
a web reference, you need to use the FileServiceWse version of the web reference (the
wse class). The problem was, one wasn't generated in the proxy. I debated using the
proxy for the web application, but then decided to try something a little different.
&lt;/p&gt;
&lt;p&gt;
I removed the existing Web Reference, added a reference to System.Web to my project,
then added the Web Reference again. Viola! My wse version was available now, and my
code compiles! I decided to post this to save someone else a bit of time, as well
as a reminder to myself in the future.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=14bee00c-2e56-4024-ba74-c52a804be4c5" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,14bee00c-2e56-4024-ba74-c52a804be4c5.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>VB.Net</category>
      <category>Windows</category>
      <category>WinForms</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=8e3e7285-b4a7-4a3a-910c-1a84d2b1cf75</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,8e3e7285-b4a7-4a3a-910c-1a84d2b1cf75.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,8e3e7285-b4a7-4a3a-910c-1a84d2b1cf75.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8e3e7285-b4a7-4a3a-910c-1a84d2b1cf75</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There's a lot of debate on the best type of error handling, where to log it (if at
all), and when to do it. For example, here's a debate today:
</p>
        <p>
          <a href="http://weblogs.asp.net/alex_papadimoulis/archive/2005/03/29/396141.aspx">http://weblogs.asp.net/alex_papadimoulis/archive/2005/03/29/396141.aspx</a>
        </p>
        <p>
In this debate, the question is Return codes vs. Throwing an Exception. You can read
the blog entry to see the debate. Here's my take, and why.
</p>
        <p>
First, I always handle the exception where it happens, and rarely bubble it up. Why?
First, what if the calling code doesn't handle the exception? Now you have an unhandled
error, and it could cause an application to crash. On a recent project for a large
chipmaking client, I got into this debate a few times with all levels of developers.
It was always an interesting debate with senior developers because they at least adopted
their belief into action and a bigger strategy. For example, they may trickle it up
and handle it at the highest level, but if they forget to handle it, the best developers
handle the uncaught errors at the thread level. The advantage is they have the error
information and can use it to provide the user some feedback as to the nature of the
problem.
</p>
        <p>
But those are good developers, and I would say the top 10%. As an example, I had this
debate with a mid-level developer who was convinced he was a senior level developer.
Now, as I tell this story, let me mention I am a very good poker player. He adamantly
felt errors should be bubbled up and handled at the UI. I countered him with the standard
“What happens when the exception isn't handled?” He advised me he never
forgets. Enter the poker player in me. 
</p>
        <p>
Being a consultant, you have to know when to shut up and let the “hand”
play out. This was an XP project (never again), and as we paired, I watched him write
some code, and I even reminded him about error handling. For the most part, with my
diligence and because we had just had the discussion this guy was being fairly consistant
in his exception handling at the UI level. However, I stopped reminding him (it's
instinct for me to do it now), and sure enough, he forgot, and the application crashed
a horrible death. The reason I wanted to have this discussion with him was because
his code was causing about 80% of the crashes on the team, and I was trying to help
him improve his skills (and our project). To finish the story, the guy's ego was so
big he refused to accept responsibility for the crashes or even acknowledge that I
had a valid point about forgetting error handling, and kept on his merry way.
</p>
        <p>
Back to the point, IMHO error handling should be handled where the error occurs. This
is especially true in multi-developer projects, as you cannot guarantee someone who
calls your code is diligent enough to handle things when problems occur.
</p>
        <p>
But that has a serious downside -- how do you let the user know there was a problem,
and it was handled? The answer -- return values. OK, there's a little more to it than
that. An error code is never enough information to provide feedback or to decide what
to do when the caller receives notice an error occurred. Even worse, a number is useless
in trying to relay relevant info to the end-user.
</p>
        <p>
What I have adopted is this: I have a base class which my other classes inherit from.
In that class, I have an ErrorMessage property (string) which is set where the error
occurs, or in a central error handler. When a method encounters an error, it returns
an integer value indicating failure. The calling routine (if desired) can check the
ErrorMessage property and use that value for displaying a message or get details as
to the nature of the problem.  It can also ignore it if it wants. The key thing
though is that the error will never go unhandled and cause the application to crash.
</p>
        <p>
I'll be happy to post up some examples if there is interest. This is just a very important
topic to me, and one I think which separates the wheat from the chaff, as they say!
</p>
        <p>
In the debate listed above, there's an argument over performance. There's a balance
here: you need to perform well, but performance is killed when the application
crashes. Find a solution which is robust but also performs. Not handling an exception
is not an option for robustness.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=8e3e7285-b4a7-4a3a-910c-1a84d2b1cf75" />
      </body>
      <title>Error Handling Discussion</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,8e3e7285-b4a7-4a3a-910c-1a84d2b1cf75.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/04/14/ErrorHandlingDiscussion.aspx</link>
      <pubDate>Thu, 14 Apr 2005 16:49:54 GMT</pubDate>
      <description>&lt;p&gt;
There's a lot of debate on the best type of error handling, where to log it (if at
all), and when to do it. For example, here's a debate today:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://weblogs.asp.net/alex_papadimoulis/archive/2005/03/29/396141.aspx"&gt;http://weblogs.asp.net/alex_papadimoulis/archive/2005/03/29/396141.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
In this debate, the question is Return codes vs. Throwing an Exception. You can read
the blog entry to see the debate. Here's my take, and why.
&lt;/p&gt;
&lt;p&gt;
First, I always handle the exception where it happens, and rarely bubble it up. Why?
First, what if the calling code doesn't handle the exception? Now you have an unhandled
error, and it could cause an application to crash. On a recent project for a large
chipmaking client, I got into this debate a few times with all levels of developers.
It was always an interesting debate with senior developers because they at least adopted
their belief into action and a bigger strategy. For example, they may trickle it up
and handle it at the highest level, but if they forget to handle it, the best developers
handle the uncaught errors at the thread level. The advantage is they have the error
information and can use it to provide the user some feedback as to the nature of the
problem.
&lt;/p&gt;
&lt;p&gt;
But those are good developers, and I would say the top 10%. As an example, I had this
debate with a mid-level developer who was convinced he was a senior level developer.
Now, as I tell this story, let me mention I am a very good poker player. He adamantly
felt errors should be bubbled up and handled at the UI. I countered him with the standard
&amp;#8220;What happens when the exception isn't handled?&amp;#8221; He advised me he never
forgets. Enter the poker player in me. 
&lt;/p&gt;
&lt;p&gt;
Being a consultant, you have to know when to shut up and let the &amp;#8220;hand&amp;#8221;
play out. This was an XP project (never again), and as we paired, I watched him write
some code, and I even reminded him about error handling. For the most part, with my
diligence and because we had just had the discussion this guy was being fairly consistant
in his exception handling at the UI level. However, I stopped reminding him (it's
instinct for me to do it now), and sure enough, he forgot, and the application crashed
a horrible death. The reason I wanted to have this discussion with him was because
his code was causing about 80% of the crashes on the team, and I was trying to help
him improve his skills (and our project). To finish the story, the guy's ego was so
big he refused to accept responsibility for the crashes or even acknowledge that I
had a valid point about forgetting error handling, and kept on his merry way.
&lt;/p&gt;
&lt;p&gt;
Back to the point, IMHO error handling should be handled where the error occurs. This
is especially true in multi-developer projects, as you cannot guarantee someone who
calls your code is diligent enough to handle things when problems occur.
&lt;/p&gt;
&lt;p&gt;
But that has a serious downside -- how do you let the user know there was a problem,
and it was handled? The answer -- return values. OK, there's a little more to it than
that. An error code is never enough information to provide feedback or to decide what
to do when the caller receives notice an error occurred. Even worse, a number is useless
in trying to relay relevant info to the end-user.
&lt;/p&gt;
&lt;p&gt;
What I have adopted is this: I have a base class which my other classes inherit from.
In that class, I have an ErrorMessage property (string) which is set where the error
occurs, or in a central error handler. When a method encounters an error, it returns
an integer value indicating failure. The calling routine (if desired) can check the
ErrorMessage property and use that value for displaying a message or get details as
to the nature of the problem.&amp;nbsp; It can also ignore it if it wants. The key thing
though is that the error will never go unhandled and cause the application to crash.
&lt;/p&gt;
&lt;p&gt;
I'll be happy to post up some examples if there is interest. This is just a very important
topic to me, and one I think which separates the wheat from the chaff, as they say!
&lt;/p&gt;
&lt;p&gt;
In the debate listed above, there's an argument over performance. There's a balance
here: you need to perform well, but performance is killed&amp;nbsp;when the application
crashes. Find a solution which is robust but also performs. Not handling an exception
is not an option for robustness.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=8e3e7285-b4a7-4a3a-910c-1a84d2b1cf75" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,8e3e7285-b4a7-4a3a-910c-1a84d2b1cf75.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=d5411609-078a-494c-9e9d-7d01f80c3f51</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,d5411609-078a-494c-9e9d-7d01f80c3f51.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,d5411609-078a-494c-9e9d-7d01f80c3f51.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d5411609-078a-494c-9e9d-7d01f80c3f51</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have a large ASP.Net project I am working on, and the solution contains about 6
projects. Periodically, it won't compile, but when I look in the Task List there are
no errors listed. After a lot of trial and error, I finally found a solution which
restores the missing error notations, so that I can fix the problem and move on.
</p>
        <p>
Right-click in the “Task” screen, and select the “Show Tasks/Comments”
option. Try compiling, and of course it will fail again. Then, right-click on the
“Task” screen again, and select the “Build Errors” option,
and they should appear. It seems to work fairly consistantly so I think this “workaround”
may actually work.
</p>
        <p>
As an alternative (although not as easy to work with), you can just look at the output
window, and filter through the text output. Take your pick, you should be able to
see what the problem is!
</p>
        <p>
ADDENDUM: It happened again, and these steps didn't work exactly. To make it work,
try to compile again between “right-clicks” and they should appear.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=d5411609-078a-494c-9e9d-7d01f80c3f51" />
      </body>
      <title>Tip of the Day - My errors aren't showing up in the task list..???</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,d5411609-078a-494c-9e9d-7d01f80c3f51.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/04/04/TipOfTheDayMyErrorsArentShowingUpInTheTaskList.aspx</link>
      <pubDate>Mon, 04 Apr 2005 18:28:35 GMT</pubDate>
      <description>&lt;p&gt;
I have a large ASP.Net project I am working on, and the solution contains about 6
projects. Periodically, it won't compile, but when I look in the Task List there are
no errors listed. After a lot of trial and error, I finally found a solution which
restores the missing error notations, so that I can fix the problem and move on.
&lt;/p&gt;
&lt;p&gt;
Right-click in the &amp;#8220;Task&amp;#8221; screen, and select the &amp;#8220;Show Tasks/Comments&amp;#8221;
option. Try compiling, and of course it will fail again. Then, right-click on the
&amp;#8220;Task&amp;#8221; screen again, and select the &amp;#8220;Build Errors&amp;#8221; option,
and they should appear. It seems to work fairly consistantly so I think this &amp;#8220;workaround&amp;#8221;
may actually work.
&lt;/p&gt;
&lt;p&gt;
As an alternative (although not as easy to work with), you can just look at the output
window, and filter through the text output. Take your pick, you should be able to
see what the problem is!
&lt;/p&gt;
&lt;p&gt;
ADDENDUM: It happened again, and these steps didn't work exactly. To make it work,
try to compile again between &amp;#8220;right-clicks&amp;#8221; and they should appear.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=d5411609-078a-494c-9e9d-7d01f80c3f51" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,d5411609-078a-494c-9e9d-7d01f80c3f51.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>CSharp</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=bbf33cb9-45f0-486e-a9ae-5f5ce3daa464</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,bbf33cb9-45f0-486e-a9ae-5f5ce3daa464.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,bbf33cb9-45f0-486e-a9ae-5f5ce3daa464.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=bbf33cb9-45f0-486e-a9ae-5f5ce3daa464</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Let's talk resume's for a minute. You want that interview don't you? Well, sometimes
all you have to get you there is your resume (although personal reference is the best
way if you can get it, an area where networking and doing quality work can help).
</p>
        <p>
There's a million places on the internet to help you decide how to structure
your resume. I have only gotten one criticizm from my resume, and I am not sure if
it's the content or the structure which works best. But here's a couple of pointers
which I think have helped out my resume.
</p>
        <ol>
          <li>
Place a logo of any certifications you have if available (e.g. MCSD). These are real
eye catchers. Make the images small though.. 
</li>
          <li>
Place your specific skills separate from your experience, preferably near the top.
This makes it easy to survive the first pass from the recruiter/manager. 
</li>
          <li>
Sell yourself! Research “power“ words and make any experience descriptions
short and chock full of those words.</li>
        </ol>
        <p>
Now, there's a few easy tips of what to do. I have been helping staff for years, and
here's some of the gems I have seen.
</p>
        <ul>
          <li>
Horrible writing and spelling. 
</li>
          <li>
Obviously exagerated skills and experiences (4 years experience, 10 years at a certain
skill) 
</li>
          <li>
Never say you are an expert at anything, even if you are. Humility goes a long way,
and if the interviewer knows more, you'll be humbled by them, as I witnessed in the
past week. 
</li>
          <li>
Use nice paper if submitting a hardcopy (I received one handwritten on a partial
piece of paper -- I kid you not)</li>
        </ul>
        <p>
It's not tough... just use some common sense!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=bbf33cb9-45f0-486e-a9ae-5f5ce3daa464" />
      </body>
      <title>How to get the technical interview....(Part III?)</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,bbf33cb9-45f0-486e-a9ae-5f5ce3daa464.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/03/21/HowToGetTheTechnicalInterviewPartIII.aspx</link>
      <pubDate>Mon, 21 Mar 2005 15:11:00 GMT</pubDate>
      <description>&lt;p&gt;
Let's talk resume's for a minute. You want that interview don't you? Well, sometimes
all you have to get you there is your resume (although personal reference is the best
way if you can get it, an area where networking and doing quality work can help).
&lt;/p&gt;
&lt;p&gt;
There's a million places on the internet&amp;nbsp;to&amp;nbsp;help you decide how to structure
your resume. I have only gotten one criticizm from my resume, and I am not sure if
it's the content or the structure which works best. But here's a couple of pointers
which I think have helped out my resume.
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Place a logo of any certifications you have if available (e.g. MCSD). These are real
eye catchers. Make the images small though.. 
&lt;li&gt;
Place your specific skills separate from your experience, preferably near the top.
This makes it easy to survive the first pass from the recruiter/manager. 
&lt;li&gt;
Sell yourself! Research &amp;#8220;power&amp;#8220; words and make any experience descriptions
short and chock full of those words.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Now, there's a few easy tips of what to do. I have been helping staff for years, and
here's some of the gems I have seen.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Horrible writing and spelling. 
&lt;li&gt;
Obviously exagerated skills and experiences (4 years experience, 10 years at a certain
skill) 
&lt;li&gt;
Never say you are an expert at anything, even if you are. Humility goes a long way,
and if the interviewer knows more, you'll be humbled by them, as I witnessed in the
past week. 
&lt;li&gt;
Use nice paper if submitting a hardcopy (I received one handwritten on a&amp;nbsp;partial
piece of paper&amp;nbsp;-- I kid you not)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
It's not tough... just use some common sense!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=bbf33cb9-45f0-486e-a9ae-5f5ce3daa464" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,bbf33cb9-45f0-486e-a9ae-5f5ce3daa464.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=4ec93d89-759a-4b39-a7c9-38b1457c4055</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,4ec93d89-759a-4b39-a7c9-38b1457c4055.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,4ec93d89-759a-4b39-a7c9-38b1457c4055.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=4ec93d89-759a-4b39-a7c9-38b1457c4055</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <table cellpadding="1" width="100%">
            <tbody>
              <tr>
                <td valign="top">
                  <p>
OK, so let's assume you get past the technical part of the interview. Play you cards
right, and it's not hard to do. You've managed to show you have a decent personality
(which is VERY important in interviewing), and you think you have a good shot at landing
the job. That's where we were with a couple of candidates in this interviewing session.
However, the strongest candidates managed to snatch defeat out of the jaws of victory,
and blow their chances at getting the job. How?
</p>
                  <p>
In one case, a person was interviewed who, shall we say for legal reasons, is in a
protected class of employment law. The interview was fairly strong, and he had a great
shot at getting the job. However, when we asked this person if they had any questions,
the first thing out of their mouth dealt with their protected status, and almost a
“veiled“ insinuation we needed to be make sure we didn't take that into
consideration. Up until that point, we hadn't even thought about it. However, it came
clear that there was the potential for legal issues should this person become an employee.
</p>
                  <p>
In another case, the prospect was extremely strong. I had given my thumbs up almost
wholeheartedly until we once again asked if they had any questions for us. It's always
a good idea to ask for some feedback from your interviewers, and even lightly use
a closing technique to get the interviewers to think you'd be right for the job. However,
this prospect put each and every one of us on the spot requesting specific feedback
for their interview. And I mean very direct, pointed and almost intimidating questions
(I don't get intimidated, I just thought it was rude).
</p>
                  <p>
After the inquisition, he made this bold statement “Since there doesn't appear
to be any resistance or negative feedback, I think you should just go ahead and make
the offer.“ WTF?!?!? Well, it was politely stated that we had other candidates
to consider, and we would be in touch soon. 
</p>
                  <p>
This same candidate took it upon himself to continue the pressing over the next couple
of days. He managed to obtain all of our individual email addresses, and send communications
reiterating we should “choose“ him, like we were voting a tribe member
out of Survivor or something.
</p>
                  <p>
Don't get me wrong, it's good to send thank you notes, and it's good to gently ask
for feedback and sell yourself. Putting people on the spot is ABSOLUTELY not the way
to do it though. Repeated unsolicited communication and badgering is also not a great
way to get people to remember you positively after the interview. Say thanks, ingratiate
yourself for allowing them to consider you, and get out.
</p>
                  <p>
You can also blow it in one question. When one candidate was asked what he liked to
do in his spare time, his answer was “Anything dangerous.“ Great, an insurance
risk! One guy mentioned he sleeps with his computer. Scary.
</p>
                  <p>
I might do a part three about resumes. I have a tale about a cocktail napkin, and
a guy who claims to have invented the internet, but I guess I will save that for part
III.
</p>
                </td>
              </tr>
            </tbody>
          </table>
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=4ec93d89-759a-4b39-a7c9-38b1457c4055" />
      </body>
      <title>Things not to do on a technical interview.. -- Part II</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,4ec93d89-759a-4b39-a7c9-38b1457c4055.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/03/19/ThingsNotToDoOnATechnicalInterviewPartII.aspx</link>
      <pubDate>Sat, 19 Mar 2005 00:14:50 GMT</pubDate>
      <description>&lt;p&gt;
&lt;table cellpadding=1 width="100%"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign=top&gt;
&lt;p&gt;
OK, so let's assume you get past the technical part of the interview. Play you cards
right, and it's not hard to do. You've managed to show you have a decent personality
(which is VERY important in interviewing), and you think you have a good shot at landing
the job. That's where we were with a couple of candidates in this interviewing session.
However, the strongest candidates managed to snatch defeat out of the jaws of victory,
and blow their chances at getting the job. How?
&lt;/p&gt;
&lt;p&gt;
In one case, a person was interviewed who, shall we say for legal reasons, is in a
protected class of employment law. The interview was fairly strong, and he had a great
shot at getting the job. However, when we asked this person if they had any questions,
the first thing out of their mouth dealt with their protected status, and almost a
&amp;#8220;veiled&amp;#8220; insinuation we needed to be make sure we didn't take that into
consideration. Up until that point, we hadn't even thought about it. However, it came
clear that there was the potential for legal issues should this person become an employee.
&lt;/p&gt;
&lt;p&gt;
In another case, the prospect was extremely strong. I had given my thumbs up almost
wholeheartedly until we once again asked if they had any questions for us. It's always
a good idea to ask for some feedback from your interviewers, and even lightly use
a closing technique to get the interviewers to think you'd be right for the job. However,
this prospect put each and every one of us on the spot requesting specific feedback
for their interview. And I mean very direct, pointed and almost intimidating questions
(I don't get intimidated, I just thought it was rude).
&lt;/p&gt;
&lt;p&gt;
After the inquisition, he made this bold statement &amp;#8220;Since there doesn't appear
to be any resistance or negative feedback, I think you should just go ahead and make
the offer.&amp;#8220; WTF?!?!? Well, it was politely stated that we had other candidates
to consider, and we would be in touch soon. 
&lt;/p&gt;
&lt;p&gt;
This same candidate took it upon himself to continue the pressing over the next couple
of days. He managed to obtain all of our individual email addresses, and send communications
reiterating we should &amp;#8220;choose&amp;#8220; him, like we were voting a tribe member
out of Survivor or something.
&lt;/p&gt;
&lt;p&gt;
Don't get me wrong, it's good to send thank you notes, and it's good to gently ask
for feedback and sell yourself. Putting people on the spot is ABSOLUTELY not the way
to do it though. Repeated unsolicited communication and badgering is also not a great
way to get people to remember you positively after the interview. Say thanks, ingratiate
yourself for allowing them to consider you, and get out.
&lt;/p&gt;
&lt;p&gt;
You can also blow it in one question. When one candidate was asked what he liked to
do in his spare time, his answer was &amp;#8220;Anything dangerous.&amp;#8220; Great, an insurance
risk! One guy mentioned he sleeps with his computer. Scary.
&lt;/p&gt;
&lt;p&gt;
I might do a part three about resumes. I have a tale about a cocktail napkin, and
a guy who claims to have invented the internet, but I guess I will save that for part
III.
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=4ec93d89-759a-4b39-a7c9-38b1457c4055" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,4ec93d89-759a-4b39-a7c9-38b1457c4055.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=ee965caf-0dc3-45de-b5d9-8daad3d39851</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,ee965caf-0dc3-45de-b5d9-8daad3d39851.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,ee965caf-0dc3-45de-b5d9-8daad3d39851.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ee965caf-0dc3-45de-b5d9-8daad3d39851</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am so irritated at how poor the documentation for WSE2 and DIME attachment processing
is. So today's tip will save someone new to the process countless amount of time.
Here's the scenario: You want to process a file download using DIME attachments. You
write your web service, and want to test it. You run the web service, pop up the Visual
Studio test page for the web service, and it doesn't download your file as expected. 
</p>
        <p>
So, you start debugging, and it turns out the ResponseSoapContext.Current is null.
WTF? It *should* work. So you grab all your books and online articles you can find,
and a few people are having this problem, but no one seems to post how they solved
it. Well, after spending a few hours trying to solve the problem, I run across a blurb
that states you can't test your DIME downloading from the web page which is created
by the Visual Studio IDE, you *have* to create a separate client (those weren't the
exact words, but that's the gist of it).
</p>
        <p>
Arrggh!!! Wasted time! But if I can save someone else from the same frustration, I
will.
</p>
        <p>
Good luck!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ee965caf-0dc3-45de-b5d9-8daad3d39851" />
      </body>
      <title>Tip of the Day: Testing WSE2 (SOAP) DIME Attachments and the 'ResponseSoapContext.Current is null' issue</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,ee965caf-0dc3-45de-b5d9-8daad3d39851.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/03/18/TipOfTheDayTestingWSE2SOAPDIMEAttachmentsAndTheResponseSoapContextCurrentIsNullIssue.aspx</link>
      <pubDate>Fri, 18 Mar 2005 21:15:58 GMT</pubDate>
      <description>&lt;p&gt;
I am so irritated at how poor the documentation for WSE2 and DIME attachment processing
is. So today's tip will save someone new to the process countless amount of time.
Here's the scenario: You want to process a file download using DIME attachments. You
write your web service, and want to test it. You run the web service, pop up the Visual
Studio test page for the web service, and it doesn't download your file as expected. 
&lt;/p&gt;
&lt;p&gt;
So, you start debugging, and it turns out the ResponseSoapContext.Current is null.
WTF? It *should* work. So you grab all your books and online articles you can find,
and a few people are having this problem, but no one seems to post how they solved
it. Well, after spending a few hours trying to solve the problem, I run across a blurb
that states you can't test your DIME downloading from the web page which is created
by the Visual Studio IDE, you *have* to create a separate client (those weren't the
exact words, but that's the gist of it).
&lt;/p&gt;
&lt;p&gt;
Arrggh!!! Wasted time! But if I can save someone else from the same frustration, I
will.
&lt;/p&gt;
&lt;p&gt;
Good luck!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ee965caf-0dc3-45de-b5d9-8daad3d39851" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,ee965caf-0dc3-45de-b5d9-8daad3d39851.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>CSharp</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=68527dc4-da69-47b2-b028-df00feb35f05</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,68527dc4-da69-47b2-b028-df00feb35f05.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,68527dc4-da69-47b2-b028-df00feb35f05.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=68527dc4-da69-47b2-b028-df00feb35f05</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I wear many hats on the projects I work on, from developer to mentor to pure consultant.
One of my current clients is having me help make staffing decisions by performing
technical interviews on potential candidates.
</p>
        <p>
I've helped out with this kind of thing before, and I want to make some comments because
I have noticed a lot of trends in technical interviews. I'll also have some comments
on the interviewees, and how you can talk yourself out of a job over and over again.
To put this all in context, let me just say in the past 10 years as an independent
consultant, I have never had a day of bench time. Also, in the many, many interviews
and initial meetings I have been to, I was only not given the project one time, and
that was quite mutual by the end of the meeting. Some day, I will write about that
particular experience, and in an unusual change of things, I am going to name names
of the guilty to save others the same problem.
</p>
        <p>
First, the concept of the technical interview. I have seen post after post of technical
questions to help identify the level of technical experience a candidate has. It's
amazing how specific those questions are. Why? They really don't need to be. From
my experience, when someone is asking those excruciatingly detailed questions,
it's more for the interviewer to feel superior than the interviewee (a warning sign
for you job hunters) than to ascertain a knowledge level. 
</p>
        <p>
It's not practical or informative to ask deeply detailed technical questions. Why?
Programming is like medicine in that it's highly specialized at times. I was asked
some specific details about the DataAdapter one time, and I couldn't answer it. Does
that make me a bad hire? Most people wouldn't think so, but I wrapped the functionality
into a data access class, and I don't have to worry about the implementation ever
again unless I need to do something specific. 
</p>
        <p>
As an interviewee, it's important to worry less about the answer to that type of question
than to address how you'd solve the problem. In the DataAdapter above, I stressed
I employed the OOP concept of encapsulation, and if I need to know a specific implementation,
I grab Google or the MSDN and solve the problem. <strong>The key is this: if you don't
know the answer, be truthful about it (and why), and how you would solve the problem</strong>.
</p>
        <p>
You can really identify a programmer's level of expertise with simple questions. For
example, I ask something like “What's the difference between an abstract class
and an interface?” Not terribly tough, but you can tell from the detail of the
answer a lot, both about their programming style as well as their level of knowledge.
</p>
        <p>
I ask two sets of technical questions. The first are the the purely technical questions
(about 10), and then seven or eight “philosophy” questions. I plainly
state there are no right or wrong answers, but I just want to see what level
of thought they place into their development. Here's an example:
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <strong>
              <em>Describe some exception handling you've implemented, and the advantages
and disadvantages you encountered with that method.</em>
            </strong>
          </p>
        </blockquote>
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
Not too bad, right? But what does it tell us? It tells me how robust of an application
this developer is capable of writing. From these interviews I have been participating
in, I would say 80% of the candidates say “I just log to a file.” without
any reason why or “try..catch”. All you need here is an answer and a conviction.
But with the low quality of either portion, I know handling the problems in an application
are not a real priority, which also tells me the developer does not code defensively.
Things like validation and good user dialogs will likely be missed too. While these
things may not be important in your organization or project, it may also mean they
are not the most diligent programmers.
</p>
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
This ends the question section of this topic. In the next part, I will descibe how
I watch a couple of top candidates snatch defeat out of the jaws of victory!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=68527dc4-da69-47b2-b028-df00feb35f05" />
      </body>
      <title>Things not to do on a technical interview.. -- Part I</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,68527dc4-da69-47b2-b028-df00feb35f05.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/03/17/ThingsNotToDoOnATechnicalInterviewPartI.aspx</link>
      <pubDate>Thu, 17 Mar 2005 20:19:01 GMT</pubDate>
      <description>&lt;p&gt;
I wear many hats on the projects I work on, from developer to mentor to pure consultant.
One of my current clients is having me help make staffing decisions by performing
technical interviews on potential candidates.
&lt;/p&gt;
&lt;p&gt;
I've helped out with this kind of thing before, and I want to make some comments because
I have noticed a lot of trends in technical interviews. I'll also have some comments
on the interviewees, and how you can talk yourself out of a job over and over again.
To put this all in context, let me just say in the past 10 years as an independent
consultant, I have never had a day of bench time. Also, in the many, many interviews
and initial meetings I have been to, I was only not given the project one time, and
that was quite mutual by the end of the meeting. Some day, I will write about that
particular experience, and in an unusual change of things, I am going to name names
of the guilty to save others the same problem.
&lt;/p&gt;
&lt;p&gt;
First, the concept of the technical interview. I have seen post after post of technical
questions to help identify the level of technical experience a candidate has. It's
amazing how specific those questions are. Why? They really don't need to be. From
my experience, when someone is asking those excruciatingly&amp;nbsp;detailed questions,
it's more for the interviewer to feel superior than the interviewee (a warning sign
for you job hunters) than to ascertain a knowledge level. 
&lt;/p&gt;
&lt;p&gt;
It's not practical or informative to ask deeply detailed technical questions. Why?
Programming is like medicine in that it's highly specialized at times. I was asked
some specific details about the DataAdapter one time, and I couldn't answer it. Does
that make me a bad hire? Most people wouldn't think so, but I wrapped the functionality
into a data access class, and I don't have to worry about the implementation ever
again unless I need to do something specific. 
&lt;/p&gt;
&lt;p&gt;
As an interviewee, it's important to worry less about the answer to that type of question
than to address how you'd solve the problem. In the DataAdapter above, I stressed
I employed the OOP concept of encapsulation, and if I need to know a specific implementation,
I grab Google or the MSDN and solve the problem. &lt;strong&gt;The key is this: if you don't
know the answer, be truthful about it (and why), and how you would solve the problem&lt;/strong&gt;.
&lt;/p&gt;
&lt;p&gt;
You can really identify a programmer's level of expertise with simple questions. For
example, I ask something like &amp;#8220;What's the difference between an abstract class
and an interface?&amp;#8221; Not terribly tough, but you can tell from the detail of the
answer a lot, both about their programming style as well as their level of knowledge.
&lt;/p&gt;
&lt;p&gt;
I ask two sets of technical questions. The first are the the purely technical questions
(about 10), and then seven or eight &amp;#8220;philosophy&amp;#8221; questions. I plainly
state there&amp;nbsp;are no right or wrong answers, but I just want to see what level
of thought they place into their development. Here's an example:
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;strong&gt;&lt;em&gt;Describe some exception handling you've implemented, and the advantages
and disadvantages you encountered with that method.&lt;/em&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p dir=ltr style="MARGIN-RIGHT: 0px"&gt;
Not too bad, right? But what does it tell us? It tells&amp;nbsp;me how robust of an application
this developer is capable of writing. From these interviews I have been participating
in, I would say 80% of the candidates say &amp;#8220;I just log to a file.&amp;#8221; without
any reason why or &amp;#8220;try..catch&amp;#8221;. All you need here is an answer and a conviction.
But with the low quality of either portion, I know handling the problems in an application
are not a real priority, which also tells me the developer does not code defensively.
Things like validation and good user dialogs will likely be missed too. While these
things may not be important in your organization or project, it may also mean they
are not the most diligent programmers.
&lt;/p&gt;
&lt;p dir=ltr style="MARGIN-RIGHT: 0px"&gt;
This ends the question section of this topic. In the next part, I will descibe how
I watch a couple of top candidates snatch defeat out of the jaws of victory!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=68527dc4-da69-47b2-b028-df00feb35f05" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,68527dc4-da69-47b2-b028-df00feb35f05.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=41506101-3710-4682-8821-965a563fd77b</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,41506101-3710-4682-8821-965a563fd77b.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,41506101-3710-4682-8821-965a563fd77b.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=41506101-3710-4682-8821-965a563fd77b</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Sometimes as a developer you need to rename a file with a date time aspect
so you can do something like guarantee uniqueness,  track submission information,
etc. There's always a ton of ways to do this, but I decided to write a couple of routines
to do this using the FileInfo class. First, the code:
</p>
        <div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0pt; FONT-SIZE: 10pt; BACKGROUND: white; PADDING-BOTTOM: 0pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 0pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New">
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">///</span>
            <span style="COLOR: green">
            </span>
            <span style="COLOR: gray">&lt;summary&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">///</span>
            <span style="COLOR: green"> Gets a string you
can append in a file name to supply uniqueness</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">///</span>
            <span style="COLOR: green">
            </span>
            <span style="COLOR: gray">&lt;/summary&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">///</span>
            <span style="COLOR: green">
            </span>
            <span style="COLOR: gray">&lt;returns&gt;</span>
            <span style="COLOR: green">a
string which looks similar to 2232005_090812 which is a date time</span>
            <span style="COLOR: gray">&lt;/returns&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">public</span>
            <span style="COLOR: blue">static</span>
            <span style="COLOR: blue">string</span> GetUniqueFileNameIdentifier()
</p>
          <p style="MARGIN: 0px">
{
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">return</span> DateTime.Now.Month.ToString()
+ DateTime.Now.Day.ToString() + DateTime.Now.Year.ToString()+ "_" + DateTime.Now.Hour.ToString()
+ DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
</p>
          <p style="MARGIN: 0px">
}
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">///</span>
            <span style="COLOR: green">
            </span>
            <span style="COLOR: gray">&lt;summary&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">///</span>
            <span style="COLOR: green"> Renames a file with
a unique identifier in it</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">///</span>
            <span style="COLOR: green">
            </span>
            <span style="COLOR: gray">&lt;/summary&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">///</span>
            <span style="COLOR: green">
            </span>
            <span style="COLOR: gray">&lt;param
name="fileName"&gt;</span>
            <span style="COLOR: green">file name to rename..</span>
            <span style="COLOR: gray">&lt;/param&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: gray">///</span>
            <span style="COLOR: green">
            </span>
            <span style="COLOR: gray">&lt;returns&gt;</span>
            <span style="COLOR: green">unique
name of file with datetime identifier in the name. e.g. MyFile.txt renamed to MyFile_2232005_090812.txt </span>
            <span style="COLOR: gray">&lt;/returns&gt;</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: blue">public</span>
            <span style="COLOR: blue">static</span>
            <span style="COLOR: blue">string</span> FormatUniqueFileName(<span style="COLOR: blue">string</span> fileName)
</p>
          <p style="MARGIN: 0px">
{
</p>
          <p style="MARGIN: 0px">
    FileInfo fi = <span style="COLOR: blue">new</span> FileInfo(fileName);
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: blue">return</span> fi.Name.Replace(fi.Extension,"")
+ "_" + GetUniqueFileNameIdentifier() + fi.Extension;
</p>
          <p style="MARGIN: 0px">
}
</p>
        </div>
        <p>
First, the FormatUniqueFileName funtion takes a file name (like test.txt), and inserts
the date time info (in the current format, it does this as fileprefix_mmddyyyy_hhmmss.fileextension,
so in our example, we might get test_03162005_071525.txt.
</p>
        <p>
Not a real complex function by any means, but one that's reused a lot in development,
and I decided to get this out just in case some developer wanted to save 5 minutes!
</p>
        <p>
Enjoy!<!--EndFragment--></p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=41506101-3710-4682-8821-965a563fd77b" />
      </body>
      <title>Tip of the day: Renaming files with a time date stamp</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,41506101-3710-4682-8821-965a563fd77b.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/03/16/TipOfTheDayRenamingFilesWithATimeDateStamp.aspx</link>
      <pubDate>Wed, 16 Mar 2005 15:26:57 GMT</pubDate>
      <description>&lt;p&gt;
Sometimes&amp;nbsp;as a developer you need to rename a file with a date&amp;nbsp;time aspect
so you can do something like guarantee uniqueness, &amp;nbsp;track submission information,
etc. There's always a ton of ways to do this, but I decided to write a couple of routines
to&amp;nbsp;do this using the FileInfo class. First, the code:
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0pt; FONT-SIZE: 10pt; BACKGROUND: white; PADDING-BOTTOM: 0pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 0pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets a string you
can append in a file name to supply uniqueness&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;a
string which looks similar to 2232005_090812 which is a date time&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; GetUniqueFileNameIdentifier()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; DateTime.Now.Month.ToString()
+ DateTime.Now.Day.ToString() + DateTime.Now.Year.ToString()+ "_" + DateTime.Now.Hour.ToString()
+ DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Renames a file with
a unique identifier in it&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="fileName"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;file name to rename..&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;unique
name of file with datetime identifier in the name. e.g. MyFile.txt renamed to MyFile_2232005_090812.txt &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; FormatUniqueFileName(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fileName)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; FileInfo fi = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; FileInfo(fileName);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; fi.Name.Replace(fi.Extension,"")
+ "_" + GetUniqueFileNameIdentifier() + fi.Extension;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
}
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
First, the FormatUniqueFileName funtion takes a file name (like test.txt), and inserts
the date time info (in the current format, it does this as fileprefix_mmddyyyy_hhmmss.fileextension,
so in our example, we might get test_03162005_071525.txt.
&lt;/p&gt;
&lt;p&gt;
Not a real complex function by any means, but one that's reused a lot in development,
and I decided to get this out just in case some developer wanted to save 5 minutes!
&lt;/p&gt;
&lt;p&gt;
Enjoy!&lt;!--EndFragment--&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=41506101-3710-4682-8821-965a563fd77b" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,41506101-3710-4682-8821-965a563fd77b.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=43bf4362-22d3-40d8-8818-2f82d1b8ffd4</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,43bf4362-22d3-40d8-8818-2f82d1b8ffd4.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,43bf4362-22d3-40d8-8818-2f82d1b8ffd4.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=43bf4362-22d3-40d8-8818-2f82d1b8ffd4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Someone asked me today if I knew that you couldn't use GETDATE() in functions in SQL
Server. Well, I did, so I dug out this solution I had found a while back, and decided
to post it, since I am sure others have come across the same issue. 
</p>
        <p>
Basically, you use a view to do the work for you... here you go!
</p>
        <p>
CREATE VIEW Function_Assist_GETDATE
</p>
        <p>
/********************************************************<br />
*<br />
* A view to return one row, with one column, the current 
<br />
* date/time from the built-in function GETDATE().  This 
<br />
* view allows a UDF to bypass the restriction on access to 
<br />
* the non-deterministic getdate() function.<br />
*<br />
* Attribution: Based on a newsgroup posting in by Mikhail 
<br />
*   Berlyant in microsoft.public.sqlserver.programming 
<br />
* 
<br />
* Common Usage:<br />
DECLARE @dtVar datetime<br />
select @dtVAr = [GetDate] from Function_Assist_GETDATE<br />
**********************************************************/
</p>
        <p>
AS 
<br />
    SELECT getdate() as [GetDate]
</p>
        <p>
GO
</p>
        <p>
GRANT SELECT on Function_Assist_GETDATE to PUBLIC<br />
GO
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=43bf4362-22d3-40d8-8818-2f82d1b8ffd4" />
      </body>
      <title>Tip of the Day -- Using GetDate in functions</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,43bf4362-22d3-40d8-8818-2f82d1b8ffd4.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/03/11/TipOfTheDayUsingGetDateInFunctions.aspx</link>
      <pubDate>Fri, 11 Mar 2005 21:45:00 GMT</pubDate>
      <description>&lt;p&gt;
Someone asked me today if I knew that you couldn't use GETDATE() in functions in SQL
Server. Well, I did, so I dug out this solution I had found a while back, and decided
to post it, since I am sure others have come across the same issue. 
&lt;/p&gt;
&lt;p&gt;
Basically, you use a view to do the work for you... here you go!
&lt;/p&gt;
&lt;p&gt;
CREATE VIEW Function_Assist_GETDATE
&lt;/p&gt;
&lt;p&gt;
/********************************************************&lt;br&gt;
*&lt;br&gt;
* A view to return one row, with one column, the current 
&lt;br&gt;
* date/time from the built-in function GETDATE().&amp;nbsp; This 
&lt;br&gt;
* view allows a UDF to bypass the restriction on access to 
&lt;br&gt;
* the non-deterministic getdate() function.&lt;br&gt;
*&lt;br&gt;
* Attribution: Based on a newsgroup posting in by Mikhail 
&lt;br&gt;
*&amp;nbsp;&amp;nbsp; Berlyant in microsoft.public.sqlserver.programming 
&lt;br&gt;
* 
&lt;br&gt;
* Common Usage:&lt;br&gt;
DECLARE @dtVar datetime&lt;br&gt;
select @dtVAr = [GetDate] from Function_Assist_GETDATE&lt;br&gt;
**********************************************************/
&lt;/p&gt;
&lt;p&gt;
AS 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT getdate() as [GetDate]
&lt;/p&gt;
&lt;p&gt;
GO
&lt;/p&gt;
&lt;p&gt;
GRANT SELECT on Function_Assist_GETDATE to PUBLIC&lt;br&gt;
GO
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=43bf4362-22d3-40d8-8818-2f82d1b8ffd4" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,43bf4362-22d3-40d8-8818-2f82d1b8ffd4.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=80e3aae3-25f7-4fcb-ba45-62e0879ecc72</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,80e3aae3-25f7-4fcb-ba45-62e0879ecc72.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,80e3aae3-25f7-4fcb-ba45-62e0879ecc72.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=80e3aae3-25f7-4fcb-ba45-62e0879ecc72</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am currently trying to go through a Code Review at a large bank to get our code
approved for release on the internet. One thing that came up was in some situations,
we are displaying the raw exception message which was listed as a no-no, which I disagree
with. While it's not particularly informative to the user which is potentially an
issue, I can't see where “Invalid use of null” is going to be particularly
useful to a hacker, but to a developer, that tidbit may help identify the problem
when the user calls for help (good application logging aside in this example). Ironically,
when errors weren't handled because the developer forgot, this passed code review.
</p>
        <p>
So my intent was to enumerate all the default error messages to determine if there
are any which would be particularly helpful to a hacker. While I am still looking
to find or create an application which will enumerate all the default messages that
.New throws out, I did come across a great article which lists the various error handling
philosophies, and tries to weigh out the pros and cons of each. Here's where to get
this pearl of wisdom:
</p>
        <p>
          <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/exceptdotnet.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/exceptdotnet.asp</a>
        </p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=80e3aae3-25f7-4fcb-ba45-62e0879ecc72" />
      </body>
      <title>Tip of the Day -- Great Exception Handling article</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,80e3aae3-25f7-4fcb-ba45-62e0879ecc72.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/03/09/TipOfTheDayGreatExceptionHandlingArticle.aspx</link>
      <pubDate>Wed, 09 Mar 2005 17:47:50 GMT</pubDate>
      <description>&lt;p&gt;
I am currently trying to go through a Code Review at a large bank to get our code
approved for release on the internet. One thing that came up was in some situations,
we are displaying the raw exception message which was listed as a no-no, which I disagree
with. While it's not particularly informative to the user which is potentially an
issue, I can't see where &amp;#8220;Invalid use of null&amp;#8221; is going to be particularly
useful to a hacker, but to a developer, that tidbit may help identify the problem
when the user calls for help (good application logging aside in this example). Ironically,
when errors weren't handled because the developer forgot, this passed code review.
&lt;/p&gt;
&lt;p&gt;
So my intent was to enumerate all the default error messages to determine if there
are any which would be particularly helpful to a hacker. While I am still looking
to find or create an application which will enumerate all the default messages that
.New throws out, I did come across a great article which lists the various error handling
philosophies, and tries to weigh out the pros and cons of each. Here's where to get
this pearl of wisdom:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/exceptdotnet.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/exceptdotnet.asp&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=80e3aae3-25f7-4fcb-ba45-62e0879ecc72" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,80e3aae3-25f7-4fcb-ba45-62e0879ecc72.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=724942ca-29cf-43e6-ae54-cfc1b7485a60</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,724942ca-29cf-43e6-ae54-cfc1b7485a60.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,724942ca-29cf-43e6-ae54-cfc1b7485a60.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=724942ca-29cf-43e6-ae54-cfc1b7485a60</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I must be getting some hits on this site according to my referrals, but I am sure
it could be a ton more if I posted more. So, why haven't I been posting the tips
of the day?
</p>
        <p>
Well, they are going to be starting up again soon. I had to deliver 2 projects suddenly,
and pretty much all my waking hours were dedicated to actual work which brings in
cold-hard cash. So now I am officially down from 3 active projects to one full-time
project, so I should have some time to make some postings. 
</p>
        <p>
In that time, I have created a SOAP-based web service using DIME attachments, encryption
and compression, used a horrible product called Syncfusion for Excel manipulation,
developed invoicing PDF generation using DynamicPDF, written a Windows service, written
a Windows application, developed to “rough stuff” inner workings of 2
ASP.Net web sites, and put some enhancements on a VB6 program I originally developed
8 years ago (in VB4 originally -- talk about longevity!). Been a busy year so far!
</p>
        <p>
I also won a fairly large poker tournament in a local casino, and have a shot for
a satellite seat for the World Series of Poker. 
</p>
        <p>
But things are starting to slow down a bit, so start looking for more tips of the
day for things I have learned since the year began!
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=724942ca-29cf-43e6-ae54-cfc1b7485a60" />
      </body>
      <title>Where did the posts go?</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,724942ca-29cf-43e6-ae54-cfc1b7485a60.aspx</guid>
      <link>http://www.dotnettechnologies.com/2005/03/03/WhereDidThePostsGo.aspx</link>
      <pubDate>Thu, 03 Mar 2005 23:07:53 GMT</pubDate>
      <description>&lt;p&gt;
I must be getting some hits on this site according to my referrals, but I am sure
it could be a ton more if&amp;nbsp;I posted more. So, why haven't I been posting the tips
of the day?
&lt;/p&gt;
&lt;p&gt;
Well, they are going to be starting up again soon. I had to deliver 2 projects suddenly,
and pretty much all my waking hours were dedicated to actual work which brings in
cold-hard cash. So now I am officially down from 3 active projects to one full-time
project, so I should have some time to make some postings. 
&lt;/p&gt;
&lt;p&gt;
In that time, I have created a SOAP-based web service using DIME attachments, encryption
and compression, used a horrible product called Syncfusion for Excel manipulation,
developed invoicing PDF generation using DynamicPDF, written a Windows service, written
a Windows application, developed to &amp;#8220;rough stuff&amp;#8221; inner workings of 2
ASP.Net web sites, and put some enhancements on a VB6 program I originally developed
8 years ago (in VB4 originally -- talk about longevity!). Been a busy year so far!
&lt;/p&gt;
&lt;p&gt;
I also won a fairly large poker tournament in a local casino, and have a shot for
a satellite seat for the World Series of Poker. 
&lt;/p&gt;
&lt;p&gt;
But things are starting to slow down a bit, so start looking for more tips of the
day for things I have learned since the year began!
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=724942ca-29cf-43e6-ae54-cfc1b7485a60" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,724942ca-29cf-43e6-ae54-cfc1b7485a60.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=eea0c32f-1b4f-45d6-acb4-4dde56f38ffc</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,eea0c32f-1b4f-45d6-acb4-4dde56f38ffc.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,eea0c32f-1b4f-45d6-acb4-4dde56f38ffc.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=eea0c32f-1b4f-45d6-acb4-4dde56f38ffc</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
So, you want to get the value of an identity column after an insert so you can update
the UI or use it in another procedure. You've been using @@IDENTITY for ages, and
it has worked fine. But today, you're getting a new value. What's up?
</p>
        <p>
There are 3 (or more if you want to consider queries or identity tables) methods for
getting the identity value from a table after an insert. The methods are @@IDENTITY,
SCOPE_IDENTITY() and IDENT_CURRENT(). What's the difference?
</p>
        <p>
@@IDENTITY gets the last inserted identity value. The problem is, in a high-volumn
environment or one with triggers, it may not be the value you are expecting.
</p>
        <p>
The SCOPE_IDENTITY() function gets the last identity inserted within the same scope
(e.g. inside the procedure you're running). This is useful especially when your table
has triggers which might do another insert. You'll only get the identity value of
your change, not the trigger's.
</p>
        <p>
The IDENT_CURRENT('table_name') returns the last identity value for the specified
table, regardless of scope.
</p>
        <p>
So, for safety in your routines, if you want the value YOU inserted, try the SCOPE_IDENTITY
function for safety!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=eea0c32f-1b4f-45d6-acb4-4dde56f38ffc" />
      </body>
      <title>The difference between @@IDENTITY, SCOPE_IDENTITY(), and IDENT_CURRENT()</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,eea0c32f-1b4f-45d6-acb4-4dde56f38ffc.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/31/TheDifferenceBetweenIDENTITYSCOPEIDENTITYAndIDENTCURRENT.aspx</link>
      <pubDate>Fri, 31 Dec 2004 15:25:39 GMT</pubDate>
      <description>&lt;p&gt;
So, you want to get the value of an identity column after an insert so you can update
the UI or use it in another procedure. You've been using @@IDENTITY for ages, and
it has worked fine. But today, you're getting a new value. What's up?
&lt;/p&gt;
&lt;p&gt;
There are 3 (or more if you want to consider queries or identity tables) methods for
getting the identity value from a table after an insert. The methods are @@IDENTITY,
SCOPE_IDENTITY() and IDENT_CURRENT(). What's the difference?
&lt;/p&gt;
&lt;p&gt;
@@IDENTITY gets the last inserted identity value. The problem is, in a high-volumn
environment or one with triggers, it may not be the value you are expecting.
&lt;/p&gt;
&lt;p&gt;
The SCOPE_IDENTITY() function gets the last identity inserted within the same scope
(e.g. inside the procedure you're running). This is useful especially when your table
has triggers which might do another insert. You'll only get the identity value of
your change, not the trigger's.
&lt;/p&gt;
&lt;p&gt;
The IDENT_CURRENT('table_name') returns the last identity value for the specified
table, regardless of scope.
&lt;/p&gt;
&lt;p&gt;
So, for safety in your routines, if you want the value YOU inserted, try the SCOPE_IDENTITY
function for safety!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=eea0c32f-1b4f-45d6-acb4-4dde56f38ffc" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,eea0c32f-1b4f-45d6-acb4-4dde56f38ffc.aspx</comments>
      <category>All Things</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=64f0d00f-10c2-47f2-ba98-cfa86815c141</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,64f0d00f-10c2-47f2-ba98-cfa86815c141.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,64f0d00f-10c2-47f2-ba98-cfa86815c141.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=64f0d00f-10c2-47f2-ba98-cfa86815c141</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Here's a quick and dirty routine I use all the time. This simple procedure will list
all tables in your database where a particular field is found. Not earth shattering
by any means, but useful and since I find I use it all the time, I thought someone
else might find it userful and same them the brief effort to write their own!
</p>
        <p>
IF EXISTS(SELECT name FROM sysobjects WHERE name = 'sp_findField' AND type='P')<br />
BEGIN<br />
 DROP PROCEDURE sp_findField<br />
END<br />
GO
</p>
        <p>
CREATE PROCEDURE dbo.sp_findField (@fieldName varchar(100))<br />
AS<br />
BEGIN<br />
 SET NOCOUNT ON
</p>
        <p>
 SELECT so.name<br />
 FROM sysobjects so, syscolumns sc<br />
 WHERE so.id = sc.id<br />
 AND sc.name = @fieldName<br />
 ORDER BY so.name
</p>
        <p>
END<br />
GO
</p>
        <p>
GRANT EXECUTE ON sp_findField TO public<br />
GO
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=64f0d00f-10c2-47f2-ba98-cfa86815c141" />
      </body>
      <title>Finding all tables where a field exists in SQL Server</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,64f0d00f-10c2-47f2-ba98-cfa86815c141.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/30/FindingAllTablesWhereAFieldExistsInSQLServer.aspx</link>
      <pubDate>Thu, 30 Dec 2004 18:09:49 GMT</pubDate>
      <description>&lt;p&gt;
Here's a quick and dirty routine I use all the time. This simple procedure will list
all tables in your database where a particular field is found. Not earth shattering
by any means, but useful and since I find I use it all the time, I thought someone
else might find it userful and same them the brief effort to write their own!
&lt;/p&gt;
&lt;p&gt;
IF EXISTS(SELECT name FROM sysobjects WHERE name = 'sp_findField' AND type='P')&lt;br&gt;
BEGIN&lt;br&gt;
&amp;nbsp;DROP PROCEDURE sp_findField&lt;br&gt;
END&lt;br&gt;
GO
&lt;/p&gt;
&lt;p&gt;
CREATE PROCEDURE dbo.sp_findField (@fieldName varchar(100))&lt;br&gt;
AS&lt;br&gt;
BEGIN&lt;br&gt;
&amp;nbsp;SET NOCOUNT ON
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;SELECT so.name&lt;br&gt;
&amp;nbsp;FROM sysobjects so, syscolumns sc&lt;br&gt;
&amp;nbsp;WHERE so.id = sc.id&lt;br&gt;
&amp;nbsp;AND sc.name = @fieldName&lt;br&gt;
&amp;nbsp;ORDER BY so.name
&lt;/p&gt;
&lt;p&gt;
END&lt;br&gt;
GO
&lt;/p&gt;
&lt;p&gt;
GRANT EXECUTE ON sp_findField TO public&lt;br&gt;
GO
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=64f0d00f-10c2-47f2-ba98-cfa86815c141" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,64f0d00f-10c2-47f2-ba98-cfa86815c141.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=1509924c-e48d-4d6e-8af0-4562186eacfd</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,1509924c-e48d-4d6e-8af0-4562186eacfd.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,1509924c-e48d-4d6e-8af0-4562186eacfd.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1509924c-e48d-4d6e-8af0-4562186eacfd</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Here's another simple tip, but it does encapsulate some of the functionality needed
to format a DateTime (or a string) to a particular string format. First, from the
documentation, here's some examples of the DateTime formatting:
</p>
        <p>
          <strong>Column 1: Format String, Column 2: The format of the date</strong>
          <br />
          <font color="#0000ff">    ' d :08/17/2000<br />
    ' D :Thursday, August 17, 2000<br />
    ' f :Thursday, August 17, 2000 16:32<br />
    ' F :Thursday, August 17, 2000 16:32:32<br />
    ' g :08/17/2000 16:32<br />
    ' G :08/17/2000 16:32:32<br />
    ' m :August 17<br />
    ' r :Thu, 17 Aug 2000 23:32:32 GMT<br />
    ' s :2000-08-17T16:32:32<br />
    ' t :16:32<br />
    ' T :16:32:32<br />
    ' u :2000-08-17 23:32:32Z<br />
    ' U :Thursday, August 17, 2000 23:32:32<br />
    ' y :August, 2000<br />
    ' dddd, MMMM dd yyyy :Thursday, August 17 2000<br />
    ' ddd, MMM d "'"yy :Thu, Aug 17 '00<br />
    ' dddd, MMMM dd :Thursday, August 17<br />
    ' M/yy :8/00<br />
    ' dd-MM-yy :17-08-00</font>
        </p>
        <p>
          <font color="#0000ff">
            <font color="#000000">First, we'll need a function to verify
the string we have is a valid date. </font>
          </font>
        </p>
        <div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0pt; FONT-SIZE: 10pt; BACKGROUND: white; PADDING-BOTTOM: 0pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 0pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New">   
    <span style="COLOR: blue">public</span><span style="COLOR: blue">static</span><span style="COLOR: blue">bool</span> ValidDate(<span style="COLOR: blue">string</span> checkDate)<br />
        {<br />
            <span style="COLOR: blue">try</span><br />
            {<br />
                DateTime
dtTemp;<br />
                dtTemp
= DateTime.Parse(checkDate);<br />
                <span style="COLOR: blue">return</span><span style="COLOR: blue">true</span>;<br />
            }<br />
            <span style="COLOR: blue">catch</span><br />
            {<br />
                <span style="COLOR: blue">return</span><span style="COLOR: blue">false</span>;<br />
            }<br />
        }<br /></div>
        <p>
The ValidDate function takes a string, and returns true if the value is a valid date,
or false if it isn't.
</p>
        <p>
Next, here's the function for formatting the date:
</p>
        <div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0pt; FONT-SIZE: 10pt; BACKGROUND: white; PADDING-BOTTOM: 0pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 0pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New">
          <span style="COLOR: blue">public</span>
          <span style="COLOR: blue">static</span>
          <span style="COLOR: blue">string</span> FormatDateTimeCustom(<span style="COLOR: blue">string</span> valDate, <span style="COLOR: blue">string</span> formatString)<br />
{<br />
    <span style="COLOR: blue">if</span> (ValidDate(valDate))<br />
        <span style="COLOR: blue">return</span> Convert.ToDateTime(valDate).ToString(formatString);<br />
    <span style="COLOR: blue">else</span><br />
        <span style="COLOR: blue">return</span> valDate;<br />
}<br /></div>
        <p>
valDate = the string to format
</p>
        <p>
formatString = the format style as listed earlier
</p>
        <p>
That's it for today!<!--EndFragment--></p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1509924c-e48d-4d6e-8af0-4562186eacfd" />
      </body>
      <title>Tip of the Day: Formatting Dates</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,1509924c-e48d-4d6e-8af0-4562186eacfd.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/28/TipOfTheDayFormattingDates.aspx</link>
      <pubDate>Tue, 28 Dec 2004 17:07:14 GMT</pubDate>
      <description>&lt;p&gt;
Here's another simple tip, but it does encapsulate some of the functionality needed
to format a DateTime (or a string) to a particular string format. First, from the
documentation, here's some examples of the DateTime formatting:
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Column 1: Format String, Column 2: The format of the date&lt;/strong&gt;
&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' d :08/17/2000&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' D :Thursday, August 17, 2000&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' f :Thursday, August 17, 2000 16:32&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' F :Thursday, August 17, 2000 16:32:32&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' g :08/17/2000 16:32&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' G :08/17/2000 16:32:32&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' m :August 17&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' r :Thu, 17 Aug 2000 23:32:32 GMT&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' s :2000-08-17T16:32:32&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' t :16:32&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' T :16:32:32&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' u :2000-08-17 23:32:32Z&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' U :Thursday, August 17, 2000 23:32:32&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' y :August, 2000&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' dddd, MMMM dd yyyy :Thursday, August 17 2000&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' ddd, MMM d "'"yy :Thu, Aug 17 '00&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' dddd, MMMM dd :Thursday, August 17&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' M/yy :8/00&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ' dd-MM-yy :17-08-00&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff&gt;&lt;font color=#000000&gt;First, we'll need a function to verify the
string we have is a valid date. &lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&gt;&gt; 
&lt;div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0pt; FONT-SIZE: 10pt; BACKGROUND: white; PADDING-BOTTOM: 0pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 0pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; ValidDate(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; checkDate)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;try&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; DateTime
dtTemp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; dtTemp
= DateTime.Parse(checkDate);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;catch&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/div&gt;
&lt;p&gt;
The ValidDate function takes a string, and returns true if the value is a valid date,
or false if it isn't.
&lt;/p&gt;
&lt;p&gt;
Next, here's the function for formatting the date:
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0pt; FONT-SIZE: 10pt; BACKGROUND: white; PADDING-BOTTOM: 0pt; BORDER-LEFT: windowtext 1pt solid; COLOR: black; PADDING-TOP: 0pt; BORDER-BOTTOM: windowtext 1pt solid; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; FormatDateTimeCustom(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; valDate, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; formatString)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (ValidDate(valDate))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; Convert.ToDateTime(valDate).ToString(formatString);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; valDate;&lt;br&gt;
}&lt;br&gt;
&lt;/div&gt;
&lt;p&gt;
valDate = the string to format
&lt;/p&gt;
&lt;p&gt;
formatString = the format style as listed earlier
&lt;/p&gt;
&lt;p&gt;
That's it for today!&lt;!--EndFragment--&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1509924c-e48d-4d6e-8af0-4562186eacfd" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,1509924c-e48d-4d6e-8af0-4562186eacfd.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>General</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=c775d82f-a394-47f6-9f9b-a0ac75f57738</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,c775d82f-a394-47f6-9f9b-a0ac75f57738.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,c775d82f-a394-47f6-9f9b-a0ac75f57738.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=c775d82f-a394-47f6-9f9b-a0ac75f57738</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
While not 100%, you can look at the following to see what control caused the postback
on a form:
</p>
        <p>
Request.Form("__EVENTTARGET") 
</p>
        <p>
It works because ASP.Net uses javascript to handle the postback functionality, and
the __EVENTTARGET query string value can contain the name of the control which caused
the postback.
</p>
        <p>
Want to know what arguments are being passed during the postback? Take a look at the
Request.Form(”__EVENTARGUMENT”) value!
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=c775d82f-a394-47f6-9f9b-a0ac75f57738" />
      </body>
      <title>Tip of the Day: Determining which control caused the Postback</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,c775d82f-a394-47f6-9f9b-a0ac75f57738.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/27/TipOfTheDayDeterminingWhichControlCausedThePostback.aspx</link>
      <pubDate>Mon, 27 Dec 2004 22:19:36 GMT</pubDate>
      <description>&lt;p&gt;
While not 100%, you can look at the following to see what control caused the postback
on a form:
&lt;/p&gt;
&lt;p&gt;
Request.Form("__EVENTTARGET") 
&lt;/p&gt;
&lt;p&gt;
It works because ASP.Net uses javascript to handle the postback functionality, and
the __EVENTTARGET query string value can contain the name of the control which caused
the postback.
&lt;/p&gt;
&lt;p&gt;
Want to know what arguments are being passed during the postback? Take a look at the
Request.Form(&amp;#8221;__EVENTARGUMENT&amp;#8221;) value!
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=c775d82f-a394-47f6-9f9b-a0ac75f57738" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,c775d82f-a394-47f6-9f9b-a0ac75f57738.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=e937e61b-2cc7-4108-8664-f0151d044e05</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,e937e61b-2cc7-4108-8664-f0151d044e05.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,e937e61b-2cc7-4108-8664-f0151d044e05.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e937e61b-2cc7-4108-8664-f0151d044e05</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I don't think you can be a real effective ASP.Net programmer (personal opinion alert)
unless you can do SOME javascript. Postbacks not only increase your server load, they
can also detract from your user's experience on your ASP.Net site.
</p>
        <p>
The downside is that working with javascript is that it's always been tough to debug
(if not impossible), as well as untyped, but that part's an aside. Well, it's tough
no more. Here's today's tip(s). First, enabling debugging:
</p>
        <ol>
          <li>
Open your browser, open the <em><strong>Tools</strong></em> menu, and select the <em><strong>Internet
Options</strong></em> menu item.</li>
          <li>
On the <strong><em>Advanced</em></strong> tab, locate the <strong><em>Browser</em></strong> section,
and uncheck “Disable Script Debugging“ (see image below).</li>
          <li>
When you fire up the ASP.Net debugger (either manually or by default), make sure the
“Client Script“ option is selected.</li>
          <li>
Trigger the javascript.</li>
        </ol>
        <p>
          <img height="452" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/advanced.jpg" width="406" border="0" />
        </p>
        <p>
Image 1: Browser Options
</p>
        <p>
          <img height="352" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/attach.jpg" width="402" border="0" />
        </p>
        <p>
Image 2: Setting the script debugging in the Process Debugging command in .Net
</p>
        <p>
OK, you're all set for debugging. So what! Well, the thing I learned today was how
to break into the script (without an error, which causes it to trigger debugging automatically)
is to add the following script where you want to break:
</p>
        <p>
debugger;
</p>
        <p>
Your web page will break right there, and you'll be able to step through it just like
you would your normal ASP.Net page, with local variable browsing and everything!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=e937e61b-2cc7-4108-8664-f0151d044e05" />
      </body>
      <title>Tip of the Day: Debugging Javascript in ASP.Net</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,e937e61b-2cc7-4108-8664-f0151d044e05.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/21/TipOfTheDayDebuggingJavascriptInASPNet.aspx</link>
      <pubDate>Tue, 21 Dec 2004 21:26:19 GMT</pubDate>
      <description>&lt;p&gt;
I don't think you can be a real effective ASP.Net programmer (personal opinion alert)
unless you can do SOME javascript. Postbacks not only increase your server load, they
can also detract from your user's experience on your ASP.Net site.
&lt;/p&gt;
&lt;p&gt;
The downside is that working with javascript is that it's always been tough to debug
(if not impossible), as well as untyped, but that part's an aside. Well, it's tough
no more. Here's today's tip(s). First, enabling debugging:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Open your browser, open the &lt;em&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;/em&gt; menu, and select the &lt;em&gt;&lt;strong&gt;Internet
Options&lt;/strong&gt;&lt;/em&gt; menu item.&lt;/li&gt;
&lt;li&gt;
On the &lt;strong&gt;&lt;em&gt;Advanced&lt;/em&gt;&lt;/strong&gt; tab, locate the &lt;strong&gt;&lt;em&gt;Browser&lt;/em&gt;&lt;/strong&gt; section,
and uncheck &amp;#8220;Disable Script Debugging&amp;#8220; (see image below).&lt;/li&gt;
&lt;li&gt;
When you fire up the ASP.Net debugger (either manually or by default), make sure the
&amp;#8220;Client Script&amp;#8220; option is selected.&lt;/li&gt;
&lt;li&gt;
Trigger the javascript.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
&lt;img height=452 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/advanced.jpg" width=406 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Image 1: Browser Options
&lt;/p&gt;
&lt;p&gt;
&lt;img height=352 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/attach.jpg" width=402 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Image 2: Setting the script debugging in the Process Debugging command in .Net
&lt;/p&gt;
&lt;p&gt;
OK, you're all set for debugging. So what! Well, the thing I learned today was how
to break into the script (without an error, which causes it to trigger debugging automatically)
is to add the following script where you want to break:
&lt;/p&gt;
&lt;p&gt;
debugger;
&lt;/p&gt;
&lt;p&gt;
Your web page will break right there, and you'll be able to step through it just like
you would your normal ASP.Net page, with local variable browsing and everything!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=e937e61b-2cc7-4108-8664-f0151d044e05" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,e937e61b-2cc7-4108-8664-f0151d044e05.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=69344e13-41ae-43dc-8743-f896052ebd1f</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,69344e13-41ae-43dc-8743-f896052ebd1f.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,69344e13-41ae-43dc-8743-f896052ebd1f.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=69344e13-41ae-43dc-8743-f896052ebd1f</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Say what you will about VB, it does have some wrappers for some neat functions. One
of my favorites is the Split function. Essentially, it takes a string, a parse character
parameter, and returns a string array of the items. For example, it might look like
string[] mystring = Split(myCommaDelimitedString,”,”);
</p>
        <p>
          <font color="#0033cc">So here's what the code looks like:</font>
        </p>
        <p>
          <font color="#0033cc">  /// &lt;summary&gt;<br />
  /// Replacement in C# of the VB.Net split function<br />
  /// &lt;/summary&gt;<br />
  /// &lt;param name="baseString"&gt;string to parse&lt;/param&gt;<br />
  /// &lt;param name="splitChar"&gt;chanracter to parse with &lt;/param&gt;<br />
  /// &lt;returns&gt;&lt;/returns&gt;<br />
  public static string[] Split(string baseString, string splitChar)<br />
  {<br />
   char[] sep = {(splitChar.ToCharArray())[0]};<br />
   return baseString.Split(sep);<br />
  }</font>
        </p>
        <p>
Now, I know you can use the string object's split functionality to do the same thing.
However, those coming out of the VB world will appreciate the encapsulation, as well
as never having to remember the syntax for pre-defining a character array.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=69344e13-41ae-43dc-8743-f896052ebd1f" />
      </body>
      <title>Implementing the Split function in C#</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,69344e13-41ae-43dc-8743-f896052ebd1f.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/20/ImplementingTheSplitFunctionInC.aspx</link>
      <pubDate>Mon, 20 Dec 2004 21:13:55 GMT</pubDate>
      <description>&lt;p&gt;
Say what you will about VB, it does have some wrappers for some neat functions. One
of my favorites is the Split function. Essentially, it takes a string, a parse character
parameter, and returns a string array of the items. For example, it might look like
string[] mystring = Split(myCommaDelimitedString,&amp;#8221;,&amp;#8221;);
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0033cc&gt;So here's what the code looks like:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0033cc&gt;&amp;nbsp;&amp;nbsp;/// &amp;lt;summary&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;/// Replacement in C# of the VB.Net split function&lt;br&gt;
&amp;nbsp;&amp;nbsp;/// &amp;lt;/summary&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;/// &amp;lt;param name="baseString"&amp;gt;string to parse&amp;lt;/param&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;/// &amp;lt;param name="splitChar"&amp;gt;chanracter to parse with &amp;lt;/param&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;public static string[] Split(string baseString, string splitChar)&lt;br&gt;
&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;char[] sep = {(splitChar.ToCharArray())[0]};&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;return baseString.Split(sep);&lt;br&gt;
&amp;nbsp;&amp;nbsp;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Now, I know you can use the string object's split functionality to do the same thing.
However, those coming out of the VB world will appreciate the encapsulation, as well
as never having to remember the syntax for pre-defining a character array.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=69344e13-41ae-43dc-8743-f896052ebd1f" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,69344e13-41ae-43dc-8743-f896052ebd1f.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=9fd1a674-dc81-412e-b5cd-70b2467c00b7</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,9fd1a674-dc81-412e-b5cd-70b2467c00b7.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,9fd1a674-dc81-412e-b5cd-70b2467c00b7.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9fd1a674-dc81-412e-b5cd-70b2467c00b7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the things I use this blog for is to keep track of tips which I may need while
out at the client site. I have a fairly extensive CodeLib library I use, but for some
reason, I didn't have this in my library. 
</p>
        <p>
If you're new to javascript, which I am definitely still in the learning stages of,
at some point you are going to access the control which called a function. I did a
few searches, and it turns out, unless you know what you are looking for, it's tough
to do a search like “javascript determining control which called a function”
and similar searches. So here goes, and hopefully this simple tip will save another
developer a little time. It IS a basic function, I will be the first to admit, but
it is also useful to know for an ASP.Net developer. And the code is:
</p>
        <p>
document.activeElement
</p>
        <p>
There you go! Simple, but for some reason, it's assumed you should know it, which
to a degree, I agree with. But I would also have to say online there seems to be an
assumption that everyone already knows the DOM!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9fd1a674-dc81-412e-b5cd-70b2467c00b7" />
      </body>
      <title>Tip of the day - Javascript - Getting the control which called a function</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,9fd1a674-dc81-412e-b5cd-70b2467c00b7.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/18/TipOfTheDayJavascriptGettingTheControlWhichCalledAFunction.aspx</link>
      <pubDate>Sat, 18 Dec 2004 21:55:17 GMT</pubDate>
      <description>&lt;p&gt;
One of the things I use this blog for is to keep track of tips which I may need while
out at the client site. I have a fairly extensive CodeLib library I use, but for some
reason, I didn't have this in my library. 
&lt;/p&gt;
&lt;p&gt;
If you're new to javascript, which I am definitely still in the learning stages of,
at some point you are going to access the control which called a function. I did a
few searches, and it turns out, unless you know what you are looking for, it's tough
to do a search like &amp;#8220;javascript determining control which called a function&amp;#8221;
and similar searches. So here goes, and hopefully this simple tip will save another
developer a little time. It IS a basic function, I will be the first to admit, but
it is also useful to know for an ASP.Net developer. And the code is:
&lt;/p&gt;
&lt;p&gt;
document.activeElement
&lt;/p&gt;
&lt;p&gt;
There you go! Simple, but for some reason, it's assumed you should know it, which
to a degree, I agree with. But I would also have to say online there seems to be an
assumption that everyone already knows the DOM!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9fd1a674-dc81-412e-b5cd-70b2467c00b7" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,9fd1a674-dc81-412e-b5cd-70b2467c00b7.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>Tips and Tricks</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=9e2de6f0-e90a-42f1-a3ee-ac6bf479cf53</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,9e2de6f0-e90a-42f1-a3ee-ac6bf479cf53.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,9e2de6f0-e90a-42f1-a3ee-ac6bf479cf53.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9e2de6f0-e90a-42f1-a3ee-ac6bf479cf53</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Do you have a routine which you know works, and you don't want to have to step into
when you're debugging? Granted, you could you the hotkeys to do it, but why bother?
The System.Diagnostics namespace provides some neat functionality for helping you
in your debugging process. Here's some examples:
</p>
        <p>
//This attribute prevents the debugger from entering, as well as no breakpoints within
</p>
        <p>
&lt;System.Diagnostics.DebuggerStepThrough()&gt; 
</p>
        <p>
private string MyRoutine()
</p>
        <p>
{
</p>
        <p>
//Don't step through this
</p>
        <p>
}
</p>
        <p>
I am actually not sure what the difference between that and the DebuggerHidden() attribute
is though. The description in the help is the same. Anyone know?
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9e2de6f0-e90a-42f1-a3ee-ac6bf479cf53" />
      </body>
      <title>Skipping over a routine automatically in the debugger, and other neat debugger tricks..</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,9e2de6f0-e90a-42f1-a3ee-ac6bf479cf53.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/15/SkippingOverARoutineAutomaticallyInTheDebuggerAndOtherNeatDebuggerTricks.aspx</link>
      <pubDate>Wed, 15 Dec 2004 20:15:13 GMT</pubDate>
      <description>&lt;p&gt;
Do you have a routine which you know works, and you don't want to have to step into
when you're debugging? Granted, you could you the hotkeys to do it, but why bother?
The System.Diagnostics namespace provides some neat functionality for helping you
in your debugging process. Here's some examples:
&lt;/p&gt;
&lt;p&gt;
//This attribute prevents the debugger from entering, as well as no breakpoints within
&lt;/p&gt;
&lt;p&gt;
&amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; 
&lt;/p&gt;
&lt;p&gt;
private string MyRoutine()
&lt;/p&gt;
&lt;p&gt;
{
&lt;/p&gt;
&lt;p&gt;
//Don't step through this
&lt;/p&gt;
&lt;p&gt;
}
&lt;/p&gt;
&lt;p&gt;
I am actually not sure what the difference between that and the DebuggerHidden() attribute
is though. The description in the help is the same. Anyone know?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9e2de6f0-e90a-42f1-a3ee-ac6bf479cf53" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,9e2de6f0-e90a-42f1-a3ee-ac6bf479cf53.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>Tips and Tricks</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=33c1ea8a-2aff-47e3-af42-71ad24e06a91</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,33c1ea8a-2aff-47e3-af42-71ad24e06a91.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,33c1ea8a-2aff-47e3-af42-71ad24e06a91.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=33c1ea8a-2aff-47e3-af42-71ad24e06a91</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am a huge fan of SQL Server. Don't get me wrong, there's nothing wrong with Oracle
per se, other than it's tough to get it to run right and efficiently, and not for
the amateur. If I was considering cross-platform work, Oracle would be the choice
for me. For everything else, there's SQL Server, and when the next version comes out,
look out!
</p>
        <p>
But one “downfall” of SQL Server is that it becomes very easy to believe
you can administer a production database with only Access skills, or worse, none at
all. Some stories come to mind from my experiences.
</p>
        <p>
First, I was doing a project for a large state agency, and at the time no one but
the DBA could touch the SQL Server, or directly run script against the production
server. I needed a very simple update script run, so I wrote it out, and gave it to
the “DBA” to execute. He returns in about 5 minutes and tells me it doesn't
run, and asked if I would mind taking a look at it. I did, and I had accidentally
pasted two “set” keywords in a row. Even a Jr. Developer with a minutia
of SQL experience should have seen this and been able to fix it. So, I fix it, and
I asked him why he didn't just erase the extra “set”. is reply: I don't
know SQL. Please keep it quiet.
</p>
        <p>
Mind you, this guy was touted as a Sr. DBA, and responsible for about 16 databases
which control some very important data. Unfortunately, this wasn't the worst of it. 
</p>
        <p>
One day I was using the restroom (that's important to the story), and he comes in
and begins using the stall next to me. We begin some general chit-chat, and he's excited
he can tell me something about SQL I might not know. His epiphany? “I went to
a class, and we learned about indexes in it! I am so excited to start trying them
out!” Well, since we had never been able to directly access the database, I
had just solved some of our performance problems. I also got access to the databases
from that day forward..
</p>
        <p>
Another performance story. I was doing a project for an Internet startup, and I overheard
they were having some SQL Server performance problems. The sign-ups for their site
was killing their SQL Server with all the activity. I offered to take a look at it,
but there was a definite anti-Microsoft spin at the company, and they were going to
switch to Oracle because the owner had been told it was simply because Microsoft can't
keep up with Oracle. I was working on a VB application for them, so they assumed wrongly
that I didn't know databases very well.
</p>
        <p>
So, they hire a team of Oracle (weren't employees of the Oracle Corp, just for reference) developers,
and in 4 months and almost $300,000 later, it still wasn't up and running. The owner
was bleeding cash, and was pressing the Oracle team to find out when the database
conversion would be done and the bleeding would stop. They then informed him
it would be about another month (and $100K), but even then they'd need to keep one
of them one to maintain the database, or hire a full time Oracle DBA.
</p>
        <p>
So I re-enter the SQL Server discussion with the owner. I ask him to let me look at
the SQL Server configuration, and maybe I can buy him some time until the Oracle system
is ready to go. Immediately, I see there are no indexes on the tables, and the stored procedures
were very inefficient. By adding indexes alone, the performance gain alone went from
~98% resources used on the server (processor and memory) to less than 5% peak usage.
The Oracle team was gone the next day (sorry guys), and the SQL Server portion ran
flawlessly from that day on. But something so simple cost over $300K and wasted four
months, and probably cost the company a lot of lost business.
</p>
        <p>
My point is this: SQL Server is simple to use, but you have to educate yourself on
how to use it best, because in some ways it makes it way too easy to think you are
doing the right thing, when in fact it can have a huge impact on your performance.
Next thing you know, you think the server can't handle it and you're out $20K on a
new server which you don't need.
</p>
        <p>
Case in point: I was hired by a bank to help a team of new developer's get up to speed
in VB.Net and ASP.Net (I tried to get them to go C#, but that's another story). Their
application was simple, but every day the resources on the server(s) were getting
pegged and the entire system was unusable until the next reboot. 
</p>
        <p>
I decided looking into this would need to be a top priority. I checked the indexes,
and they all looked good, but we did some tweaking there, and the problem was still
occurring. I finally pull out the SQL Performance Analyzer, and quickly nail down
there is a serious disk I/O problem. For example, I pull out a small table of about
200 rows, and do a select *, and it turns out it take 3000 disk I/O's to get it. The
indexes were fine, and the record size was small, so there was something else going
on. 
</p>
        <p>
On a hunch, I check to see if the disk drive is fragmented. Holy crap! It looked
as if it had never been defragged, and come to find out, it hadn't. The network admin
responsible for this production machine advised me the way he builds the machines
means that they never have to be defragged. So I show him an image of the fragmentation
on the drives, and he thinks I rigged it. End of conversation with him. 
</p>
        <p>
So I fix the problem, then ask for $200 for a program to schedule the de-fragmentation
automatically. I don't get it, so I now have to manually defrag it once per week.
Cost? Well, for me to track it down, and the time spent every week over a year and
a half? Likely over $5000. Go figure.
</p>
        <p>
I tried to get the employees there to take responsibility for doing it, but it never
seemed to be a priority for them. So when I left to being a new project, I reminded
them someone needed to do it. Well, I can assume for a while someone did. But I am
back there, and yesterday there were complaints of poor performance. And guess what
I found when I checked? The drives were very fragmented. One is so full and so bad,
I think we're going to have to drop all the indexes, defragment, then rebuild them.
That's gonna cost a ton of time and money. The $200 is going to be budgeted this time.
</p>
        <p>
The tip: Make sure you keep your SQL Server data and index drives defragmented. Failure
to do so can have a huge impact on your SQL Performance, since in the end, SQL Server
relies on quick disk I/O to perform well.
</p>
        <p>
-- Daryl
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=33c1ea8a-2aff-47e3-af42-71ad24e06a91" />
      </body>
      <title>Tip of the Day: The Importance of Defragging your SQL Server drive</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,33c1ea8a-2aff-47e3-af42-71ad24e06a91.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/11/TipOfTheDayTheImportanceOfDefraggingYourSQLServerDrive.aspx</link>
      <pubDate>Sat, 11 Dec 2004 18:29:51 GMT</pubDate>
      <description>&lt;p&gt;
I am a huge fan of SQL Server. Don't get me wrong, there's nothing wrong with Oracle
per se, other than it's tough to get it to run right and efficiently, and not for
the amateur. If I was considering cross-platform work, Oracle would be the choice
for me. For everything else, there's SQL Server, and when the next version comes out,
look out!
&lt;/p&gt;
&lt;p&gt;
But one &amp;#8220;downfall&amp;#8221; of SQL Server is that it becomes very easy to believe
you can administer a production database with only Access skills, or worse, none at
all. Some stories come to mind from my experiences.
&lt;/p&gt;
&lt;p&gt;
First, I was doing a project for a large state agency, and at the time no one but
the DBA could touch the SQL Server, or directly run script against the production
server. I needed a very simple update script run, so I wrote it out, and gave it to
the &amp;#8220;DBA&amp;#8221; to execute. He returns in about 5 minutes and tells me it doesn't
run, and asked if I would mind taking a look at it. I did, and I had accidentally
pasted two &amp;#8220;set&amp;#8221; keywords in a row. Even a Jr. Developer with a minutia
of SQL experience should have seen this and been able to fix it. So, I fix it, and
I asked him why he didn't just erase the extra &amp;#8220;set&amp;#8221;. is reply: I don't
know SQL. Please keep it quiet.
&lt;/p&gt;
&lt;p&gt;
Mind you, this guy was touted as a Sr. DBA, and responsible for about 16 databases
which control some very important data. Unfortunately, this wasn't the worst of it. 
&lt;/p&gt;
&lt;p&gt;
One day I was using the restroom (that's important to the story), and he comes in
and begins using the stall next to me. We begin some general chit-chat, and he's excited
he can tell me something about SQL I might not know. His epiphany? &amp;#8220;I went to
a class, and we learned about indexes in it! I am so excited to start trying them
out!&amp;#8221; Well, since we had never been able to directly access the database, I
had just solved some of our performance problems. I also got access to the databases
from that day forward..
&lt;/p&gt;
&lt;p&gt;
Another performance story. I was doing a project for an Internet startup, and I overheard
they were having some SQL Server performance problems. The sign-ups for their site
was killing their SQL Server with all the activity. I offered to take a look at it,
but there was a definite anti-Microsoft spin at the company, and they were going to
switch to Oracle because the owner had been told it was simply because Microsoft can't
keep up with Oracle. I was working on a VB application for them, so they assumed wrongly
that I didn't know databases very well.
&lt;/p&gt;
&lt;p&gt;
So, they hire a team of Oracle (weren't employees of the Oracle Corp, just for reference)&amp;nbsp;developers,
and in 4 months and almost $300,000 later, it still wasn't up and running. The owner
was bleeding cash, and was pressing the Oracle team to find out when&amp;nbsp;the database
conversion&amp;nbsp;would be done and the bleeding would stop. They then informed him
it would be about another month (and $100K), but even then they'd need to keep one
of them one to maintain the database, or hire a full time Oracle DBA.
&lt;/p&gt;
&lt;p&gt;
So I re-enter the SQL Server discussion with the owner. I ask him to let me look at
the SQL Server configuration, and maybe I can buy him some time until the Oracle system
is ready to go. Immediately, I see there are no indexes on the tables, and the stored&amp;nbsp;procedures
were very inefficient. By adding indexes alone, the performance gain alone went from
~98% resources used on the server (processor and memory) to less than 5% peak usage.
The Oracle team was gone the next day (sorry guys), and the SQL Server portion ran
flawlessly from that day on. But something so simple cost over $300K and wasted four
months, and probably cost the company a lot of lost business.
&lt;/p&gt;
&lt;p&gt;
My point is this: SQL Server is simple to use, but you have to educate yourself on
how to use it best, because in some ways it makes it way too easy to think you are
doing the right thing, when in fact it can have a huge impact on your performance.
Next thing you know, you think the server can't handle it and you're out $20K on a
new server which you don't need.
&lt;/p&gt;
&lt;p&gt;
Case in point: I was hired by a bank to help a team of new developer's get up to speed
in VB.Net and ASP.Net (I tried to get them to go C#, but that's another story). Their
application was simple, but every day the resources on the server(s) were getting
pegged and the entire system was unusable until the next reboot. 
&lt;/p&gt;
&lt;p&gt;
I decided looking into this would need to be a top priority. I checked the indexes,
and they all looked good, but we did some tweaking there, and the problem was still
occurring. I finally pull out the SQL Performance Analyzer, and quickly nail down
there is a serious disk I/O problem. For example, I pull out a small table of about
200 rows, and do a select *, and it turns out it take 3000 disk I/O's to get it. The
indexes were fine, and the record size was small, so there was something else going
on. 
&lt;/p&gt;
&lt;p&gt;
On a hunch,&amp;nbsp;I check to see if the disk drive is fragmented. Holy crap! It looked
as if it had never been defragged, and come to find out, it hadn't. The network admin
responsible for this production machine advised me the way he builds the machines
means that they never have to be defragged. So I show him an image of the fragmentation
on the drives, and he thinks I rigged it. End of conversation with him. 
&lt;/p&gt;
&lt;p&gt;
So I fix the problem, then ask for $200 for a program to schedule the de-fragmentation
automatically. I don't get it, so I now have to manually defrag it once per week.
Cost? Well, for me to track it down, and the time spent every week over a year and
a half? Likely over $5000. Go figure.
&lt;/p&gt;
&lt;p&gt;
I tried to get the employees there to take responsibility for doing it, but it never
seemed to be a priority for them. So when I left to being a new project, I reminded
them someone needed to do it. Well, I can assume for a while someone did. But I am
back there, and yesterday there were complaints of poor performance. And guess what
I found when I checked? The drives were very fragmented. One is so full and so bad,
I think we're going to have to drop all the indexes, defragment, then rebuild them.
That's gonna cost a ton of time and money. The $200 is going to be budgeted this time.
&lt;/p&gt;
&lt;p&gt;
The tip: Make sure you keep your SQL Server data and index drives defragmented. Failure
to do so can have a huge impact on your SQL Performance, since in the end, SQL Server
relies on quick disk I/O to perform well.
&lt;/p&gt;
&lt;p&gt;
-- Daryl
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=33c1ea8a-2aff-47e3-af42-71ad24e06a91" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,33c1ea8a-2aff-47e3-af42-71ad24e06a91.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>SQL Tips</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=53bbfb29-c343-4e75-9f9f-c54021a83496</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,53bbfb29-c343-4e75-9f9f-c54021a83496.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,53bbfb29-c343-4e75-9f9f-c54021a83496.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=53bbfb29-c343-4e75-9f9f-c54021a83496</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was out late last night in my first “real” poker tournament, so I am
a bit too tired to whip out some good code. (I did OK at the tournament, and hit my
target, just as an FYI). So tonight's tip is going to be about a great set of free
components I use occasionally in ASP.Net. And at least for this one, you can get the
source at a very reasonable price. Check these out:
</p>
        <p>
          <a href="http://www.eworldui.net/CustomControls/" target="_blank">Excentrics World</a>
        </p>
        <p>
They have a great collapsible panel, masked textbox, breadcrumb tracker and a popup
calendar, plus a few others. Definitely worth looking, and throw him a bone and buy
the source!
</p>
        <p>
More cool tools I have found if I can stay awake!
</p>
        <p>
-- Daryl
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=53bbfb29-c343-4e75-9f9f-c54021a83496" />
      </body>
      <title>Some great free tools for ASP.Net</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,53bbfb29-c343-4e75-9f9f-c54021a83496.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/10/SomeGreatFreeToolsForASPNet.aspx</link>
      <pubDate>Fri, 10 Dec 2004 02:30:27 GMT</pubDate>
      <description>&lt;p&gt;
I was out late last night in my first &amp;#8220;real&amp;#8221; poker tournament, so I am
a bit too tired to whip out some good code. (I did OK at the tournament, and hit my
target, just as an FYI). So tonight's tip is going to be about a great set of free
components I use occasionally in ASP.Net. And at least for this one, you can get the
source at a very reasonable price. Check these out:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.eworldui.net/CustomControls/" target=_blank&gt;Excentrics World&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
They have a great collapsible panel, masked textbox, breadcrumb tracker and a&amp;nbsp;popup
calendar, plus a few others. Definitely worth looking, and throw him a bone and buy
the source!
&lt;/p&gt;
&lt;p&gt;
More cool tools I have found if I can stay awake!
&lt;/p&gt;
&lt;p&gt;
-- Daryl
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=53bbfb29-c343-4e75-9f9f-c54021a83496" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,53bbfb29-c343-4e75-9f9f-c54021a83496.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>General</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=a80953ac-6633-43e2-9e17-6e847ccb94d0</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,a80953ac-6633-43e2-9e17-6e847ccb94d0.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,a80953ac-6633-43e2-9e17-6e847ccb94d0.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a80953ac-6633-43e2-9e17-6e847ccb94d0</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Here's a quick tip for casting to a particular type if you have the name of the type.
Once again, it may be obvious to some, but if you've never done it, it's tough to
find a quick example of it, so here goes.
</p>
        <p>
I was implementing a custom ViewState for an UserControl I was creating, and came
across a situation where I needed to dynamically box a type, when all I know is the
type which I have stored in a string. I am creating a special container control which
can host any other type of control, and for restoring ViewState, I needed to cast
it correctly when restored. Fortunately, I followed a hunch, and came across the answer
-- System.Type.GetType.
</p>
        <p>
string testType = “System.Int32“;
</p>
        <p>
Type myType1 = Type.GetType(testType);
</p>
        <p>
Not Earth shattering, but then again, you have to know where to look!<br /></p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a80953ac-6633-43e2-9e17-6e847ccb94d0" />
      </body>
      <title>Tip of the Day: Dynamically boxing a type in C#</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,a80953ac-6633-43e2-9e17-6e847ccb94d0.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/08/TipOfTheDayDynamicallyBoxingATypeInC.aspx</link>
      <pubDate>Wed, 08 Dec 2004 14:49:20 GMT</pubDate>
      <description>&lt;p&gt;
Here's a quick tip for casting to a particular type if you have the name of the type.
Once again, it may be obvious to some, but if you've never done it, it's tough to
find a quick example of it, so here goes.
&lt;/p&gt;
&lt;p&gt;
I was implementing a custom ViewState for an UserControl I was creating, and came
across a situation where I needed to dynamically box a type, when all I know is the
type which I have stored in a string. I am creating a special container control which
can host any other type of control, and for restoring ViewState, I needed to cast
it correctly when restored. Fortunately, I followed a hunch, and came across the answer
-- System.Type.GetType.
&lt;/p&gt;
&lt;p&gt;
string testType = &amp;#8220;System.Int32&amp;#8220;;
&lt;/p&gt;
&lt;p&gt;
Type myType1 = Type.GetType(testType);
&lt;/p&gt;
&lt;p&gt;
Not Earth shattering, but then again, you have to know where to look!&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=a80953ac-6633-43e2-9e17-6e847ccb94d0" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,a80953ac-6633-43e2-9e17-6e847ccb94d0.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=01fdbb59-0e3c-4a8e-b853-662341bab110</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,01fdbb59-0e3c-4a8e-b853-662341bab110.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,01fdbb59-0e3c-4a8e-b853-662341bab110.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=01fdbb59-0e3c-4a8e-b853-662341bab110</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
OK, so you're looking at some really obscure code, so it's time to step in and see
exactly what it's doing, and the best way to do it is use the debugger. Actually,
if I have to give you a reason to use the debugger, you probably shouldn't be reading
this in the first place. You fire up the VS IDE, hit F5, and viola! You see the following
scary message:
</p>
        <p>
          <img height="139" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/failure.jpg" width="551" border="0" />
        </p>
        <p>
What the heck? “Error when typing to run project: Unable to start debugging
on the web server. Catastrophic failure.”
</p>
        <p>
Likely you won't see this unless you don't have Admin privledges on the box. Right
now, I am doing a project for a large bank, and trying to get rights to do anything
is like trying to pry a “Magic” card from a freshman engineering student.
My rights are so messed up, I actually have to do the following steps at the start
of every day I plan on debugging. If you see this message, here's the steps you can
try to get rid of it and get on with your debugging.
</p>
        <p>
First, you're going to need to change one of the local security policies. Open up
your admin folder, and select Local Security Policies. You should see something similar
to the image below. Next, select <em>User Rights Assignment</em>. 
</p>
        <p>
          <img height="537" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/secpol.jpg" width="768" border="0" />
        </p>
        <p>
Locate <em>Impersonate a client after authentication</em>, and double click on it.
You should get a dialog similar to the following. What you'll need to do is add
the IWAM_ (and I add the ASP.Net worker thread just for good measure to the policy)
like below. For the record, I believe only IWAM_ is required.
</p>
        <p>
          <img height="405" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/IWAM.jpg" width="401" border="0" />
        </p>
        <p>
 OK, you've taken the first step to fixing the problem, but that's not it. You've
got to get IIS and the rest of the system to recognize the new policy. So, first,
open up the “Run “ command from the Start menu) or command prompt, and
type the following:
</p>
        <p>
          <img height="179" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/run1.jpg" width="347" border="0" />
        </p>
        <p>
Type 
</p>
        <p>
secedit /refreshpolicy machine_policy /enforce
</p>
        <p>
This will refresh the security policy for the local machine. Next, type this command
to restart IIS now that everything is set.
</p>
        <p>
iisreset
</p>
        <p>
          <img height="179" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/run2.jpg" width="347" border="0" />
        </p>
        <p>
That's it! Assuming the IIS application workspace is set to allow debugging, and everything
else is good on the machine, hopefully you'll be debugging like the Orkin man!
</p>
        <p>
-- Daryl
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=01fdbb59-0e3c-4a8e-b853-662341bab110" />
      </body>
      <title>Castastrophic Error -- What to do when you see this when trying to debug..</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,01fdbb59-0e3c-4a8e-b853-662341bab110.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/06/CastastrophicErrorWhatToDoWhenYouSeeThisWhenTryingToDebug.aspx</link>
      <pubDate>Mon, 06 Dec 2004 04:44:29 GMT</pubDate>
      <description>&lt;p&gt;
OK, so you're looking at some really obscure code, so it's time to step in and see
exactly what it's doing, and the best way to do it is use the debugger. Actually,
if I have to give you a reason to use the debugger, you probably shouldn't be reading
this in the first place. You fire up the VS IDE, hit F5, and viola! You see the following
scary message:
&lt;/p&gt;
&lt;p&gt;
&lt;img height=139 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/failure.jpg" width=551 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
What the heck? &amp;#8220;Error when typing to run project: Unable to start debugging
on the web server. Catastrophic failure.&amp;#8221;
&lt;/p&gt;
&lt;p&gt;
Likely you won't see this unless you don't have Admin privledges on the box. Right
now, I am doing a project for a large bank, and trying to get rights to do anything
is like trying to pry a &amp;#8220;Magic&amp;#8221; card from a freshman engineering student.
My rights are so messed up, I actually have to do the following steps at the start
of every day I plan on debugging. If you see this message, here's the steps you can
try to get rid of it and get on with your debugging.
&lt;/p&gt;
&lt;p&gt;
First, you're going to need to change one of the local security policies. Open up
your admin folder, and select Local Security Policies. You should see something similar
to the image below. Next, select &lt;em&gt;User Rights Assignment&lt;/em&gt;. 
&lt;/p&gt;
&lt;p&gt;
&lt;img height=537 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/secpol.jpg" width=768 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Locate &lt;em&gt;Impersonate a client after authentication&lt;/em&gt;, and double click on it.
You should get a dialog similar to the following. What you'll need to do&amp;nbsp;is add
the IWAM_ (and I add the ASP.Net worker thread just for good measure to the policy)
like below. For the record, I believe only IWAM_ is required.
&lt;/p&gt;
&lt;p&gt;
&lt;img height=405 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/IWAM.jpg" width=401 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;OK, you've taken the first step to fixing the problem, but that's not it. You've
got to get IIS and the rest of the system to recognize the new policy. So, first,
open up the &amp;#8220;Run &amp;#8220; command from the Start menu) or command prompt, and
type the following:
&lt;/p&gt;
&lt;p&gt;
&lt;img height=179 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/run1.jpg" width=347 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Type 
&lt;/p&gt;
&lt;p&gt;
secedit /refreshpolicy machine_policy /enforce
&lt;/p&gt;
&lt;p&gt;
This will refresh the security policy for the local machine. Next, type this command
to restart IIS now that everything is set.
&lt;/p&gt;
&lt;p&gt;
iisreset
&lt;/p&gt;
&lt;p&gt;
&lt;img height=179 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/run2.jpg" width=347 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
That's it! Assuming the IIS application workspace is set to allow debugging, and everything
else is good on the machine, hopefully you'll be debugging like the Orkin man!
&lt;/p&gt;
&lt;p&gt;
-- Daryl
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=01fdbb59-0e3c-4a8e-b853-662341bab110" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,01fdbb59-0e3c-4a8e-b853-662341bab110.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>C#</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=77bcec51-e4bf-4317-b81b-19d3b5edd0e6</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,77bcec51-e4bf-4317-b81b-19d3b5edd0e6.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,77bcec51-e4bf-4317-b81b-19d3b5edd0e6.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=77bcec51-e4bf-4317-b81b-19d3b5edd0e6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The winner of the cool application for the Tablet PC was announced, and the top prize
winner was an application called ArtRage. Holy cow! I am no artist but this thing
is cool. Although you can use it with a mouse, if you hae a Tablet PC, the play factor
alone on this is worth the download. Best of all, it's free.
</p>
        <p>
My favorite part: the trace feature. Essentially, it allows you to place a picture
in the background, trace over what you want, then save the tracing (without the picture
in the background). I may become an artist yet!
</p>
        <p>
For all the apps (which I am sure to check out!) check the contest out here:
</p>
        <p>
          <a href="http://www.microsoft.com/presspass/press/2004/dec04/12-01TabletPCWinnerPR.asp" target="_blank">http://www.microsoft.com/presspass/press/2004/dec04/12-01TabletPCWinnerPR.asp</a>
        </p>
        <p>
or go right to the site at:
</p>
        <p>
          <a href="http://www.ambientdesign.com/artrage.html" target="_blank">http://www.ambientdesign.com/artrage.html</a>
        </p>
        <p>
Here's a weak sample:
</p>
        <p>
          <img height="300" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/cool.png" width="200" border="0" />
        </p>
        <p>
Notice the brush textures of the paintbrush.... 
</p>
        <p>
-- Daryl
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=77bcec51-e4bf-4317-b81b-19d3b5edd0e6" />
      </body>
      <title>Too cool for words!</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,77bcec51-e4bf-4317-b81b-19d3b5edd0e6.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/03/TooCoolForWords.aspx</link>
      <pubDate>Fri, 03 Dec 2004 03:23:38 GMT</pubDate>
      <description>&lt;p&gt;
The winner of the cool application for the Tablet PC was announced, and the top prize
winner was an application called ArtRage. Holy cow! I am no artist but this thing
is cool. Although you can use it with a mouse, if you hae a Tablet PC, the play factor
alone on this is worth the download. Best of all, it's free.
&lt;/p&gt;
&lt;p&gt;
My favorite part: the trace feature. Essentially, it allows you to place a picture
in the background, trace over what you want, then save the tracing (without the picture
in the background). I may become an artist yet!
&lt;/p&gt;
&lt;p&gt;
For all the apps (which I am sure to check out!) check the contest out here:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.microsoft.com/presspass/press/2004/dec04/12-01TabletPCWinnerPR.asp" target=_blank&gt;http://www.microsoft.com/presspass/press/2004/dec04/12-01TabletPCWinnerPR.asp&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
or go right to the site at:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.ambientdesign.com/artrage.html" target=_blank&gt;http://www.ambientdesign.com/artrage.html&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Here's a weak sample:
&lt;/p&gt;
&lt;p&gt;
&lt;img height=300 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/cool.png" width=200 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Notice the brush textures of the paintbrush.... 
&lt;/p&gt;
&lt;p&gt;
-- Daryl
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=77bcec51-e4bf-4317-b81b-19d3b5edd0e6" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,77bcec51-e4bf-4317-b81b-19d3b5edd0e6.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=6394fc3f-d3b8-46c7-bd71-035b286bf35c</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,6394fc3f-d3b8-46c7-bd71-035b286bf35c.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,6394fc3f-d3b8-46c7-bd71-035b286bf35c.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6394fc3f-d3b8-46c7-bd71-035b286bf35c</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Someone on the project I am currently working on stumbled on some documentation for
WinCV, and in that documentation, it tells you how to add Assemblies which aren't
in the GAC. Here's the link from the MSDN, and then I will point out the interesting
part:
</p>
        <p>
          <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconwindowsformsclassviewerwincvexe.asp" target="_blank">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconwindowsformsclassviewerwincvexe.asp</a>
        </p>
        <p>
By using a <em>response file</em>, you can issue the necessary the parameters to look
at one or more files. From the documentation:
</p>
        <p>
          <font color="#0000ff">The following code shows the contents of a response file <code><code class="ce">myFile.rsp</code>. </code>Using
a response file eliminates the need to individually type the commands at the command
prompt.</font>
        </p>
        <pre class="code">
          <font color="#0000ff">/r:myAssembly.dll /r:myOtherAssembly.dll</font>
        </pre>
        <p>
          <font color="#0000ff">The following command reads the response file <code class="ce">myFile.rsp</code> and
executes the commands specified in the file.</font>
        </p>
        <pre class="code">
          <font color="#0000ff">wincv @myFile.rsp</font>
        </pre>
        <pre class="code">
          <font color="#000000">So,
you could set up a standard response file which holds all the names of assemblies
to search! </font>
        </pre>
        <pre class="code">Pretty neat!</pre>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=6394fc3f-d3b8-46c7-bd71-035b286bf35c" />
      </body>
      <title>WinCV revisited...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,6394fc3f-d3b8-46c7-bd71-035b286bf35c.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/12/02/WinCVRevisited.aspx</link>
      <pubDate>Thu, 02 Dec 2004 05:42:28 GMT</pubDate>
      <description>&lt;p&gt;
Someone on the project I am currently working on stumbled on some documentation for
WinCV, and in that documentation, it tells you how to add Assemblies which aren't
in the GAC. Here's the link from the MSDN, and then I will point out the interesting
part:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconwindowsformsclassviewerwincvexe.asp" target=_blank&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconwindowsformsclassviewerwincvexe.asp&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
By using a &lt;em&gt;response file&lt;/em&gt;, you can issue the necessary the parameters to look
at one or more files. From the documentation:
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff&gt;The following code shows the contents of a response file &lt;code&gt;&lt;code class=ce&gt;myFile.rsp&lt;/code&gt;. &lt;/code&gt;Using
a response file eliminates the need to individually type the commands at the command
prompt.&lt;/font&gt;
&lt;/p&gt;
&lt;pre class=code&gt;&lt;font color=#0000ff&gt;/r:myAssembly.dll /r:myOtherAssembly.dll&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;font color=#0000ff&gt;The following command reads the response file &lt;code class=ce&gt;myFile.rsp&lt;/code&gt; and
executes the commands specified in the file.&lt;/font&gt;
&lt;/p&gt;
&lt;pre class=code&gt;&lt;font color=#0000ff&gt;wincv @myFile.rsp&lt;/font&gt;&lt;/pre&gt;&lt;pre class=code&gt;&lt;font color=#000000&gt;So,
you could set up a standard response file which holds all the names of assemblies
to search! &lt;/font&gt;&lt;/pre&gt;&lt;pre class=code&gt;Pretty neat!&lt;/pre&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=6394fc3f-d3b8-46c7-bd71-035b286bf35c" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,6394fc3f-d3b8-46c7-bd71-035b286bf35c.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=6c55fa2b-a93d-4c46-bcbf-b45752c345ba</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,6c55fa2b-a93d-4c46-bcbf-b45752c345ba.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,6c55fa2b-a93d-4c46-bcbf-b45752c345ba.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6c55fa2b-a93d-4c46-bcbf-b45752c345ba</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Here's another tip which is a wrapper to retrieve the value from an enum by it's text
and also to get the text of an enum based on a value.
</p>
        <p>
          <style type="text/css">
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
</style>
        </p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="kwrd">public</span>
            <span class="kwrd">static</span>
            <span class="kwrd">string</span> RetrieveEnumTextByValue
(Type enumType, Object value)</pre>
          <pre>{</pre>
          <pre class="alt">
            <span class="kwrd">if</span> (enumType.IsEnum)</pre>
          <pre>    {</pre>
          <pre class="alt">
            <span class="kwrd">if</span> (System.Enum.GetName(enumType,value)
!= <span class="kwrd">null</span>)</pre>
          <pre>
            <span class="kwrd">return</span> System.Enum.GetName(enumType,
value);</pre>
          <pre class="alt">    }</pre>
          <pre>
            <span class="kwrd">return</span>
            <span class="str">""</span>;</pre>
          <pre class="alt">}</pre>
          <pre>
          </pre>
          <pre class="alt">
            <span class="kwrd">public</span>
            <span class="kwrd">static</span>
            <span class="kwrd">int</span> RetrieveEnumValueByText(Type
enumType, <span class="kwrd">string</span> text)</pre>
          <pre>{</pre>
          <pre class="alt">
            <span class="kwrd">if</span> (enumType.IsEnum)</pre>
          <pre>    {</pre>
          <pre class="alt">
            <span class="kwrd">if</span> (System.Enum.Parse(enumType,text)
!= <span class="kwrd">null</span>)</pre>
          <pre>
            <span class="kwrd">return</span> Convert.ToInt32(System.Enum.Parse(enumType,
text));</pre>
          <pre class="alt">    }</pre>
          <pre>
            <span class="kwrd">return</span> -1;</pre>
          <pre class="alt">}</pre>
        </div>
        <p>
I'm a little lazy tonight, but maybe I will come in later and post usage. I'll make
a better effort to do that in the future, but I have to be up in a few hours, and
being tired tomorrow just won't do!
</p>
        <p>
-- Daryl
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=6c55fa2b-a93d-4c46-bcbf-b45752c345ba" />
      </body>
      <title>Tip of the Day: Retrieving an enum's value by text, and text by value</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,6c55fa2b-a93d-4c46-bcbf-b45752c345ba.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/30/TipOfTheDayRetrievingAnEnumsValueByTextAndTextByValue.aspx</link>
      <pubDate>Tue, 30 Nov 2004 05:11:10 GMT</pubDate>
      <description>&lt;p&gt;
Here's another tip which is a wrapper to retrieve the value from an enum by it's text
and also to get the text of an enum based on a value.
&lt;/p&gt;
&lt;p&gt;
&lt;style type=text/css&gt;
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
&lt;/style&gt;
&lt;div class=csharpcode&gt;&lt;pre class=alt&gt;&lt;span class=kwrd&gt;public&lt;/span&gt; &lt;span class=kwrd&gt;static&lt;/span&gt; &lt;span class=kwrd&gt;string&lt;/span&gt; RetrieveEnumTextByValue
(Type enumType, Object value)&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class=alt&gt;    &lt;span class=kwrd&gt;if&lt;/span&gt; (enumType.IsEnum)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class=alt&gt;        &lt;span class=kwrd&gt;if&lt;/span&gt; (System.Enum.GetName(enumType,value)
!= &lt;span class=kwrd&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;            &lt;span class=kwrd&gt;return&lt;/span&gt; System.Enum.GetName(enumType,
value);&lt;/pre&gt;&lt;pre class=alt&gt;    }&lt;/pre&gt;&lt;pre&gt;    &lt;span class=kwrd&gt;return&lt;/span&gt; &lt;span class=str&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre class=alt&gt;}&lt;/pre&gt;&lt;pre&gt;   &lt;/pre&gt;&lt;pre class=alt&gt;&lt;span class=kwrd&gt;public&lt;/span&gt; &lt;span class=kwrd&gt;static&lt;/span&gt; &lt;span class=kwrd&gt;int&lt;/span&gt; RetrieveEnumValueByText(Type
enumType, &lt;span class=kwrd&gt;string&lt;/span&gt; text)&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class=alt&gt;    &lt;span class=kwrd&gt;if&lt;/span&gt; (enumType.IsEnum)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class=alt&gt;        &lt;span class=kwrd&gt;if&lt;/span&gt; (System.Enum.Parse(enumType,text)
!= &lt;span class=kwrd&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;            &lt;span class=kwrd&gt;return&lt;/span&gt; Convert.ToInt32(System.Enum.Parse(enumType,
text));&lt;/pre&gt;&lt;pre class=alt&gt;    }&lt;/pre&gt;&lt;pre&gt;    &lt;span class=kwrd&gt;return&lt;/span&gt; -1;&lt;/pre&gt;&lt;pre class=alt&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
I'm a little lazy tonight, but maybe I will come in later and post usage. I'll make
a better effort to do that in the future, but I have to be up in a few hours, and
being tired tomorrow just won't do!
&lt;/p&gt;
&lt;p&gt;
-- Daryl
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=6c55fa2b-a93d-4c46-bcbf-b45752c345ba" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,6c55fa2b-a93d-4c46-bcbf-b45752c345ba.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=99c149c3-d442-4fef-b992-3406d3737e76</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,99c149c3-d442-4fef-b992-3406d3737e76.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,99c149c3-d442-4fef-b992-3406d3737e76.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=99c149c3-d442-4fef-b992-3406d3737e76</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Yet another tip of the day. I guess until I get an environment set up to go over my
Filter Component I will be posting a lot of tips just so I keep the blog active. Be
patient, it will be worth it when I get the project set up.
</p>
        <p>
CHAR() was a useful function for taking an integer value and returning the Ascii equivalent
from the value. There's a bit more to it in .Net, so here's a C# wrapper function
to do the same. Once again, there's no error handling or validation, so if this is
important to you (and it should be), caveat emptor.
</p>
        <p>
          <style type="text/css">
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
</style>
        </p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="kwrd">public</span>
            <span class="kwrd">static</span>
            <span class="kwrd">string</span> Char(<span class="kwrd">int</span> asciiCode)</pre>
          <pre>{</pre>
          <pre class="alt">    Byte[] charBytes = {asciiCode};</pre>
          <pre>
            <span class="kwrd">return</span> System.Text.Encoding.ASCII.GetString(charBytes);</pre>
          <pre class="alt">}</pre>
        </div>
        <div class="csharpcode"> 
</div>
        <div class="csharpcode">Enjoy!
</div>
        <p>
-- Daryl
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=99c149c3-d442-4fef-b992-3406d3737e76" />
      </body>
      <title>Tip of the Day: Simulating the CHAR function in C#</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,99c149c3-d442-4fef-b992-3406d3737e76.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/30/TipOfTheDaySimulatingTheCHARFunctionInC.aspx</link>
      <pubDate>Tue, 30 Nov 2004 05:05:16 GMT</pubDate>
      <description>&lt;p&gt;
Yet another tip of the day. I guess until I get an environment set up to go over my
Filter Component I will be posting a lot of tips just so I keep the blog active. Be
patient, it will be worth it when I get the project set up.
&lt;/p&gt;
&lt;p&gt;
CHAR() was a useful function for taking an integer value and returning the Ascii equivalent
from the value. There's a bit more to it in .Net, so here's a C# wrapper function
to do the same. Once again, there's no error handling or validation, so if this is
important to you (and it should be), caveat emptor.
&lt;/p&gt;
&lt;p&gt;
&lt;style type=text/css&gt;
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
&lt;/style&gt;
&lt;div class=csharpcode&gt;&lt;pre class=alt&gt;&lt;span class=kwrd&gt;public&lt;/span&gt; &lt;span class=kwrd&gt;static&lt;/span&gt; &lt;span class=kwrd&gt;string&lt;/span&gt; Char(&lt;span class=kwrd&gt;int&lt;/span&gt; asciiCode)&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class=alt&gt;    Byte[] charBytes = {asciiCode};&lt;/pre&gt;&lt;pre&gt;    &lt;span class=kwrd&gt;return&lt;/span&gt; System.Text.Encoding.ASCII.GetString(charBytes);&lt;/pre&gt;&lt;pre class=alt&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=csharpcode&gt;&amp;nbsp;
&lt;/div&gt;
&lt;div class=csharpcode&gt;Enjoy!
&lt;/div&gt;
&lt;p&gt;
-- Daryl
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=99c149c3-d442-4fef-b992-3406d3737e76" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,99c149c3-d442-4fef-b992-3406d3737e76.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=0897315b-cdb0-4c1f-9f4a-09dd99cf3b50</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,0897315b-cdb0-4c1f-9f4a-09dd99cf3b50.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,0897315b-cdb0-4c1f-9f4a-09dd99cf3b50.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0897315b-cdb0-4c1f-9f4a-09dd99cf3b50</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It took me a few minutes to find, so I wanted to blog on it just so I could find it
again, and anyone out there can use too. I am currently working in a wierd development
environment which uses Novell over an NT network. So I have two passwords, and the
only way I can change the NT password is through Outlook or using Terminal Services
to go to an all NT machine and do it. Outlook wasn't working, so I went route #2.
</p>
        <p>
In order to send the Ctrl-Alt-Delete sequence in Terminal Services, I had to use Ctrl-Alt-End...
Go figure!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0897315b-cdb0-4c1f-9f4a-09dd99cf3b50" />
      </body>
      <title>Tip of the Day: Sending Ctrl-Alt-Delete through a Terminal Services Client</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,0897315b-cdb0-4c1f-9f4a-09dd99cf3b50.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/29/TipOfTheDaySendingCtrlAltDeleteThroughATerminalServicesClient.aspx</link>
      <pubDate>Mon, 29 Nov 2004 18:16:26 GMT</pubDate>
      <description>&lt;p&gt;
It took me a few minutes to find, so I wanted to blog on it just so I could find it
again, and anyone out there can use too. I am currently working in a wierd development
environment which uses Novell over an NT network. So I have two passwords, and the
only way I can change the NT password is through Outlook or using Terminal Services
to go to an all NT machine and do it. Outlook wasn't working, so I went route #2.
&lt;/p&gt;
&lt;p&gt;
In order to send the Ctrl-Alt-Delete sequence in Terminal Services, I had to use Ctrl-Alt-End...
Go figure!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0897315b-cdb0-4c1f-9f4a-09dd99cf3b50" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,0897315b-cdb0-4c1f-9f4a-09dd99cf3b50.aspx</comments>
      <category>All Things</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=7b6b00b2-0581-45ef-b268-de0f649282c9</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,7b6b00b2-0581-45ef-b268-de0f649282c9.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,7b6b00b2-0581-45ef-b268-de0f649282c9.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7b6b00b2-0581-45ef-b268-de0f649282c9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is a pretty simple tip (or set of tips) but one in which if you don't know, you're
going to be glad to find them out.
</p>
        <p>
First, depending on how your profile is set up in Visual Studio, you can type Ctrl-space
to get the Intellisense to come up. If there's only one possible option, it will go
ahead and type the rest out for you. For example, type “Sy” in the Code
behind editor, and press Ctrl-space. You should see a ton of “System”
options you can select from to complete the word.
</p>
        <p>
OK, that was easy, right? Well, here's a little one which is often overlooked: creating
an alias in your using statement.
</p>
        <p>
Typically, you might set up your “includes” as follows (in C#). 
</p>
        <p>
using System.XML;
</p>
        <p>
That works great if you are really familiar with the object model, and know what public
method/member you want. Suppose you don't? You can do this:
</p>
        <p>
using MyXML=System.XML;
</p>
        <p>
Now, when you type MyXML, you can get the full Intellisense for the System.XML without
having to type all that (or guess). Simple, but great for working with new workspaces.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7b6b00b2-0581-45ef-b268-de0f649282c9" />
      </body>
      <title>Tip of the Day: Speeding up your typing and Intellisense</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,7b6b00b2-0581-45ef-b268-de0f649282c9.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/29/TipOfTheDaySpeedingUpYourTypingAndIntellisense.aspx</link>
      <pubDate>Mon, 29 Nov 2004 16:36:57 GMT</pubDate>
      <description>&lt;p&gt;
This is a pretty simple tip (or set of tips) but one in which if you don't know, you're
going to be glad to find them out.
&lt;/p&gt;
&lt;p&gt;
First, depending on how your profile is set up in Visual Studio, you can type Ctrl-space
to get the Intellisense to come up. If there's only one possible option, it will go
ahead and type the rest out for you. For example, type &amp;#8220;Sy&amp;#8221; in the Code
behind editor, and press Ctrl-space. You should see a ton of &amp;#8220;System&amp;#8221;
options you can select from to complete the word.
&lt;/p&gt;
&lt;p&gt;
OK, that was easy, right? Well, here's a little one which is often overlooked: creating
an alias in your using statement.
&lt;/p&gt;
&lt;p&gt;
Typically, you might set up&amp;nbsp;your &amp;#8220;includes&amp;#8221; as follows (in C#). 
&lt;/p&gt;
&lt;p&gt;
using System.XML;
&lt;/p&gt;
&lt;p&gt;
That works great if you are really familiar with the object model, and know what public
method/member you want. Suppose you don't? You can do this:
&lt;/p&gt;
&lt;p&gt;
using MyXML=System.XML;
&lt;/p&gt;
&lt;p&gt;
Now, when you type MyXML, you can get the full Intellisense for the System.XML without
having to type all that (or guess). Simple, but great for working with new workspaces.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7b6b00b2-0581-45ef-b268-de0f649282c9" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,7b6b00b2-0581-45ef-b268-de0f649282c9.aspx</comments>
      <category>All Things</category>
      <category>C#</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=67768dd0-2d77-4e2e-88d6-486d9ade4bc5</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,67768dd0-2d77-4e2e-88d6-486d9ade4bc5.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,67768dd0-2d77-4e2e-88d6-486d9ade4bc5.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=67768dd0-2d77-4e2e-88d6-486d9ade4bc5</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Not sure where I got this, so my apologies to the original author, but it's been a
pretty useful function. Of course, you might want to wrap this with some error handling
and validation code, but here's a good start for you...
</p>
        <p>
          <style type="text/css">
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
</style>
        </p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="kwrd">private</span>
            <span class="kwrd">string</span> GetRomanNumber(<span class="kwrd">int</span> number)</pre>
          <pre>{</pre>
          <pre class="alt">
            <span class="kwrd">string</span>[]
ArabicNums = <span class="kwrd">new</span><span class="kwrd">string</span>[] {<span class="str">"1"</span>, <span class="str">"4"</span>, <span class="str">"5"</span>, <span class="str">"9"</span>, <span class="str">"10"</span>, <span class="str">"40"</span>, <span class="str">"50"</span>, <span class="str">"90"</span>, <span class="str">"100"</span>, <span class="str">"400"</span>, <span class="str">"500"</span>, <span class="str">"900"</span>, <span class="str">"1000"</span>};</pre>
          <pre>
            <span class="kwrd">string</span>[]
RomanNums = <span class="kwrd">new</span><span class="kwrd">string</span>[] {<span class="str">"I"</span>,<span class="str">"IV"</span>,<span class="str">"V"</span>,<span class="str">"IX"</span>,<span class="str">"X"</span>,<span class="str">"XL"</span>,<span class="str">"L"</span>,<span class="str">"XC"</span>,<span class="str">"C"</span>,<span class="str">"CD"</span>,<span class="str">"D"</span>,<span class="str">"CM"</span>,<span class="str">"M"</span>};</pre>
          <pre class="alt"> </pre>
          <pre>
            <span class="kwrd">int</span> ArabicUpper
= ArabicNums.GetUpperBound(0);</pre>
          <pre class="alt">
            <span class="kwrd">int</span> ArabicLower
= ArabicNums.GetLowerBound(0);</pre>
          <pre> </pre>
          <pre class="alt">
            <span class="kwrd">string</span> Output
= <span class="str">""</span>;</pre>
          <pre> </pre>
          <pre class="alt">
            <span class="kwrd">for</span> (<span class="kwrd">int</span> i
= ArabicUpper; i &gt;= ArabicLower; i--)</pre>
          <pre>    {</pre>
          <pre class="alt">
            <span class="kwrd">while</span> (number
&gt;= Convert.ToInt32(ArabicNums[i]))</pre>
          <pre>        {</pre>
          <pre class="alt">            number -= Convert.ToInt32(ArabicNums[i]);</pre>
          <pre>            Output += RomanNums[i];</pre>
          <pre class="alt">        }</pre>
          <pre>    }</pre>
          <pre class="alt"> </pre>
          <pre>
            <span class="kwrd">return</span> Output;</pre>
          <pre class="alt">}</pre>
        </div>
        <p>
Enjoy!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=67768dd0-2d77-4e2e-88d6-486d9ade4bc5" />
      </body>
      <title>Tip of the Day: Converting an integer to a Roman Numeral in C#</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,67768dd0-2d77-4e2e-88d6-486d9ade4bc5.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/27/TipOfTheDayConvertingAnIntegerToARomanNumeralInC.aspx</link>
      <pubDate>Sat, 27 Nov 2004 04:25:01 GMT</pubDate>
      <description>&lt;p&gt;
Not sure where I got this, so my apologies to the original author, but it's been a
pretty useful function. Of course, you might want to wrap this with some error handling
and validation code, but here's a good start for you...
&lt;/p&gt;
&lt;p&gt;
&lt;style type=text/css&gt;
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
&lt;/style&gt;
&lt;div class=csharpcode&gt;&lt;pre class=alt&gt;&lt;span class=kwrd&gt;private&lt;/span&gt; &lt;span class=kwrd&gt;string&lt;/span&gt; GetRomanNumber(&lt;span class=kwrd&gt;int&lt;/span&gt; number)&lt;/pre&gt;&lt;pre&gt;{&lt;/pre&gt;&lt;pre class=alt&gt;    &lt;span class=kwrd&gt;string&lt;/span&gt;[]
ArabicNums = &lt;span class=kwrd&gt;new&lt;/span&gt; &lt;span class=kwrd&gt;string&lt;/span&gt;[] {&lt;span class=str&gt;"1"&lt;/span&gt;, &lt;span class=str&gt;"4"&lt;/span&gt;, &lt;span class=str&gt;"5"&lt;/span&gt;, &lt;span class=str&gt;"9"&lt;/span&gt;, &lt;span class=str&gt;"10"&lt;/span&gt;, &lt;span class=str&gt;"40"&lt;/span&gt;, &lt;span class=str&gt;"50"&lt;/span&gt;, &lt;span class=str&gt;"90"&lt;/span&gt;, &lt;span class=str&gt;"100"&lt;/span&gt;, &lt;span class=str&gt;"400"&lt;/span&gt;, &lt;span class=str&gt;"500"&lt;/span&gt;, &lt;span class=str&gt;"900"&lt;/span&gt;, &lt;span class=str&gt;"1000"&lt;/span&gt;};&lt;/pre&gt;&lt;pre&gt;    &lt;span class=kwrd&gt;string&lt;/span&gt;[]
RomanNums = &lt;span class=kwrd&gt;new&lt;/span&gt; &lt;span class=kwrd&gt;string&lt;/span&gt;[] {&lt;span class=str&gt;"I"&lt;/span&gt;,&lt;span class=str&gt;"IV"&lt;/span&gt;,&lt;span class=str&gt;"V"&lt;/span&gt;,&lt;span class=str&gt;"IX"&lt;/span&gt;,&lt;span class=str&gt;"X"&lt;/span&gt;,&lt;span class=str&gt;"XL"&lt;/span&gt;,&lt;span class=str&gt;"L"&lt;/span&gt;,&lt;span class=str&gt;"XC"&lt;/span&gt;,&lt;span class=str&gt;"C"&lt;/span&gt;,&lt;span class=str&gt;"CD"&lt;/span&gt;,&lt;span class=str&gt;"D"&lt;/span&gt;,&lt;span class=str&gt;"CM"&lt;/span&gt;,&lt;span class=str&gt;"M"&lt;/span&gt;};&lt;/pre&gt;&lt;pre class=alt&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class=kwrd&gt;int&lt;/span&gt; ArabicUpper
= ArabicNums.GetUpperBound(0);&lt;/pre&gt;&lt;pre class=alt&gt;    &lt;span class=kwrd&gt;int&lt;/span&gt; ArabicLower
= ArabicNums.GetLowerBound(0);&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=alt&gt;    &lt;span class=kwrd&gt;string&lt;/span&gt; Output
= &lt;span class=str&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=alt&gt;    &lt;span class=kwrd&gt;for&lt;/span&gt; (&lt;span class=kwrd&gt;int&lt;/span&gt; i
= ArabicUpper; i &amp;gt;= ArabicLower; i--)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class=alt&gt;        &lt;span class=kwrd&gt;while&lt;/span&gt; (number
&amp;gt;= Convert.ToInt32(ArabicNums[i]))&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class=alt&gt;            number -= Convert.ToInt32(ArabicNums[i]);&lt;/pre&gt;&lt;pre&gt;            Output += RomanNums[i];&lt;/pre&gt;&lt;pre class=alt&gt;        }&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class=alt&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class=kwrd&gt;return&lt;/span&gt; Output;&lt;/pre&gt;&lt;pre class=alt&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
Enjoy!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=67768dd0-2d77-4e2e-88d6-486d9ade4bc5" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,67768dd0-2d77-4e2e-88d6-486d9ade4bc5.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>C#</category>
      <category>VB.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=1a9772d7-0ede-4948-a192-044da681e7c5</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,1a9772d7-0ede-4948-a192-044da681e7c5.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,1a9772d7-0ede-4948-a192-044da681e7c5.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1a9772d7-0ede-4948-a192-044da681e7c5</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I seem to go in spurts in honing my technical skills by reading. Lately, I have been
on an uber-quest to learn new things through reading, so I thought I'd write a bit
on one I have finished, and the next likely target. My .Net and SQL Server library
is pretty stocked, with about 60+ current books on a variety of subjects from graphics
to SQL optimization to network programming to UI ideas. Most just end up being references,
but a few (like Rocky Lohtka's CSLA books) get the full study and learn act.
</p>
        <p>
I just finished <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0321228103/104-3635796-5079937?v=glance" target="_blank">Open
Source .NET Development : Programming with NAnt, NUnit, NDoc, and More By Brian Nantz</a>.
It's a good intro book if you want to get a real high level look at the open source
tools for automating builds and automated testing. It's a little confusing if you're
trying to learn what some of the tools do and which are best for which scenario, but
it does give a good glance on nAnt in particular. I would recommend this book for
someone wanting to understand what tools are available, but don't look for this book
to get you results in really complex situations. Sort of a road map, but you'll still
be looking for topos when you figure out where you want to go.
</p>
        <p>
Looking ahead, I had just purchased <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0321205618/104-3635796-5079937?v=glance" target="_blank">Seeing
Data : Designing User Interfaces for Database Systems Using .NET</a> by Rebecca M.
Riordan. It came in this afternoon, and I was very excited to get it on a long weekend
where I can try to pump through it. I am a little dis-enchanted though, as it appears
to be oriented towards Rich Clients. I do rich client apps, but I was looking more
forward to ASP.Net suggestions. I haven't given up hope on that yet, but if there
is limited information on web applications in the book, I would certainly wish they
would put "rich client" in the book description. I'll give it a read and put an update
here once I know for sure.
</p>
        <p>
It's important to me primarily because I can make a program do twists through hoops
with no problem. I can also make a program very usable in terms of functionality.
But making it look pretty, it takes me a lot of time, and I never am happy with it.
Note there is a huge difference between pretty and usability, although the two can
work together quite well and create a symbiotic relationship.
</p>
        <p>
That's it for now. I plan on posting a few more tips this weekend, and eating some
good home-cooked food. So, all those so celebrating, have a Happy Thanksgiving!
</p>
        <p>
-- Daryl
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1a9772d7-0ede-4948-a192-044da681e7c5" />
      </body>
      <title>Reading, Reading, Reading....</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,1a9772d7-0ede-4948-a192-044da681e7c5.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/25/ReadingReadingReading.aspx</link>
      <pubDate>Thu, 25 Nov 2004 05:51:47 GMT</pubDate>
      <description>&lt;p&gt;
I seem to go in spurts in honing my technical skills by reading. Lately, I have been
on an uber-quest to learn new things through reading, so I thought I'd write a bit
on one I have finished, and the next likely target. My .Net and SQL Server library
is pretty stocked, with about 60+ current books on a variety of subjects from graphics
to SQL optimization to network programming to UI ideas. Most just end up being references,
but a few (like Rocky Lohtka's CSLA books) get the full study and learn act.
&lt;/p&gt;
&lt;p&gt;
I just finished &lt;a href="http://www.amazon.com/exec/obidos/tg/detail/-/0321228103/104-3635796-5079937?v=glance" target=_blank&gt;Open
Source .NET Development : Programming with NAnt, NUnit, NDoc, and More By Brian Nantz&lt;/a&gt;.
It's a good intro book if you want to get a real high level look at the open source
tools for automating builds and automated testing. It's a little confusing if you're
trying to learn what some of the tools do and which are best for which scenario, but
it does give a good glance on nAnt in particular. I would recommend this book for
someone wanting to understand what tools are available, but don't look for this book
to get you results in really complex situations. Sort of a road map, but you'll still
be looking for topos when you figure out where you want to go.
&lt;/p&gt;
&lt;p&gt;
Looking ahead, I had just purchased &lt;a href="http://www.amazon.com/exec/obidos/tg/detail/-/0321205618/104-3635796-5079937?v=glance" target=_blank&gt;Seeing
Data : Designing User Interfaces for Database Systems Using .NET&lt;/a&gt; by Rebecca M.
Riordan. It came in this afternoon, and I was very excited to get it on a long weekend
where I can try to pump through it. I am a little dis-enchanted though, as it appears
to be oriented towards Rich Clients. I do rich client apps, but I was looking more
forward to ASP.Net suggestions. I haven't given up hope on that yet, but if there
is limited information on web applications in the book, I would certainly wish they
would put "rich client" in the book description. I'll give it a read and put an update
here once I know for sure.
&lt;/p&gt;
&lt;p&gt;
It's important to me primarily because I can make a program do twists through hoops
with no problem. I can also make a program very usable in terms of functionality.
But making it look pretty, it takes me a lot of time, and I never am happy with it.
Note there is a huge difference between pretty and usability, although the two can
work together quite well and create a symbiotic relationship.
&lt;/p&gt;
&lt;p&gt;
That's it for now. I plan on posting a few more tips this weekend, and eating some
good home-cooked food. So, all those so celebrating, have a Happy Thanksgiving!
&lt;/p&gt;
&lt;p&gt;
-- Daryl
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=1a9772d7-0ede-4948-a192-044da681e7c5" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,1a9772d7-0ede-4948-a192-044da681e7c5.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=ceb433e0-0cca-45d4-9cf8-67f48d19a4d1</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,ceb433e0-0cca-45d4-9cf8-67f48d19a4d1.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,ceb433e0-0cca-45d4-9cf8-67f48d19a4d1.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ceb433e0-0cca-45d4-9cf8-67f48d19a4d1</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I spent the past 11 months (as I mentioned previously) as part of a team of developers on
an 'agile' project, using the Extreme Programming methodology. As I was working out
today, I was reading the December 2004 issue of asp.net Pro magazine. The featured
article is about Test Driven Development (TDD), and it's place in agile development.
</p>
        <p>
First, let me preface this topic by saying I am absolutely FOR Test Driven Development.
In my opinion, there's too little focus given by developers on focusing in what can
go wrong with an application -- testing, error handling, malicious users, and a myriad
of other potential gotchas. The purpose of this blog is simply to provide some alternative
views on TDD, and some potential pitfalls, since there is little seen on the topic,
especially from those of us in the trenches. Combine this in your approach to TDD,
and you'll have a much better experience.
</p>
        <p>
Here's an executive summery of the caveats to TDD from my experience:
</p>
        <ol>
          <li>
No code is supposed to be written before the tests. Design first, then write the tests,
or you'll end up with a bad design. 
</li>
          <li>
When tests take longer to write and modify than the actual coding, the process gets
in the way. 
</li>
          <li>
TDD gives way to the erroneous philosophy that if your automated tests work, that's
all the testing you need (except user acceptance). 
</li>
          <li>
There is the dangerous thinking that you can write automated tests to cover every
scenario. See point 2 again. 
</li>
          <li>
There becomes a belief that the number of tests somehow correlates to the quality
of testing, or the the mere existence of an automated test provides a better application. 
</li>
          <li>
UI testing tools (especially the open source varieties) are lacking in the ability
to generate UI tests, at least from the web perspective in the trench I sat in. 
</li>
          <li>
When you data shunt the data access (and manipulation) portion of a class, that's
not a very valid test. The database MUST be tested, and your tests must accurately
reflect how the users are going to be actually using your objects for TDD to be of
any use.</li>
        </ol>
        <p>
Let's look at each point in a bit of detail, so I can provide some details on my OPINIONS
here... 
</p>
        <p>
First, the statement is made no code should be written before the test. OK, what exactly
are you going to be testing for? For example, let's say you might be wanting to test
customer creation. You envision the routine you want to test to return an integer
which ties to the ID the database generates. OK, great! But guess what, that's a DESIGN
DECISION. Why not set a read-only property of a class, and return a standard return
code? Are you going to follow this exact style with the rest of your classes? Will
the other developers do the same? Will the routine throw an error, or handle it itself?
If handled, how will I know there was an error?
</p>
        <p>
I know for a fact that if you don't lay out some very specific coding guidelines and
design, four developers are going to design the same class four different ways,
even when pairing. Given that fact, how can you possible write meaningful and consistent
tests without doing a basic architecture/design first. 
</p>
        <p>
Second, writing tests is time consuming. Maintaining tests can be even worse. On this
same project, test maintenance at times took more time than making a simple change.
Why? When the change is made, many times a refactoring occurs (in our case it was
almost a given since there was little thought placed on a unified design -- some day
I will write on why that occurred as part of a human dynamics of development topic).
Suddenly, the test needs to be re-written because the test now fails as a result of
the refactoring. A simple business rule change has now turned into a design and test
change. A task that might have taken an hour now takes two days. Sorry, as a business
owner, it's a bitter pill to swallow.
</p>
        <p>
Another mistake occurs when the developer takes on the attitude that when the automated
tests pass, the testing is complete. Let's face it, as developers, testing sits right
up there with documenting code. No one wants to do it, but it HAS to be done. With
TDD, it's an easy trap to fall into. I even heard “My tests run, let the customer
catch anything else in User Acceptance.” Wrong! The customer's are why we as
developers have jobs. We need to do due diligence in functional testing, integration
testing as well as usability testing. Automated testing is NOT going to do that for
us. To think your automated tests are going to catch all the errors is dangerous thinking.
No one has every promoted TDD to accomplish this, but I can tell you from experience,
the possibility that this mindset can exist is there.
</p>
        <p>
As I mentioned before, I am all for TDD and automated testing. However, I also like
to be thorough. I also only like to write valid tests. If I was to sit there and ponder
every single possible scenario, at my bill rate the client is going to be looking
elsewhere thinking I am nor getting enough done. Consultants beware! But seriously,
even if I could take the time to come up with test which can adequately test the possible
scenarios, how much have I gained (in the short term -- long term is a whole other
story which TDD clearly wins)? Testing scripts which repeatedly test the application,
written by the users and repeated each time in user acceptance is a far more effective
testing methodology (OK, devil's advocate time -- can you really get them to test
it completely every time? The tester also suffers from laziness or lack of attention in
repetitive tasks..) So writing tests is going to also be an iterative process which
never ends. When a bug shows up, we need to refactor our testing to cover that scenario
in the future. Now I am maintaining two projects which is even more time consuming.
</p>
        <p>
The next fallacy in TDD is that the sheer number of tests (metrics) means you have
good testing. In the environment I was working in, their reviews were actually based
in part on the number of tests they wrote. Never mind that the majority of the test
written were actually an effective test, but the sheer count was taken to be effective
testing. Quality in testing should be your number one priority. If you can only come
up with one test which effectively tests an object, then so be it. Adding five more
test which do nothing other than add time during a refactoring is little help to the
cause of good software.
</p>
        <p>
Right now, automated testing really focuses on the Data Access Layer (DAL) and Business
Objects Layer (BOL). When I discuss shunting next, you'll see it actually comes down
to the BOL in many cases. What about the UI? The tools, especially for ASP.Net in
the open source community are severely lacking in automated testing. How will you
know if the javascript works both on Netscape and IE without running it yourself? 
It's the UI the user sees, which is why the UI has to be thoroughly tested in both
how you expect the user to use it, and how they <strong>might</strong> use it. Users
always come up with useful scenarios to break our applications. Think of it as a fun
challenge and you'll be far less frustrated.
</p>
        <p>
To test out our BOL, we shunted the data using XML or pre-defined data tables. It
actually works great, but it's a limited test. What happens when the database schema
changes? If you've shunted the data, you'll never know the impact unless you do your
due diligence and fully integrate test, or the user finds it in user acceptance testing
(which is not where you want to catch these things). If you do shunt your data, that's
great and fine. Just make sure you test against the schema the application is going
to be deployed against as well. See my blog about getting a random record using NewId()
if you want to generate some good database based tests.
</p>
        <p>
OK, it probably sounds like I am really bummed about automated testing after my recent
experience with it. That belief is the farthest from the truth. In fact, I am
going to introduce it on my current project because I feel it can certainly add a
key dynamic to a complete testing process. But as Test Driven Development gains
acceptance, I felt it was time someone at least mentioned the things to consider
so it can be a more effective tool in your development cycle. Plan ahead and determine
how you can avoid these pitfalls and hopefully your investment in time will generate
more dividends from Test Driven Development.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ceb433e0-0cca-45d4-9cf8-67f48d19a4d1" />
      </body>
      <title>Test Driven Development (Test First) -- is it everything it's supposed to be?</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,ceb433e0-0cca-45d4-9cf8-67f48d19a4d1.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/24/TestDrivenDevelopmentTestFirstIsItEverythingItsSupposedToBe.aspx</link>
      <pubDate>Wed, 24 Nov 2004 04:10:05 GMT</pubDate>
      <description>&lt;p&gt;
I spent the past 11 months (as I mentioned&amp;nbsp;previously) as part of a team of developers&amp;nbsp;on
an 'agile' project, using the Extreme Programming methodology. As I was working out
today, I was reading the December 2004 issue of asp.net Pro magazine. The featured
article is about Test Driven Development (TDD), and it's place in agile development.
&lt;/p&gt;
&lt;p&gt;
First, let me preface this topic by saying I am absolutely FOR Test Driven Development.
In my opinion, there's too little focus given by developers on focusing in what can
go wrong with an application -- testing, error handling, malicious users, and a myriad
of other potential gotchas. The purpose of this blog is simply to provide some alternative
views on TDD, and some potential pitfalls, since there is little seen on the topic,
especially from those of us in the trenches. Combine this in your approach to TDD,
and you'll have a much better experience.
&lt;/p&gt;
&lt;p&gt;
Here's an executive summery of the caveats to TDD from my experience:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
No code is supposed to be written before the tests. Design first, then write the tests,
or you'll end up with a bad design. 
&lt;li&gt;
When tests take longer to write and modify than the actual coding, the process gets
in the way. 
&lt;li&gt;
TDD gives way to the erroneous philosophy that if your automated tests work, that's
all the testing you need (except user acceptance). 
&lt;li&gt;
There is the&amp;nbsp;dangerous thinking that you can write automated tests to cover every
scenario. See point 2 again. 
&lt;li&gt;
There becomes a belief that the number of tests somehow correlates to the quality
of testing, or the the mere existence of an automated test provides a better application. 
&lt;li&gt;
UI testing tools (especially the open source varieties) are lacking in the ability
to generate UI tests, at least from the web perspective in the trench I sat in. 
&lt;li&gt;
When you data shunt the data access (and manipulation) portion of a class, that's
not a very valid test. The database MUST be tested, and your tests must accurately
reflect how the users are going to be actually using your objects for TDD to be of
any use.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Let's look at each point in a bit of detail, so I can provide some details on my OPINIONS
here... 
&lt;/p&gt;
&lt;p&gt;
First, the statement is made no code should be written before the test. OK, what exactly
are you going to be testing for? For example, let's say you might be wanting to test
customer creation. You envision the routine you want to test to return an integer
which ties to the ID the database generates. OK, great! But guess what, that's a DESIGN
DECISION. Why not set a read-only property of a class, and return a standard return
code? Are you going to follow this exact style with the rest of your classes? Will
the other developers do the same? Will the routine throw an error, or handle it itself?
If handled, how will I know there was an error?
&lt;/p&gt;
&lt;p&gt;
I know for a fact that if you don't lay out some very specific coding guidelines and
design, four developers are going to design the same class&amp;nbsp;four different ways,
even when pairing. Given that fact, how can you possible write meaningful and consistent
tests without doing a basic architecture/design first. 
&lt;/p&gt;
&lt;p&gt;
Second, writing tests is time consuming. Maintaining tests can be even worse. On this
same project, test maintenance at times took more time than making a simple change.
Why? When the change is made, many times a refactoring occurs (in our case it was
almost a given since there was little thought placed on a unified design -- some day
I will write on why that occurred as part of a human dynamics of development topic).
Suddenly, the test needs to be re-written because the test now fails as a result of
the refactoring. A simple business rule change has now turned into a design and test
change. A task that might have taken an hour now takes two days. Sorry, as a business
owner, it's a bitter pill to swallow.
&lt;/p&gt;
&lt;p&gt;
Another mistake occurs when the developer takes on the attitude that when the automated
tests pass, the testing is complete. Let's face it, as developers, testing sits right
up there with documenting code. No one wants to do it, but it HAS to be done. With
TDD, it's an easy trap to fall into. I even heard &amp;#8220;My tests run, let the customer
catch anything else in User Acceptance.&amp;#8221; Wrong! The customer's are why we as
developers have jobs. We need to do due diligence in functional testing, integration
testing as well as usability testing. Automated testing is NOT going to do that for
us. To think your automated tests are going to catch all the errors is dangerous thinking.
No one has every promoted TDD to accomplish this, but I can tell you from experience,
the possibility that this mindset can exist is there.
&lt;/p&gt;
&lt;p&gt;
As I mentioned before, I am all for TDD and automated testing. However, I also like
to be thorough. I also only like to write valid tests. If I was to sit there and ponder
every single possible scenario, at my bill rate the client is going to be looking
elsewhere thinking I am nor getting enough done. Consultants beware! But seriously,
even if I could take the time to come up with test which can adequately test the possible
scenarios, how much have I gained (in the short term -- long term is a whole other
story which TDD clearly wins)? Testing scripts which repeatedly test the application,
written by the users and repeated each time in user acceptance is a far more effective
testing methodology (OK, devil's advocate time -- can you really get them to test
it completely every time? The tester also suffers from laziness or lack of attention&amp;nbsp;in
repetitive tasks..) So writing tests is going to also be an iterative process which
never ends. When a bug shows up, we need to refactor our testing to cover that scenario
in the future. Now I am maintaining two projects which is even more time consuming.
&lt;/p&gt;
&lt;p&gt;
The next fallacy in TDD is that the sheer number of tests (metrics) means you have
good testing. In the environment I was working in, their reviews were actually based
in part on the number of tests they wrote. Never mind that the majority of the test
written were actually an effective test, but the sheer count was taken to be effective
testing. Quality in testing should be your number one priority. If you can only come
up with one test which effectively tests an object, then so be it. Adding five more
test which do nothing other than add time during a refactoring is little help to the
cause of good software.
&lt;/p&gt;
&lt;p&gt;
Right now, automated testing really focuses on the Data Access Layer (DAL) and Business
Objects Layer (BOL). When I discuss shunting next, you'll see it actually comes down
to the BOL in many cases. What about the UI? The tools, especially for ASP.Net in
the open source community are severely lacking in automated testing. How will you
know if the javascript works both on Netscape and IE without running it yourself?&amp;nbsp;
It's the UI the user sees, which is why the UI has to be thoroughly tested in both
how you expect the user to use it, and how they &lt;strong&gt;might&lt;/strong&gt; use it. Users
always come up with useful scenarios to break our applications. Think of it as a fun
challenge and you'll be far less frustrated.
&lt;/p&gt;
&lt;p&gt;
To test out our BOL, we shunted the data using XML or pre-defined data tables. It
actually works great, but it's a limited test. What happens when the database schema
changes? If you've shunted the data, you'll never know the impact unless you do your
due diligence and fully integrate test, or the user finds it in user acceptance testing
(which is not where you want to catch these things). If you do shunt your data, that's
great and fine. Just make sure you test against the schema the application is going
to be deployed against as well. See my blog about getting a random record using NewId()
if you want to generate some good database based tests.
&lt;/p&gt;
&lt;p&gt;
OK, it probably sounds like I am really bummed about automated testing after&amp;nbsp;my&amp;nbsp;recent
experience&amp;nbsp;with it. That belief is the farthest from the truth. In fact, I am
going to introduce it on my current project because I feel it can certainly add a
key dynamic to a complete testing process. But as&amp;nbsp;Test Driven Development&amp;nbsp;gains
acceptance, I felt it was time someone at least mentioned the things to&amp;nbsp;consider
so it can be a more effective tool in your development cycle. Plan ahead and determine
how you can avoid these pitfalls and&amp;nbsp;hopefully your investment in time will generate
more dividends from Test Driven Development.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ceb433e0-0cca-45d4-9cf8-67f48d19a4d1" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,ceb433e0-0cca-45d4-9cf8-67f48d19a4d1.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Design</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=7450e1ce-9e9b-4e68-aa3f-7ec0026ffdc5</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,7450e1ce-9e9b-4e68-aa3f-7ec0026ffdc5.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,7450e1ce-9e9b-4e68-aa3f-7ec0026ffdc5.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=7450e1ce-9e9b-4e68-aa3f-7ec0026ffdc5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
On my last project, as part of the agile process, we utilized nAnt with Draco.Net
to create automated builds. I didn't implement that part of the project, but I certainly
did see the value in automating the build. So, while I set up my environment for my
topic of Component Based Development, I am going to write my learning's on generating
an automated build. If you've used these tools, feel free to hop in and add some help.
</p>
        <p>
That's one downside of open source projects -- the documentation can either be lacking
or just as distributed. So hopefully by blogging about it, I can save someone some
frustration.
</p>
        <p>
So I am going to start by looking at the tools I am planning on using:
</p>
        <p>
          <a href="http://nant.sourceforge.net/">nAnt Home Page</a> -- Get nAnt here. nAnt is
the tool you'll use to configure your build
</p>
        <p>
          <a href="http://draconet.sourceforge.net/">Draco.Net</a> -- How to generate a build
when your source control changes (or you trigger it)
</p>
        <p>
Some other interesting links I saw: 
</p>
        <p>
For nAnt help: <a href="http://nant.sourceforge.net/wiki/index.php/NAntUsage">NAntUsage
wiki</a> -- Some help on how to use nAnt
</p>
        <p>
For Draco.Net help: <a href="http://draconet.sourceforge.net/wiki/">Draco.Net wiki</a> --
Some help on how to use Draco.net
</p>
        <p>
Tomorrow I am going to start implementing nAnt on a fairly complex project, so I will
post my findings as I go along!
</p>
        <p>
          <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7450e1ce-9e9b-4e68-aa3f-7ec0026ffdc5" />
        </p>
      </body>
      <title>My trek into automated builds</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,7450e1ce-9e9b-4e68-aa3f-7ec0026ffdc5.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/23/MyTrekIntoAutomatedBuilds.aspx</link>
      <pubDate>Tue, 23 Nov 2004 21:47:25 GMT</pubDate>
      <description>&lt;p&gt;
On my last project, as part of the agile process, we utilized nAnt with Draco.Net
to create automated builds. I didn't implement that part of the project, but I certainly
did see the value in automating the build. So, while I set up my environment for my
topic of Component Based Development, I am going to write my learning's on generating
an automated build. If you've used these tools, feel free to hop in and add some help.
&lt;/p&gt;
&lt;p&gt;
That's one downside of open source projects -- the documentation can either be lacking
or just as distributed. So hopefully by blogging about it, I can save someone some
frustration.
&lt;/p&gt;
&lt;p&gt;
So I am going to start by looking at the tools I am planning on using:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://nant.sourceforge.net/"&gt;nAnt Home Page&lt;/a&gt; -- Get nAnt here. nAnt is
the tool you'll use to configure your build
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://draconet.sourceforge.net/"&gt;Draco.Net&lt;/a&gt; -- How to generate a build
when your source control changes (or you trigger it)
&lt;/p&gt;
&lt;p&gt;
Some other interesting links I saw: 
&lt;/p&gt;
&lt;p&gt;
For nAnt help: &lt;a href="http://nant.sourceforge.net/wiki/index.php/NAntUsage"&gt;NAntUsage
wiki&lt;/a&gt;&amp;nbsp;-- Some help on how to use nAnt
&lt;/p&gt;
&lt;p&gt;
For Draco.Net help: &lt;a href="http://draconet.sourceforge.net/wiki/"&gt;Draco.Net wiki&lt;/a&gt;&amp;nbsp;--
Some help on how to use Draco.net
&lt;/p&gt;
&lt;p&gt;
Tomorrow I am going to start implementing nAnt on a fairly complex project, so I will
post my findings as I go along!&lt;p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=7450e1ce-9e9b-4e68-aa3f-7ec0026ffdc5" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,7450e1ce-9e9b-4e68-aa3f-7ec0026ffdc5.aspx</comments>
      <category>All Things</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=86628950-3c69-4cb6-89cb-4dc4c69ba78a</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,86628950-3c69-4cb6-89cb-4dc4c69ba78a.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,86628950-3c69-4cb6-89cb-4dc4c69ba78a.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=86628950-3c69-4cb6-89cb-4dc4c69ba78a</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you are looking to add logging to your application, whether for error logging or
debugging or tracing, one decent option is the open source log4net. I give it a “decent”
only in that there seems to be some bugs, and I am still not totally sold on the open
source concept for a variety of reasons. But given that, some good thought has been
placed into log4net, so that you have a good variety of options on where and in what
format your logging information will be output. Note that I looked at v2, since it's
the one which allows you to output to the database.
</p>
        <p>
I am a huge proponent of logging error information to a database because you can check
on errors real-time, as well as give yourself some powerful searching mechanisms.
The client I was working for was logging to a file using an older version of log4net,
so I decided to check out the log4net database functionality. Here's where you can
find all the information you may want to know, including how to download log4net: <a href="http://logging.apache.org/log4net/" target="_blank">http://logging.apache.org/log4net/</a></p>
        <p>
What I found was mixed. On the upside, you can (to a degree) use log4net with an existing
database error log to a certain degree (I say to a certain degree because without
going in an changing the source -- which is a plus for open source). A lot of thought
has been placed into the design with regards to flexibility and performance.
</p>
        <p>
On the downside, the code seemed buggy and the documentation is pretty bad. In
order to get v2 database logging to work, I had to resort to stepping into the code
to determine what the correct configuration settings would be. So as a bonus today,
I will save the reader any heartache and post my file, along with a description of
what the reader will need to change to use it!
</p>
        <p>
First, I created a database (called test) in SQL Server 2000, and created a table
called Log. Here's the fields, and I will leave the size out so you can make your
own decisions about that, but given the amount of detail in the Message parameter
of an error message, you might want to make some big varchars in there. 
</p>
        <p>
          <table height="100" cellspacing="0" cellpadding="0" width="300" border="1">
            <tbody>
              <tr>
                <td align="middle">
Column</td>
                <td align="middle">
Type</td>
              </tr>
              <tr>
                <td align="middle">
ErrorId</td>
                <td align="middle">
Identity (int)</td>
              </tr>
              <tr>
                <td align="middle">
Date</td>
                <td align="middle">
datetime</td>
              </tr>
              <tr>
                <td align="middle">
Thread</td>
                <td align="middle">
varchar</td>
              </tr>
              <tr>
                <td align="middle">
Level</td>
                <td align="middle">
int</td>
              </tr>
              <tr>
                <td align="middle">
Logger</td>
                <td align="middle">
varchar</td>
              </tr>
              <tr>
                <td align="middle">
Message</td>
                <td align="middle">
varchar</td>
              </tr>
              <tr>
                <td align="middle">
Exception</td>
                <td align="middle">
varchar</td>
              </tr>
            </tbody>
          </table>
        </p>
        <p>
Create the table, then configure the log4net configuration file. Here's what mine
looked like with the table structure above:
</p>
        <pre>&lt;?xml version="1.0" encoding="utf-8" ?&gt;</pre>
        <pre>&lt;log4net debug="false"&gt;</pre>
        <pre>&lt;appender name="ADONetAppender" type="log4net.Appender.ADONetAppender"&gt;</pre>
        <pre>&lt;param name="BufferSize" value="1" /&gt;</pre>
        <pre>&lt;param name="ConnectionType" value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt;</pre>
        <pre>&lt;param name="ConnectionString" value="server=localhost;uid=test;pwd=test;database=test" /&gt;</pre>
        <pre>&lt;param name="CommandText" value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" /&gt;</pre>
        <pre>&lt;param name="Parameter"&gt;</pre>
        <pre>&lt;param name="ParameterName"&amp;#0;value="@log_date" /&gt;</pre>
        <pre>&lt;param name="DbType" value="DateTime" /&gt;</pre>
        <pre>&lt;param name="Layout" type="log4net.Layout.RawTimeStampLayout" /&gt;</pre>
        <pre>&lt;/param&gt;</pre>
        <pre>&lt;param name="Parameter"&gt;</pre>
        <pre>&lt;param name="ParameterName"&amp;#0;value="@thread" /&gt;</pre>
        <pre>&lt;param name="DbType" value="String" /&gt;</pre>
        <pre>&lt;param name="Size" value="255" /&gt;</pre>
        <pre>&lt;param name="Layout" type="log4net.Layout.PatternLayout"&gt;</pre>
        <pre>&lt;param name="ConversionPattern" value="%t" /&gt;</pre>
        <pre>&lt;/param&gt;</pre>
        <pre>&lt;/param&gt;</pre>
        <pre>&lt;param name="Parameter"&gt;</pre>
        <pre>&lt;param name="ParameterName"&amp;#0;value="@log_level" /&gt;</pre>
        <pre>&lt;param name="DbType" value="String" /&gt;</pre>
        <pre>&lt;param name="Size" value="50" /&gt;</pre>
        <pre>&lt;param name="Layout" type="log4net.Layout.PatternLayout"&gt;</pre>
        <pre>&lt;param name="ConversionPattern" value="%p" /&gt;</pre>
        <pre>&lt;/param&gt;</pre>
        <pre>&lt;/param&gt;</pre>
        <pre>&lt;param name="Parameter"&gt;</pre>
        <pre>&lt;param name="ParameterName"&amp;#0;value="@logger" /&gt;</pre>
        <pre>&lt;param name="DbType" value="String" /&gt;</pre>
        <pre>&lt;param name="Size" value="255" /&gt;</pre>
        <pre>&lt;param name="Layout" type="log4net.Layout.PatternLayout"&gt;</pre>
        <pre>&lt;param name="ConversionPattern" value="%c" /&gt;</pre>
        <pre>&lt;/param&gt;</pre>
        <pre>&lt;/param&gt;</pre>
        <pre>&lt;param name="Parameter"&gt;</pre>
        <pre>&lt;param name="ParameterName"&amp;#0;value="@message" /&gt;</pre>
        <pre>&lt;param name="DbType" value="String" /&gt;</pre>
        <pre>&lt;param name="Size" value="4000" /&gt;</pre>
        <pre>&lt;param name="Layout" type="log4net.Layout.PatternLayout"&gt;</pre>
        <pre>&lt;param name="ConversionPattern" value="%m" /&gt;</pre>
        <pre>&lt;/param&gt;</pre>
        <pre>&lt;/param&gt;</pre>
        <pre>&lt;param name="Parameter"&gt;</pre>
        <pre>&lt;param name="ParameterName"&amp;#0;value="@exception" /&gt;</pre>
        <pre>&lt;param name="DbType" value="String" /&gt;</pre>
        <pre>&lt;param name="Size" value="2000" /&gt;</pre>
        <pre>&lt;param name="Layout" type="log4net.Layout.ExceptionLayout" /&gt;</pre>
        <pre>&lt;/param&gt;</pre>
        <pre>&lt;/appender&gt;</pre>
        <pre>&lt;root&gt;</pre>
        <pre>&lt;level value="DEBUG" /&gt;</pre>
        <pre>&lt;appender-ref ref="ADONetAppender" /</pre>
        <pre>&lt;/root&gt;</pre>
        <pre>&lt;/log4net&gt;</pre>
        <p>
          <a href="http://www.dotnettechnologies.com/dotnettechnologies/content/binary/config.log4net">config.log4net
(2.32 KB)</a>
        </p>
        <p>
Of course, first thing you'll want to do is change the ConnectionString value to your
situation. Now, some weird things I found. It doesn't seem to use the stored procedure
it says it does. I stepped through the source, and it looks like it just tries to
execute a SQL statement, which can be found in the CommandText parameter in the configuration
file. So really, you could likely strip out all the parameters listed above. I have
to confess it has been some months since I looked at log4net, so there might be a
reason I left them in, such as a different part of the code that uses them and without
it, it fails. So, take a few minutes and strip them out, and see what you get. But
the saving you get from my slogging through the code should more than justify looking
at this configuration file.
</p>
        <p>
My final review is this: If you're creating a production app, here's your two options:
roll your own solution or use log4net. If you plan on using log4net, download the
source, learn it, and be prepared to spend some time (possibly considerable) debugging
it. As a consultant, unless you need to ability to switch logging types (e.g. database
to file to application log) dynamically, I would recommend rolling your own logging
system, and write it such you can use it in multiple applications. Use log4net to
get some ideas on the best way to accomplish it. Why? I think it tries to be too much
to everyone, and it's not quite yet complete, and the documentation is lacking. In
the end, KISS wins (keep it simple, stupid).
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=86628950-3c69-4cb6-89cb-4dc4c69ba78a" />
      </body>
      <title>using log4net database storage -- review and database configuration correction</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,86628950-3c69-4cb6-89cb-4dc4c69ba78a.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/21/usingLog4netDatabaseStorageReviewAndDatabaseConfigurationCorrection.aspx</link>
      <pubDate>Sun, 21 Nov 2004 16:05:01 GMT</pubDate>
      <description>&lt;p&gt;
If you are looking to add logging to your application, whether for error logging or
debugging or tracing, one decent option is the open source log4net. I give it a &amp;#8220;decent&amp;#8221;
only in that there seems to be some bugs, and I am still not totally sold on the open
source concept for a variety of reasons. But given that, some good thought has been
placed into log4net, so that you have a good variety of options on where and in what
format your logging information will be output. Note that I looked at v2, since it's
the one which allows you to output to the database.
&lt;/p&gt;
&lt;p&gt;
I am a huge proponent of logging error information to a database because you can check
on errors real-time, as well as give yourself some powerful searching mechanisms.
The client I was working for was logging to a file using an older version of log4net,
so I decided to check out the log4net database functionality. Here's where you can
find all the information you may want to know, including how to download log4net: &lt;a href="http://logging.apache.org/log4net/" target=_blank&gt;http://logging.apache.org/log4net/&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
What I found was mixed. On the upside, you can (to a degree) use log4net with an existing
database error log to a certain degree (I say to a certain degree because without
going in an changing the source -- which is a plus for open source). A lot of thought
has been placed into the design with regards to flexibility and performance.
&lt;/p&gt;
&lt;p&gt;
On the downside, the code&amp;nbsp;seemed buggy and the documentation is pretty bad. In
order to get v2 database logging to work, I had to resort to stepping into the code
to determine what the correct configuration settings would be. So as a bonus today,
I will save the reader any heartache and post my file, along with a description of
what the reader will need to change to use it!
&lt;/p&gt;
&lt;p&gt;
First, I created a database (called test) in SQL Server 2000, and created a table
called Log. Here's the fields, and I will leave the size out so you can make your
own decisions about that, but given the amount of detail in the Message parameter
of an error message, you might want to make some big varchars in there. 
&lt;/p&gt;
&lt;p&gt;
&lt;table height=100 cellspacing=0 cellpadding=0 width=300 border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align=middle&gt;
Column&lt;/td&gt;
&lt;td align=middle&gt;
Type&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=middle&gt;
ErrorId&lt;/td&gt;
&lt;td align=middle&gt;
Identity (int)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=middle&gt;
Date&lt;/td&gt;
&lt;td align=middle&gt;
datetime&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=middle&gt;
Thread&lt;/td&gt;
&lt;td align=middle&gt;
varchar&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=middle&gt;
Level&lt;/td&gt;
&lt;td align=middle&gt;
int&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=middle&gt;
Logger&lt;/td&gt;
&lt;td align=middle&gt;
varchar&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=middle&gt;
Message&lt;/td&gt;
&lt;td align=middle&gt;
varchar&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align=middle&gt;
Exception&lt;/td&gt;
&lt;td align=middle&gt;
varchar&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;
Create the table, then configure the log4net configuration file. Here's what mine
looked like with the table structure above:
&lt;/p&gt;
&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;log4net debug="false"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;appender name="ADONetAppender" type="log4net.Appender.ADONetAppender"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="BufferSize" value="1" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ConnectionType" value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ConnectionString" value="server=localhost;uid=test;pwd=test;database=test" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="CommandText" value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Parameter"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ParameterName"&amp;amp;#0;value="@log_date" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="DbType" value="DateTime" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Layout" type="log4net.Layout.RawTimeStampLayout" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/param&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Parameter"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ParameterName"&amp;amp;#0;value="@thread" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="DbType" value="String" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Size" value="255" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Layout" type="log4net.Layout.PatternLayout"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ConversionPattern" value="%t" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/param&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/param&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Parameter"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ParameterName"&amp;amp;#0;value="@log_level" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="DbType" value="String" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Size" value="50" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Layout" type="log4net.Layout.PatternLayout"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ConversionPattern" value="%p" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/param&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/param&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Parameter"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ParameterName"&amp;amp;#0;value="@logger" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="DbType" value="String" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Size" value="255" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Layout" type="log4net.Layout.PatternLayout"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ConversionPattern" value="%c" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/param&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/param&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Parameter"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ParameterName"&amp;amp;#0;value="@message" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="DbType" value="String" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Size" value="4000" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Layout" type="log4net.Layout.PatternLayout"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ConversionPattern" value="%m" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/param&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/param&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Parameter"&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="ParameterName"&amp;amp;#0;value="@exception" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="DbType" value="String" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Size" value="2000" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;param name="Layout" type="log4net.Layout.ExceptionLayout" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/param&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/appender&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;root&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;level value="DEBUG" /&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;appender-ref ref="ADONetAppender" /&lt;/pre&gt;&lt;pre&gt;&amp;lt;/root&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/log4net&amp;gt;&lt;/pre&gt;
&lt;p&gt;
&lt;a href="http://www.dotnettechnologies.com/dotnettechnologies/content/binary/config.log4net"&gt;config.log4net
(2.32 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Of course, first thing you'll want to do is change the ConnectionString value to your
situation. Now, some weird things I found. It doesn't seem to use the stored procedure
it says it does. I stepped through the source, and it looks like it just tries to
execute a SQL statement, which can be found in the CommandText parameter in the configuration
file. So really, you could likely strip out all the parameters listed above. I have
to confess it has been some months since I looked at log4net, so there might be a
reason I left them in, such as a different part of the code that uses them and without
it, it fails. So, take a few minutes and strip them out, and see what you get. But
the saving you get from my slogging through the code should more than justify looking
at this configuration file.
&lt;/p&gt;
&lt;p&gt;
My final review is this: If you're creating a production app, here's your two options:
roll your own solution or use log4net. If you plan on using log4net, download the
source, learn it, and be prepared to spend some time (possibly considerable) debugging
it. As a consultant, unless you need to ability to switch logging types (e.g. database
to file to application log) dynamically, I would recommend rolling your own logging
system, and write it such you can use it in multiple applications. Use log4net to
get some ideas on the best way to accomplish it. Why? I think it tries to be too much
to everyone, and it's not quite yet complete, and the documentation is lacking. In
the end, KISS wins (keep it simple, stupid).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=86628950-3c69-4cb6-89cb-4dc4c69ba78a" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,86628950-3c69-4cb6-89cb-4dc4c69ba78a.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=3b7666de-adef-41bc-8996-9f4a96a88456</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,3b7666de-adef-41bc-8996-9f4a96a88456.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,3b7666de-adef-41bc-8996-9f4a96a88456.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3b7666de-adef-41bc-8996-9f4a96a88456</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We had a situation where the page wasn't expiring, and we were getting faulty results.
So today's tip is a quick and dirty -- make the page expire!
</p>
        <div class="cf">
          <p class="cl">
 <span class="cb1"><font color="#0000ff">private</font></span><span class="cb1"><font color="#0000ff">void</font></span> EnsurePageExpires()
</p>
          <p class="cl">
{
</p>
          <p class="cl">
Response.Expires = -1;
</p>
          <p class="cl">
            <span class="cln">
              <font color="#008080">  </font>
            </span>Response.ExpiresAbsolute
= DateTime.Now;
</p>
          <p class="cl">
 Response.CacheControl = <span class="cb2"><font color="#800000">"no-cache"</font></span>;
</p>
          <p class="cl">
}
</p>
        </div>
        <!--EndFragment-->
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=3b7666de-adef-41bc-8996-9f4a96a88456" />
      </body>
      <title>Making a page expire</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,3b7666de-adef-41bc-8996-9f4a96a88456.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/19/MakingAPageExpire.aspx</link>
      <pubDate>Fri, 19 Nov 2004 14:40:51 GMT</pubDate>
      <description>&lt;p&gt;
We had a situation where the page wasn't expiring, and we were getting faulty results.
So today's tip is a quick and dirty -- make the page expire!
&lt;/p&gt;
&lt;div class=cf&gt;
&lt;p class=cl&gt;
&amp;nbsp;&lt;span class=cb1&gt;&lt;font color=#0000ff&gt;private&lt;/font&gt;&lt;/span&gt; &lt;span class=cb1&gt;&lt;font color=#0000ff&gt;void&lt;/font&gt;&lt;/span&gt; EnsurePageExpires()
&lt;/p&gt;
&lt;p class=cl&gt;
{
&lt;/p&gt;
&lt;p class=cl&gt;
Response.Expires = -1;
&lt;/p&gt;
&lt;p class=cl&gt;
&lt;span class=cln&gt;&lt;font color=#008080&gt;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;Response.ExpiresAbsolute
= DateTime.Now;
&lt;/p&gt;
&lt;p class=cl&gt;
&amp;nbsp;Response.CacheControl = &lt;span class=cb2&gt;&lt;font color=#800000&gt;"no-cache"&lt;/font&gt;&lt;/span&gt;;
&lt;/p&gt;
&lt;p class=cl&gt;
}
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=3b7666de-adef-41bc-8996-9f4a96a88456" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,3b7666de-adef-41bc-8996-9f4a96a88456.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=54bd1528-d671-4888-ad36-a7ed311e580d</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,54bd1528-d671-4888-ad36-a7ed311e580d.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,54bd1528-d671-4888-ad36-a7ed311e580d.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=54bd1528-d671-4888-ad36-a7ed311e580d</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A very common task in application development is reporting. There are many tool packages
out there which do a great job, such as Crystal Reports, Active Reports and the new
kid on the block, SQL Server reporting tools. However, a lot of times these are overkill,
or too expensive a solution.
</p>
        <p>
Using ASP.Net, generating a UI for the results using a DataGrid or DataRepeater is
very easy and can look professional in minutes. However, users typically aren't happy
with just pulling out all the data. They want to be able to filter the data and quickly
narrow down the data they need to see.
</p>
        <p>
The solution is to create a data filter. A data filter provides a UI for selecting
one or more criteria and limiting the results displayed to the items selected in the
filter. Sometimes, the filter takes far longer to create for a deeloper than the actual
report, and from my experience not one of the 'cool' functionality to add.
</p>
        <p>
Case in point: A portal-based web site I helped develop for a large bank was about
90% reporting. By implementing base pages and styles, common grid functionality and
libraries, I was able to get the turnaround on a report from 2 weeks to a day or so.
As I analyzed the process, I noticed the report display only took a couple of hours,
but the ensuing filter could take a day or more between layout, creating the filter
items and modifying the query to handle the filter.
</p>
        <p>
Subsequently, I developed the FilterWizard, which is a User Control which handles
compiling the filter criteria, retrieving the data and making the data available to
other controls, exporting to Excel, or anything which consumes data. The beauty of
this control is that filters for individual fields can be added or removed with one
line of code. The layout of the filter can also be altered by changing single values.
</p>
        <p>
The requirements were fairly simple: Strong encapsulation of internal logic to a few
simple methods (Primarly a single point of entry for formatting the individual filters,
and a single point of entry for retrieving the values to filter on when the user pushes
a [Filter] button). When the filter is triggered, the FilterWizard should notify
the data consumer that data has been retrieved and is available for rendering.
</p>
        <p>
When formatting the individual filters, the developer should be able to change the
format of a filter simply by changing an enum value which represent the available
filter types. Examples of filter types might be a single-select combo box, a multi-select
listbox, a date range, a single value or a range of values. In the end, I wanted it
as extensible as possible so if a new filter requirement came up, I could add additional
filter types as quickly and easily as possible.
</p>
        <p>
Finally, the FilterWizard should also be able to clear itself and reset the individual
filters as well as display a summary of the filter values should the user choose to
print the page.
</p>
        <p>
There are actually two versions of this control. The first version used Dynamic SQL
to create the filtered data. It was written in VB.Net. While Dynamic SQL provides
some flexibility not easily duplicated using parameters, it's also more susceptible
to SQL Injection. The second version uses C#, and used parameterized queries. I plan
on discussing both because each has it's strengths and will reach a wider audience
of developers by providing source in both VB.Net and C#. 
</p>
        <p>
What did I come up with? A great and easy to use control which provides all that functionality.
And this is the start of my series on the FilterWizard which I will write more about,
and finally provide all the source for in upcoming writings!
</p>
        <p>
Now there's an idea for another topic (and a brief aside): C# vs. VB.net. I am a long
time VB user and fanatic, but I have to confess C# is where it's at. I will certainly
discuss this at length in the future, as there are definite advantages to using C#
(which may go away in VS 2005) which I think are largely overlooked in other discussions
on the subject. For now, let's suffice it to say if you have a choice, don't fear
C# and jump in it head first. If not, use it when you can just so you are familiar
with the syntax.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=54bd1528-d671-4888-ad36-a7ed311e580d" />
      </body>
      <title>UI Abstraction -- Component Based Development Part #1 -- Description and Requirements</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,54bd1528-d671-4888-ad36-a7ed311e580d.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/18/UIAbstractionComponentBasedDevelopmentPart1DescriptionAndRequirements.aspx</link>
      <pubDate>Thu, 18 Nov 2004 05:14:36 GMT</pubDate>
      <description>&lt;p&gt;
A very common task in application development is reporting. There are many tool packages
out there which do a great job, such as Crystal Reports, Active Reports and the new
kid on the block, SQL Server reporting tools. However, a lot of times these are overkill,
or too expensive a solution.
&lt;/p&gt;
&lt;p&gt;
Using ASP.Net, generating a UI for the results using a DataGrid or DataRepeater is
very easy and can look professional in minutes. However, users typically aren't happy
with just pulling out all the data. They want to be able to filter the data and quickly
narrow down the data they need to see.
&lt;/p&gt;
&lt;p&gt;
The solution is to create a data filter. A data filter provides a UI for selecting
one or more criteria and limiting the results displayed to the items selected in the
filter. Sometimes, the filter takes far longer to create for a deeloper than the actual
report, and from my experience not one of the 'cool' functionality to add.
&lt;/p&gt;
&lt;p&gt;
Case in point: A portal-based web site I helped develop for a large bank was about
90% reporting. By implementing base pages and styles, common grid functionality and
libraries, I was able to get the turnaround on a report from 2 weeks to a day or so.
As I analyzed the process, I noticed the report display only took a couple of hours,
but the ensuing filter could take a day or more between layout, creating the filter
items and modifying the query to handle the filter.
&lt;/p&gt;
&lt;p&gt;
Subsequently, I developed the FilterWizard, which is a User Control which handles
compiling the filter criteria, retrieving the data and making the data available to
other controls, exporting to Excel, or anything which consumes data. The beauty of
this control is that filters for individual fields can be added or removed with one
line of code. The layout of the filter can also be altered by changing single values.
&lt;/p&gt;
&lt;p&gt;
The requirements were fairly simple: Strong encapsulation of internal logic to a few
simple methods (Primarly a single point of entry for formatting the individual filters,
and a single point of entry for retrieving the values to filter on when the user pushes
a [Filter] button). When the filter is triggered, the&amp;nbsp;FilterWizard should notify
the data consumer that data has been retrieved and is available for rendering.
&lt;/p&gt;
&lt;p&gt;
When formatting the individual filters, the developer should be able to change the
format of a filter simply by changing an enum value which represent the available
filter types. Examples of filter types might be a single-select combo box, a multi-select
listbox, a date range, a single value or a range of values. In the end, I wanted it
as extensible as possible so if a new filter requirement came up, I could add additional
filter types as quickly and easily as possible.
&lt;/p&gt;
&lt;p&gt;
Finally, the FilterWizard should also be able to clear itself and reset the individual
filters as well as display a summary of the filter values should the user choose to
print the page.
&lt;/p&gt;
&lt;p&gt;
There are actually two versions of this control. The first version used Dynamic SQL
to create the filtered data. It was written in VB.Net. While Dynamic SQL provides
some flexibility not easily duplicated using parameters, it's also more susceptible
to SQL Injection. The second version uses C#, and used parameterized queries. I plan
on discussing both because each has it's strengths and will reach a wider audience
of developers by providing source in both VB.Net and C#. 
&lt;/p&gt;
&lt;p&gt;
What did I come up with? A great and easy to use control which provides all that functionality.
And this is the start of my series on the FilterWizard which I will write more about,
and finally provide all the source for in upcoming writings!
&lt;/p&gt;
&lt;p&gt;
Now there's an idea for another topic (and a brief aside): C# vs. VB.net. I am a long
time VB user and fanatic, but I have to confess C# is where it's at. I will certainly
discuss this at length in the future, as there are definite advantages to using C#
(which may go away in VS 2005) which I think are largely overlooked in other discussions
on the subject. For now, let's suffice it to say if you have a choice, don't fear
C# and jump in it head first. If not, use it when you can just so you are familiar
with the syntax.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=54bd1528-d671-4888-ad36-a7ed311e580d" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,54bd1528-d671-4888-ad36-a7ed311e580d.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Design</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=6d409bb6-7de4-4d23-9ec2-4347ab2d2d81</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,6d409bb6-7de4-4d23-9ec2-4347ab2d2d81.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,6d409bb6-7de4-4d23-9ec2-4347ab2d2d81.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6d409bb6-7de4-4d23-9ec2-4347ab2d2d81</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am actually amazed that this should be considered a tip, but since .Net came out,
I have been at 3+ client sites working with other developers, and in every case, they
didn't know how to set the debugger to break exactly where the error occurs. So, just
to get back in the swing of things, I decided to post a quick tip on effectively using
the .Net debugger.
</p>
        <p>
So let's say you do your due diligence, and you have robust error handling in your
application (I have actually heard the argument that's why you DON'T put error handling
in, so you know exactly where the error occurs...but then again, so does your customer!).
An error pops up, and your error trapping doesn't provide you with sufficient information
(another difficult thing to do, considering the error object actually gives you the
line number). The solution? Set the debugger to stop exactly on the line the error
occurs.
</p>
        <p>
To do it, open the Dubug menu, and select the <em>Exceptions</em> menu item as shown
below.
</p>
        <p>
          <img height="310" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/menu.PNG" width="275" border="0" />
        </p>
        <p>
You should then see the following dialog. Select <em>Common Language Runtime Exceptions</em>,
and select the <em>When the Exception Is Thrown/Break into the Debugger </em>option,
as shown below.
</p>
        <p>
          <img height="495" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/Exception.PNG" width="471" border="0" />
        </p>
        <p>
That's it! One thing you may find is only turning it on when you reach the page you
want to debug, or you may be hitting a lot more than you want. Typically, in ASP.Net,
I will set a break in the Page_Load, and turn it on, and reproduce the error.
</p>
        <p>
Another interesting thing about the power of this utility is the ability to select
individual exception types to break on, as shown below. Happy debugging!
</p>
        <p>
          <img height="495" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/Exception2.PNG" width="471" border="0" />
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=6d409bb6-7de4-4d23-9ec2-4347ab2d2d81" />
      </body>
      <title>Debugging in .Net</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,6d409bb6-7de4-4d23-9ec2-4347ab2d2d81.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/17/DebuggingInNet.aspx</link>
      <pubDate>Wed, 17 Nov 2004 15:29:26 GMT</pubDate>
      <description>&lt;p&gt;
I am actually amazed that this should be considered a tip, but since .Net came out,
I have been at 3+ client sites working with other developers, and in every case, they
didn't know how to set the debugger to break exactly where the error occurs. So, just
to get back in the swing of things, I decided to post a quick tip on effectively using
the .Net debugger.
&lt;/p&gt;
&lt;p&gt;
So let's say you do your due diligence, and you have robust error handling in your
application (I have actually heard the argument that's why you DON'T put error handling
in, so you know exactly where the error occurs...but then again, so does your customer!).
An error pops up, and your error trapping doesn't provide you with sufficient information
(another difficult thing to do, considering the error object actually gives you the
line number). The solution? Set the debugger to stop exactly on the line the error
occurs.
&lt;/p&gt;
&lt;p&gt;
To do it, open the Dubug menu, and select the &lt;em&gt;Exceptions&lt;/em&gt; menu item as shown
below.
&lt;/p&gt;
&lt;p&gt;
&lt;img height=310 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/menu.PNG" width=275 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
You should then see the following dialog. Select &lt;em&gt;Common Language Runtime Exceptions&lt;/em&gt;,
and select the &lt;em&gt;When the Exception Is Thrown/Break into the Debugger &lt;/em&gt;option,
as shown below.
&lt;/p&gt;
&lt;p&gt;
&lt;img height=495 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/Exception.PNG" width=471 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
That's it! One thing you may find is only turning it on when you reach the page you
want to debug, or you may be hitting a lot more than you want. Typically, in ASP.Net,
I will set a break in the Page_Load, and turn it on, and reproduce the error.
&lt;/p&gt;
&lt;p&gt;
Another interesting thing about the power of this utility is the ability to select
individual exception types to break on, as shown below. Happy debugging!
&lt;/p&gt;
&lt;p&gt;
&lt;img height=495 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/Exception2.PNG" width=471 border=0&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=6d409bb6-7de4-4d23-9ec2-4347ab2d2d81" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,6d409bb6-7de4-4d23-9ec2-4347ab2d2d81.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=ad357e09-6697-41c0-880d-e098bdb81132</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,ad357e09-6697-41c0-880d-e098bdb81132.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,ad357e09-6697-41c0-880d-e098bdb81132.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ad357e09-6697-41c0-880d-e098bdb81132</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today I signed my new contract to start a new project in a week. It's actually not
a new project, but I was contacted by a former client and asked to return to help
out with both new development as well as things I had previously worked on. To me,
getting asked to come back means I must have done something right. 
</p>
        <p>
I was actually torn a bit on going back to the project. The offer was extremely generous,
but there's the excitement of starting something totally new. The one thing about
having a diverse set of clients is that you get exposed to something new each time.
Even in cases where the challenges aren't great, the other developers aren't motivated
or the project is mundane, I still manage to take a great deal of experience from
them. Some good, some bad, but I do learn from them all. 
</p>
        <p>
Once I get the Component Based Development series done, I might just have to write
about some of my mis-adventures of Independent Consulting. I was discussing this a
bit as I signed the new contract. Everything from another contractor getting reprimanded
for putting another employee's stuffed animals into compromising positions. At another
location, the dba would frequently only speak Klingon. Yet another guy tried to extort
the company whose domain name expire -- only to find out when he re-registered the
name, he forgot to put it in his own name!
</p>
        <p>
Genius... real genius out there. There's something to say for a guy like me who tries
to act professional, shows up every day and plays well with others!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ad357e09-6697-41c0-880d-e098bdb81132" />
      </body>
      <title>It's official..</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,ad357e09-6697-41c0-880d-e098bdb81132.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/11/ItsOfficial.aspx</link>
      <pubDate>Thu, 11 Nov 2004 05:13:29 GMT</pubDate>
      <description>&lt;p&gt;
Today I signed my new contract to start a new project in a week. It's actually not
a new project, but I was contacted by a former client and asked to return to help
out with both new development as well as things I had previously worked on. To me,
getting asked to come back means I must have done something right. 
&lt;/p&gt;
&lt;p&gt;
I was actually torn a bit on going back to the project. The offer was extremely generous,
but there's the excitement of starting something totally new. The one thing about
having a diverse set of clients is that you get exposed to something new each time.
Even in cases where the challenges aren't great, the other developers aren't motivated
or the project is mundane, I still manage to take a great deal of experience from
them. Some good, some bad, but I do learn from them all. 
&lt;/p&gt;
&lt;p&gt;
Once I get the Component Based Development series done, I might just have to write
about some of my mis-adventures of Independent Consulting. I was discussing this a
bit as I signed the new contract. Everything from another contractor getting reprimanded
for putting another employee's stuffed animals into compromising positions. At another
location, the dba would frequently only speak Klingon. Yet another guy tried to extort
the company whose domain name expire -- only to find out when he re-registered the
name, he forgot to put it in his own name!
&lt;/p&gt;
&lt;p&gt;
Genius... real genius out there. There's something to say for a guy like me who tries
to act professional, shows up every day and plays well with others!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ad357e09-6697-41c0-880d-e098bdb81132" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,ad357e09-6697-41c0-880d-e098bdb81132.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=3731b015-70e4-4735-b767-9f1b94a7b08d</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,3731b015-70e4-4735-b767-9f1b94a7b08d.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,3731b015-70e4-4735-b767-9f1b94a7b08d.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3731b015-70e4-4735-b767-9f1b94a7b08d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I ran across a situation recently where I needed to dynamically hide or show
items based on whether or not a checkbox was checked. Simple enough if you know
what items need to be hidden or not, but an easier and cleaner way was to set the
appropriate CSSClass for the controls, then actually manipulate the style to do the
work. 
</p>
        <p>
So how to change the properties of a style dynamically? Here's a snippet from a CodeBehind
function, which was rendered in the Page_PreRender. The javascript was built in a
StringWriter (sw), then rendered out onto the page. 
</p>
        <p>
          <style type="text/css">
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
</style>
        </p>
        <div class="csharpcode">
          <pre class="alt">        sw.WriteLine(<span class="str">@"if
(document.all.chkMatch.checked) "</span>);</pre>
          <pre>        sw.WriteLine(<span class="str">@"document.styleSheets['Identical'].addRule
('.Identical', 'display:"</span> + myStr + <span class="str">"block"</span> + myStr
+ <span class="str">"'); "</span>);</pre>
          <pre class="alt">        sw.WriteLine(<span class="str">@"else"</span>);</pre>
          <pre>        sw.WriteLine(<span class="str">@"document.styleSheets['Identical'].addRule
('.Identical', 'display:"</span> + myStr + <span class="str">"none"</span> + myStr
+ <span class="str">"');"</span>);</pre>
        </div>
        <p>
Here's the explanation. chkMatch is a server control checkbox (this is old code. it
would have been better to use chkMatch's ClientId property when building this). When
chkMatch is checked, the CSS class 'Identical' block attribute is set to 'block mode'.
When unchecked, the style class is set to 'none', which has the effect of hiding any
objects with the CSSClass property set to 'Identical'.
</p>
        <p>
On a related topic, let's look at rendering scipt in include files vs. ASPX pages
vs. CodeBehind. First, let's eliminate ASPX pages, since that means the code may be
repeated, and we lose reuse. I suppose there's little difference between an include
file and the code behind, because you can place common functions in both. However,
from an encapsulation and organizational standpoint, I like CodeBehind because then
I only add the exact scripts I need, instead of using include files which might contain
a lot of extraneous functions. This is especially the case when I create User controls
(which I do a lot of in my upcoming series on Component Based Development).
</p>
        <p>
Feel free to write if you need further explanation. It's a powerful UI ability to
be able to manipulate style properties dynamically from client side code!
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=3731b015-70e4-4735-b767-9f1b94a7b08d" />
      </body>
      <title>How to set style properties using javascript (and ASP.Net)</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,3731b015-70e4-4735-b767-9f1b94a7b08d.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/11/HowToSetStylePropertiesUsingJavascriptAndASPNet.aspx</link>
      <pubDate>Thu, 11 Nov 2004 05:05:03 GMT</pubDate>
      <description>&lt;p&gt;
I ran across a situation recently where I needed to dynamically&amp;nbsp;hide or show
items&amp;nbsp;based on whether or not a checkbox was checked. Simple enough if you know
what items need to be hidden or not, but an easier and cleaner way was to set the
appropriate CSSClass for the controls, then actually manipulate the style to do the
work. 
&lt;/p&gt;
&lt;p&gt;
So how to change the properties of a style dynamically? Here's a snippet from a CodeBehind
function, which was rendered in the Page_PreRender. The javascript was built in a
StringWriter (sw), then rendered out onto the page. 
&lt;/p&gt;
&lt;p&gt;
&lt;style type=text/css&gt;
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
&lt;/style&gt;
&lt;div class=csharpcode&gt;&lt;pre class=alt&gt;        sw.WriteLine(&lt;span class=str&gt;@"if (document.all.chkMatch.checked)
"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;        sw.WriteLine(&lt;span class=str&gt;@"document.styleSheets['Identical'].addRule
('.Identical', 'display:"&lt;/span&gt; + myStr + &lt;span class=str&gt;"block"&lt;/span&gt; + myStr
+ &lt;span class=str&gt;"'); "&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=alt&gt;        sw.WriteLine(&lt;span class=str&gt;@"else"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;        sw.WriteLine(&lt;span class=str&gt;@"document.styleSheets['Identical'].addRule
('.Identical', 'display:"&lt;/span&gt; + myStr + &lt;span class=str&gt;"none"&lt;/span&gt; + myStr + &lt;span class=str&gt;"');"&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
Here's the explanation. chkMatch is a server control checkbox (this is old code. it
would have been better to use chkMatch's ClientId property when building this). When
chkMatch is checked, the CSS class 'Identical' block attribute is set to 'block mode'.
When unchecked, the style class is set to 'none', which has the effect of hiding any
objects with the CSSClass property set to 'Identical'.
&lt;/p&gt;
&lt;p&gt;
On a related topic, let's look at rendering scipt in include files vs. ASPX pages
vs. CodeBehind. First, let's eliminate ASPX pages, since that means the code may be
repeated, and we lose reuse. I suppose there's little difference between an include
file and the code behind, because you can place common functions in both. However,
from an encapsulation and organizational standpoint, I like CodeBehind because then
I only add the exact scripts I need, instead of using include files which might contain
a lot of extraneous functions. This is especially the case when I create User controls
(which I do a lot of in my upcoming series on Component Based Development).
&lt;/p&gt;
&lt;p&gt;
Feel free to write if you need further explanation. It's a powerful UI ability to
be able to manipulate style properties dynamically from client side code!
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=3731b015-70e4-4735-b767-9f1b94a7b08d" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,3731b015-70e4-4735-b767-9f1b94a7b08d.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=ef031338-faf2-4be6-a4cb-dc4beae66341</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,ef031338-faf2-4be6-a4cb-dc4beae66341.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,ef031338-faf2-4be6-a4cb-dc4beae66341.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ef031338-faf2-4be6-a4cb-dc4beae66341</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was thinking today that the daily tips are nice, there really isn't much I can't
write about that hasn't been written about in terms of tips. So what can I write about
that is not something I plan to make commercially available at some point, but can
enhance the .Net community?
</p>
        <p>
Today, I remembered an ASP.Net component I wrote which makes adding a complex
data filter to a report as quick as a few lines of code. It's fully extendable and
it demonstrates what UI abstraction can really do. I also have it already available
in VB.Net and C#, and an example of building dynamic SQL as well as integration with
stored procedures. It's in use for two of my large clients, and they swear by how
much time it saves them, so hopefully it can save someone out there in Blog-land a
bit of time too.
</p>
        <p>
I'll still include my daily tips, but I think this will be a great beginning to contributing
back to the ASP.Net development community which I have benefitted much from. So, stay
tuned while I get the components into a nice same project using the Northwind database.
</p>
        <p>
-- Daryl
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ef031338-faf2-4be6-a4cb-dc4beae66341" />
      </body>
      <title>What's Next?</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,ef031338-faf2-4be6-a4cb-dc4beae66341.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/10/WhatsNext.aspx</link>
      <pubDate>Wed, 10 Nov 2004 04:58:13 GMT</pubDate>
      <description>&lt;p&gt;
I was thinking today that the daily tips are nice, there really isn't much I can't
write about that hasn't been written about in terms of tips. So what can I write about
that is not something I plan to make commercially available at some point, but can
enhance the .Net community?
&lt;/p&gt;
&lt;p&gt;
Today, I remembered an ASP.Net&amp;nbsp;component I wrote which makes adding a complex
data filter to a report as quick as a few lines of code. It's fully extendable and
it demonstrates what UI abstraction can really do. I also have it already available
in VB.Net and C#, and an example of building dynamic SQL as well as integration with
stored procedures. It's in use for two of my large clients, and they swear by how
much time it saves them, so hopefully it can save someone out there in Blog-land a
bit of time too.
&lt;/p&gt;
&lt;p&gt;
I'll still include my daily tips, but I think this will be a great beginning to contributing
back to the ASP.Net development community which I have benefitted much from. So, stay
tuned while I get the components into a nice same project using the Northwind database.
&lt;/p&gt;
&lt;p&gt;
-- Daryl
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ef031338-faf2-4be6-a4cb-dc4beae66341" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,ef031338-faf2-4be6-a4cb-dc4beae66341.aspx</comments>
      <category>ASP.Net</category>
      <category>Design</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=925253af-3292-429e-9476-73db036cded4</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,925253af-3292-429e-9476-73db036cded4.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,925253af-3292-429e-9476-73db036cded4.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=925253af-3292-429e-9476-73db036cded4</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When you install the .Net framework, you also get a ton of utilities with it. For
a complete listing, follow this link:
</p>
        <p>
          <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconNETFrameworkTools.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconNETFrameworkTools.asp</a>
        </p>
        <p>
One of these utilities is insanely useful if you want to find something fast, and
you don't feel like going through the overhead and all the excess listings of the
MSDN. This miracle utility is the Windows Class Viewer, also known as WinCV.exe.
</p>
        <p>
To run it, use the .Net DOS prompt, and type in WinCV. You'll be able to enter a serach
string (or partial string), and it will list the namespace it was found in, as well
as the definitions of the accessible methods.
</p>
        <p>
Now, the neat thing which isn't really mentioned is that you can include 3rd party
searches by placing an entry in the WinCV config file. For example, I tested
this by using the Infragistics libraries. Once I placed them in the config file, I
was able to search them like any other Microsoft assembly. One caveat though -- it
only works for assemblies registered in the GAC.  I won't tell you
exactly how to edit the config file, because if you can't look at it and figure it
out, you probably shouldn't be editing that file. 
</p>
        <p>
          <img height="865" src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/wincv.PNG" width="705" border="0" />
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=925253af-3292-429e-9476-73db036cded4" />
      </body>
      <title>WinCV -- Great .Net search tool</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,925253af-3292-429e-9476-73db036cded4.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/10/WinCVGreatNetSearchTool.aspx</link>
      <pubDate>Wed, 10 Nov 2004 04:47:53 GMT</pubDate>
      <description>&lt;p&gt;
When you install the .Net framework, you also get a ton of utilities with it. For
a complete listing, follow this link:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconNETFrameworkTools.asp"&gt;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpconNETFrameworkTools.asp&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
One of these utilities is insanely useful if you want to find something fast, and
you don't feel like going through the overhead and all the excess listings of the
MSDN. This miracle utility is the Windows Class Viewer, also known as WinCV.exe.
&lt;/p&gt;
&lt;p&gt;
To run it, use the .Net DOS prompt, and type in WinCV. You'll be able to enter a serach
string (or partial string), and it will list the namespace it was found in, as well
as the definitions of the accessible methods.
&lt;/p&gt;
&lt;p&gt;
Now, the neat thing which isn't really mentioned is that you can include 3rd party
searches by placing an entry in the WinCV config file. For example,&amp;nbsp;I tested
this by using the Infragistics libraries. Once I placed them in the config file, I
was able to search them like any other Microsoft assembly. One caveat though -- it
only works for&amp;nbsp;assemblies registered in the GAC.&amp;nbsp;&amp;nbsp;I won't tell you
exactly how to edit the config file, because if you can't look at it and figure it
out, you probably shouldn't be editing that file. 
&lt;/p&gt;
&lt;p&gt;
&lt;img height=865 src="http://www.dotnettechnologies.com/DotNetTechnologies/content/binary/wincv.PNG" width=705 border=0&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=925253af-3292-429e-9476-73db036cded4" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,925253af-3292-429e-9476-73db036cded4.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=b37e885c-ab36-44a7-a0f8-41aad6f2035d</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,b37e885c-ab36-44a7-a0f8-41aad6f2035d.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,b37e885c-ab36-44a7-a0f8-41aad6f2035d.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=b37e885c-ab36-44a7-a0f8-41aad6f2035d</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As a consultant, I need to be able to port a bag of tricks from one project to the
next. Accessing MS Repository isn't always the easiest, although I have used it in
the past for internal projects.
</p>
        <p>
I ran across <a href="http://dotnet.4all.cc/" target="_blank">CodeLib for .Net by
Fish</a>, and it's a great tool, with searching, the ability to append files, notes,
code (which it formats) as well as web pages (which I have yet to figure out how to
work with).
</p>
        <p>
Best of all, it's Freeware. So give it a try, you'll like it. Heck, once you get a
library put together, maybe we can swap! ;)
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=b37e885c-ab36-44a7-a0f8-41aad6f2035d" />
      </body>
      <title>Another Great tool</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,b37e885c-ab36-44a7-a0f8-41aad6f2035d.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/09/AnotherGreatTool.aspx</link>
      <pubDate>Tue, 09 Nov 2004 05:34:42 GMT</pubDate>
      <description>&lt;p&gt;
As a consultant, I need to be able to port a bag of tricks from one project to the
next. Accessing MS Repository isn't always the easiest, although I have used it in
the past for internal projects.
&lt;/p&gt;
&lt;p&gt;
I ran across &lt;a href="http://dotnet.4all.cc/" target=_blank&gt;CodeLib for .Net by Fish&lt;/a&gt;,
and it's a great tool, with searching, the ability to append files, notes, code (which
it formats) as well as web pages (which I have yet to figure out how to work with).
&lt;/p&gt;
&lt;p&gt;
Best of all, it's Freeware. So give it a try, you'll like it. Heck, once you get a
library put together, maybe we can swap! ;)
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=b37e885c-ab36-44a7-a0f8-41aad6f2035d" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,b37e885c-ab36-44a7-a0f8-41aad6f2035d.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Design</category>
      <category>General</category>
      <category>Tips and Tricks</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=15a8bff4-1eef-4627-a4dd-3bddad6f5b98</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,15a8bff4-1eef-4627-a4dd-3bddad6f5b98.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,15a8bff4-1eef-4627-a4dd-3bddad6f5b98.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=15a8bff4-1eef-4627-a4dd-3bddad6f5b98</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Have you ever wanted to make a server control appear normal, but be read only? If
you simply set it to disabled, it's also greyed out, which can be a real pain display
wise. So here's a couple of functions which will apply client-side javascript to the
TextBox and DropDownList controls to prevent the user from being able to change the
entries. Feel free to extend them to other controls (and forward them on! :))
</p>
        <p>
          <style type="text/css">
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
</style>
        </p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="kwrd">public</span>
            <span class="kwrd">static</span>
            <span class="kwrd">void</span> SetControlReadOnly(DropDownList
ddlTemp)</pre>
          <pre>    {</pre>
          <pre class="alt">        ddlTemp.Attributes.Add(<span class="str">"onFocus"</span>,<span class="str">"window.focus()"</span>);</pre>
          <pre>        ddlTemp.Attributes.Add(<span class="str">"ondblclick"</span>,<span class="str">"window.focus()"</span>);</pre>
          <pre class="alt">        ddlTemp.Attributes.Add(<span class="str">"onClick"</span>,<span class="str">"window.focus()"</span>);</pre>
          <pre>    }</pre>
          <pre class="alt"> </pre>
          <pre>
            <span class="kwrd">public</span>
            <span class="kwrd">static</span>
            <span class="kwrd">void</span> SetControlReadOnly(TextBox
txtTemp)</pre>
          <pre class="alt">    {</pre>
          <pre>        txtTemp.Attributes.Add(<span class="str">"onFocus"</span>,<span class="str">"window.focus()"</span>);</pre>
          <pre class="alt">        txtTemp.Attributes.Add(<span class="str">"ondblclick"</span>,<span class="str">"window.focus()"</span>);</pre>
          <pre>        txtTemp.Attributes.Add(<span class="str">"onClick"</span>,<span class="str">"window.focus()"</span>);</pre>
          <pre class="alt">    }</pre>
        </div>
        <p>
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=15a8bff4-1eef-4627-a4dd-3bddad6f5b98" />
      </body>
      <title>Setting a control to ReadOnly using javascript</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,15a8bff4-1eef-4627-a4dd-3bddad6f5b98.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/08/SettingAControlToReadOnlyUsingJavascript.aspx</link>
      <pubDate>Mon, 08 Nov 2004 04:47:19 GMT</pubDate>
      <description>&lt;p&gt;
Have you ever wanted to make a server control appear normal, but be read only? If
you simply set it to disabled, it's also greyed out, which can be a real pain display
wise. So here's a couple of functions which will apply client-side javascript to the
TextBox and DropDownList controls to prevent the user from being able to change the
entries. Feel free to extend them to other controls (and forward them on! :))
&lt;/p&gt;
&lt;p&gt;
&lt;style type=text/css&gt;
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
&lt;/style&gt;
&lt;div class=csharpcode&gt;&lt;pre class=alt&gt;    &lt;span class=kwrd&gt;public&lt;/span&gt; &lt;span class=kwrd&gt;static&lt;/span&gt; &lt;span class=kwrd&gt;void&lt;/span&gt; SetControlReadOnly(DropDownList
ddlTemp)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class=alt&gt;        ddlTemp.Attributes.Add(&lt;span class=str&gt;"onFocus"&lt;/span&gt;,&lt;span class=str&gt;"window.focus()"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;        ddlTemp.Attributes.Add(&lt;span class=str&gt;"ondblclick"&lt;/span&gt;,&lt;span class=str&gt;"window.focus()"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=alt&gt;        ddlTemp.Attributes.Add(&lt;span class=str&gt;"onClick"&lt;/span&gt;,&lt;span class=str&gt;"window.focus()"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;    }&lt;/pre&gt;&lt;pre class=alt&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;    &lt;span class=kwrd&gt;public&lt;/span&gt; &lt;span class=kwrd&gt;static&lt;/span&gt; &lt;span class=kwrd&gt;void&lt;/span&gt; SetControlReadOnly(TextBox
txtTemp)&lt;/pre&gt;&lt;pre class=alt&gt;    {&lt;/pre&gt;&lt;pre&gt;        txtTemp.Attributes.Add(&lt;span class=str&gt;"onFocus"&lt;/span&gt;,&lt;span class=str&gt;"window.focus()"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=alt&gt;        txtTemp.Attributes.Add(&lt;span class=str&gt;"ondblclick"&lt;/span&gt;,&lt;span class=str&gt;"window.focus()"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;        txtTemp.Attributes.Add(&lt;span class=str&gt;"onClick"&lt;/span&gt;,&lt;span class=str&gt;"window.focus()"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=alt&gt;    }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=15a8bff4-1eef-4627-a4dd-3bddad6f5b98" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,15a8bff4-1eef-4627-a4dd-3bddad6f5b98.aspx</comments>
      <category>All Things</category>
      <category>ASP.Net</category>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=d78e5568-a212-46f0-9087-67dc83648920</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,d78e5568-a212-46f0-9087-67dc83648920.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,d78e5568-a212-46f0-9087-67dc83648920.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d78e5568-a212-46f0-9087-67dc83648920</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
On the project I am currently working on, the entire department uses the same Portal
for hosting the different applications. That's great in that it promotes reusability,
a common look and feel, quicker development and a central place for users to get all
related information. I could go on and on, but I won't because there's one downside:
flexibility.
</p>
        <p>
We had a request from a user to allow uploading some files. Simple enough task, except
our web pages all inherit from the same base web page, and there's no flexibility
allowed in what we can do with that page. So, I had a dilemma. I had to give the user's
the ability to upload files, but I couldn't change the base page that I HAD to use.
</p>
        <p>
Simple enough, I would do a search for the form tag, and change the EncType dynamically!
And here's how I did it...
</p>
        <p>
Once again, I passed in the Page reference, because this sits in a common library.
If you don't want to do that, just use the current Page reference. The other thing
you might want to do is change the “form1“ reference as a parameter to
make it more flexibility. At the time I wrote this, I knew it would never change,
so I just left it..
</p>
        <p>
          <style type="text/css">
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
</style>
        </p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="kwrd">public</span>
            <span class="kwrd">static</span>
            <span class="kwrd">void</span> ChangePortalEncType(Page
page)</pre>
          <pre>    {</pre>
          <pre class="alt">        HtmlForm form1;</pre>
          <pre>
            <span class="kwrd">if</span> (page.FindControl(<span class="str">"form1"</span>)
!= <span class="kwrd">null</span>) </pre>
          <pre class="alt">        {    </pre>
          <pre>            form1 = (HtmlForm) page.FindControl(<span class="str">"form1"</span>);</pre>
          <pre class="alt">
            <span class="kwrd">if</span> (form1.Attributes[<span class="str">"enctype"</span>]
!= <span class="kwrd">null</span>)</pre>
          <pre>            {</pre>
          <pre class="alt">
            <span class="kwrd">if</span> (form1.Attributes[<span class="str">"enctype"</span>]
!= <span class="str">"multipart/form-data"</span>)</pre>
          <pre>                    form1.Attributes[<span class="str">"enctype"</span>]
= <span class="str">"multipart/form-data"</span>;</pre>
          <pre class="alt">            }</pre>
          <pre>
            <span class="kwrd">else</span>
          </pre>
          <pre class="alt">            {</pre>
          <pre>                form1.Attributes.Add(<span class="str">"enctype"</span>,<span class="str">"multipart/form-data"</span>);</pre>
          <pre class="alt">            }</pre>
          <pre>        }</pre>
          <pre class="alt">    }</pre>
        </div>
        <p>
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=d78e5568-a212-46f0-9087-67dc83648920" />
      </body>
      <title>Changing the EncType of an ASP.Net form </title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,d78e5568-a212-46f0-9087-67dc83648920.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/08/ChangingTheEncTypeOfAnASPNetForm.aspx</link>
      <pubDate>Mon, 08 Nov 2004 04:40:15 GMT</pubDate>
      <description>&lt;p&gt;
On the project I am currently working on, the entire department uses the same Portal
for hosting the different applications. That's great in that it promotes reusability,
a common look and feel, quicker development and a central place for users to get all
related information. I could go on and on, but I won't because there's one downside:
flexibility.
&lt;/p&gt;
&lt;p&gt;
We had a request from a user to allow uploading some files. Simple enough task, except
our web pages all inherit from the same base web page, and there's no flexibility
allowed in what we can do with that page. So, I had a dilemma. I had to give the user's
the ability to upload files, but I couldn't change the base page that I HAD to use.
&lt;/p&gt;
&lt;p&gt;
Simple enough, I would do a search for the form tag, and change the EncType dynamically!
And here's how I did it...
&lt;/p&gt;
&lt;p&gt;
Once again, I passed in the Page reference, because this sits in a common library.
If you don't want to do that, just use the current Page reference. The other thing
you might want to do is change the &amp;#8220;form1&amp;#8220; reference as a parameter to
make it more flexibility. At the time I wrote this, I knew it would never change,
so I just left it..
&lt;/p&gt;
&lt;p&gt;
&lt;style type=text/css&gt;
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
&lt;/style&gt;
&lt;div class=csharpcode&gt;&lt;pre class=alt&gt;    &lt;span class=kwrd&gt;public&lt;/span&gt; &lt;span class=kwrd&gt;static&lt;/span&gt; &lt;span class=kwrd&gt;void&lt;/span&gt; ChangePortalEncType(Page
page)&lt;/pre&gt;&lt;pre&gt;    {&lt;/pre&gt;&lt;pre class=alt&gt;        HtmlForm form1;&lt;/pre&gt;&lt;pre&gt;        &lt;span class=kwrd&gt;if&lt;/span&gt; (page.FindControl(&lt;span class=str&gt;"form1"&lt;/span&gt;)
!= &lt;span class=kwrd&gt;null&lt;/span&gt;) &lt;/pre&gt;&lt;pre class=alt&gt;        {    &lt;/pre&gt;&lt;pre&gt;            form1 = (HtmlForm) page.FindControl(&lt;span class=str&gt;"form1"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=alt&gt;            &lt;span class=kwrd&gt;if&lt;/span&gt; (form1.Attributes[&lt;span class=str&gt;"enctype"&lt;/span&gt;]
!= &lt;span class=kwrd&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;            {&lt;/pre&gt;&lt;pre class=alt&gt;                &lt;span class=kwrd&gt;if&lt;/span&gt; (form1.Attributes[&lt;span class=str&gt;"enctype"&lt;/span&gt;]
!= &lt;span class=str&gt;"multipart/form-data"&lt;/span&gt;)&lt;/pre&gt;&lt;pre&gt;                    form1.Attributes[&lt;span class=str&gt;"enctype"&lt;/span&gt;]
= &lt;span class=str&gt;"multipart/form-data"&lt;/span&gt;;&lt;/pre&gt;&lt;pre class=alt&gt;            }&lt;/pre&gt;&lt;pre&gt;            &lt;span class=kwrd&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre class=alt&gt;            {&lt;/pre&gt;&lt;pre&gt;                form1.Attributes.Add(&lt;span class=str&gt;"enctype"&lt;/span&gt;,&lt;span class=str&gt;"multipart/form-data"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=alt&gt;            }&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;&lt;pre class=alt&gt;    }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=d78e5568-a212-46f0-9087-67dc83648920" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,d78e5568-a212-46f0-9087-67dc83648920.aspx</comments>
      <category>Tips and Tricks</category>
      <category>All Things</category>
      <category>ASP.Net</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=c036932a-1fc3-4777-9298-58459212e257</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,c036932a-1fc3-4777-9298-58459212e257.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,c036932a-1fc3-4777-9298-58459212e257.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=c036932a-1fc3-4777-9298-58459212e257</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Went to see the Incredibles today, and I am torn becuase while the movie was great,
the new Star Wars preview really piqued my interest to see that one! Will next May
never get here? :)
</p>
        <p>
My son was only a little less excited about the preview. At 4, I hope it's not too
scary for him, but all the other Star Wars weren't too bad, but he doesn't like sitting
through the whole thing. I can't even begin to tell you how many times I have sat
through the Factory scene in <em>Attack of the Clones</em>.
</p>
        <p>
So, for a double bonus, go see the Incredibles, but make sure you get there early.
And starting tomorrow, you can download the trailer!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=c036932a-1fc3-4777-9298-58459212e257" />
      </body>
      <title>Star Wars Trailer</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,c036932a-1fc3-4777-9298-58459212e257.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/08/StarWarsTrailer.aspx</link>
      <pubDate>Mon, 08 Nov 2004 00:48:09 GMT</pubDate>
      <description>&lt;p&gt;
Went to see the Incredibles today, and I am torn becuase while the movie was great,
the new Star Wars preview really piqued my interest to see that one! Will next May
never get here? :)
&lt;/p&gt;
&lt;p&gt;
My son was only a little less excited about the preview. At 4, I hope it's not too
scary for him, but all the other Star Wars weren't too bad, but he doesn't like sitting
through the whole thing. I can't even begin to tell you how many times I have sat
through the Factory scene in &lt;em&gt;Attack of the Clones&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
So, for a double bonus, go see the Incredibles, but make sure you get there early.
And starting tomorrow, you can download the trailer!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=c036932a-1fc3-4777-9298-58459212e257" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,c036932a-1fc3-4777-9298-58459212e257.aspx</comments>
      <category>All Things</category>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=9d2ba4c1-c425-421f-952d-917eb9589f9b</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,9d2ba4c1-c425-421f-952d-917eb9589f9b.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,9d2ba4c1-c425-421f-952d-917eb9589f9b.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9d2ba4c1-c425-421f-952d-917eb9589f9b</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Since I was looking for a new project last week, I went ahead and updated my resume.
Turns out I didn't need to, as I had a new project before I started looking, but hadn't
checked one of my email accounts before I sent word out to clients and recruiters
I was finishing up a project. The resume needed to be updated, since it had been almost
2 years since I had to actively look for a project.
</p>
        <p>
So here's a link to my resume if you want to see what I've been up to for the last
8+ years as an Independent Consultant.
</p>
        <p>
          <a href="http://www.rubiconcomputing.com/resume/resume.html" target="_blank">Resume
of Daryl Smith</a>
        </p>
        <p>
Now I just need to find time to put some active content on my company web site. Time,
time, time... never enough of it, especially if you have a life AND a family...
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9d2ba4c1-c425-421f-952d-917eb9589f9b" />
      </body>
      <title>Updated My Resume</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,9d2ba4c1-c425-421f-952d-917eb9589f9b.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/06/UpdatedMyResume.aspx</link>
      <pubDate>Sat, 06 Nov 2004 17:32:25 GMT</pubDate>
      <description>&lt;p&gt;
Since I was looking for a new project last week, I went ahead and updated my resume.
Turns out I didn't need to, as I had a new project before I started looking, but hadn't
checked one of my email accounts before I sent word out to clients and recruiters
I was finishing up a project. The resume needed to be updated, since it had been almost
2 years since I had to actively look for a project.
&lt;/p&gt;
&lt;p&gt;
So here's a link to my resume if you want to see what I've been up to for the last
8+ years as an Independent Consultant.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.rubiconcomputing.com/resume/resume.html" target="_blank"&gt;Resume
of Daryl Smith&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Now I just need to find time to put some active content on my company web site. Time,
time, time... never enough of it, especially if you have a life AND a family...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=9d2ba4c1-c425-421f-952d-917eb9589f9b" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,9d2ba4c1-c425-421f-952d-917eb9589f9b.aspx</comments>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=3d080936-1fb7-42f9-bfdc-adf6199ec9e1</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,3d080936-1fb7-42f9-bfdc-adf6199ec9e1.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,3d080936-1fb7-42f9-bfdc-adf6199ec9e1.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3d080936-1fb7-42f9-bfdc-adf6199ec9e1</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
On a rare occasion, I come across a circumstance where I can't create a SQL Server
2000 diagram, or the table is so huge and denormalized it doesn't really print from
the diagram tool (which I love, BTW).
</p>
        <p>
So, I ended up writing this little script which allows me to create a report which
is easily printable. Yes, I am definitely a guy, as I am visually focused. :)
</p>
        <p>
          <font color="#0066ff">DECLARE @TableName VARCHAR(50)</font>
        </p>
        <p>
          <font color="#0066ff">SET @TableName = 'Authors'</font>
        </p>
        <p>
          <font color="#0066ff">select<br />
 'Table_Name'   = Left(sysobjects.name,25),<br />
 'Column_name'   = Left(syscolumns.name,25),<br />
 'Type'     = Left(type_name(xusertype),10),<br />
 'Length'    = convert(int, length),<br />
 'Nullable'    = case when isnullable = 0 then 'No' else
'Yes' end<br />
from syscolumns, sysobjects where sysobjects.name = @TableName<br />
and sysobjects.id = syscolumns.id<br />
order by colid</font>
        </p>
        <p>
Now, I imagine by now anyone reading these tips are saying “OK, nothing Earth
shattering here..”. Give it time. Right now I am working on 2 projects, and
it's hard to justify a lot of blogging time when I could be billing $XX per hour as
many hours as I can stay awake and sane. At some point, I am going to write a series
of articles on “Control Oriented Development”, and possibly give the keys
to the city for a Questionaire engine I created which is basically limitless in how
it presents questionaires to users. If you can think of a question, it can ask it...
But that's down the road, so stick around!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=3d080936-1fb7-42f9-bfdc-adf6199ec9e1" />
      </body>
      <title>Creating a printable listing of fields in a table</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,3d080936-1fb7-42f9-bfdc-adf6199ec9e1.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/06/CreatingAPrintableListingOfFieldsInATable.aspx</link>
      <pubDate>Sat, 06 Nov 2004 16:45:22 GMT</pubDate>
      <description>&lt;p&gt;
On a rare occasion, I come across a circumstance where I can't create a SQL Server
2000 diagram, or the table is so huge and denormalized it doesn't really print from
the diagram tool (which I love, BTW).
&lt;/p&gt;
&lt;p&gt;
So, I ended up writing this little script which allows me to create a report which
is easily printable. Yes, I am definitely a guy, as I am visually focused. :)
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0066ff&gt;DECLARE @TableName VARCHAR(50)&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0066ff&gt;SET @TableName = 'Authors'&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0066ff&gt;select&lt;br&gt;
&amp;nbsp;'Table_Name'&amp;nbsp;&amp;nbsp;&amp;nbsp;= Left(sysobjects.name,25),&lt;br&gt;
&amp;nbsp;'Column_name'&amp;nbsp;&amp;nbsp;&amp;nbsp;= Left(syscolumns.name,25),&lt;br&gt;
&amp;nbsp;'Type'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= Left(type_name(xusertype),10),&lt;br&gt;
&amp;nbsp;'Length'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= convert(int, length),&lt;br&gt;
&amp;nbsp;'Nullable'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= case when isnullable = 0 then 'No' else
'Yes' end&lt;br&gt;
from syscolumns, sysobjects where sysobjects.name = @TableName&lt;br&gt;
and sysobjects.id = syscolumns.id&lt;br&gt;
order by colid&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Now, I imagine by now anyone reading these tips are saying &amp;#8220;OK, nothing Earth
shattering here..&amp;#8221;. Give it time. Right now I am working on 2 projects, and
it's hard to justify a lot of blogging time when I could be billing $XX per hour as
many hours as I can stay awake and sane. At some point, I am going to write a series
of articles on &amp;#8220;Control Oriented Development&amp;#8221;, and possibly give the keys
to the city for a Questionaire engine I created which is basically limitless in how
it presents questionaires to users. If you can think of a question, it can ask it...
But that's down the road, so stick around!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=3d080936-1fb7-42f9-bfdc-adf6199ec9e1" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,3d080936-1fb7-42f9-bfdc-adf6199ec9e1.aspx</comments>
      <category>Tips and Tricks</category>
      <category>SQL Tips</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=0dae7654-84d5-4573-b49b-1eef072f24d5</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,0dae7654-84d5-4573-b49b-1eef072f24d5.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,0dae7654-84d5-4573-b49b-1eef072f24d5.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0dae7654-84d5-4573-b49b-1eef072f24d5</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was faced with a challenge a while back where I needed to trigger a javascript function
when an individual item was clicked in a RadioButtonList. Unfortunately, the standard
Control.Attributes.Add functionality doesn't work here, because you can't directly
access the rendered controls easily with the RadioButtonList. In this case, I wanted
an image which indicated a required value to disappear anytime one of the options
was clicked.
</p>
        <p>
After a lot of playing around, I came up with this generic function which will append
some script to each item in a RadioButtonList. You can further modify this to apply
individual scripts to each item in the RadioButtonList. 
</p>
        <p>
          <style type="text/css">
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
</style>
        </p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="rem">/// &lt;summary&gt;</span>
          </pre>
          <pre>
            <span class="rem">///
Function to append client script to the onclick event of individual radiobuttonlist
buttons</span>
          </pre>
          <pre class="alt">
            <span class="rem">/// &lt;/summary&gt;</span>
          </pre>
          <pre>
            <span class="rem">///
&lt;param name="rbl"&gt;RadioButtonList to apply script to&lt;/param&gt;</span>
          </pre>
          <pre class="alt">
            <span class="rem">///
&lt;param name="page"&gt;The Page the script is going to be appended to&lt;/param&gt;</span>
          </pre>
          <pre>
            <span class="rem">///
&lt;param name="script"&gt;The script to append&lt;/param&gt;</span>
          </pre>
          <pre class="alt">
            <span class="kwrd">public</span>
            <span class="kwrd">static</span>
            <span class="kwrd">void</span> SetRadioButtonListItemScript(RadioButtonList
rbl, Page page, <span class="kwrd">string</span> script)</pre>
          <pre>        {</pre>
          <pre class="alt">
            <span class="kwrd">for</span> (<span class="kwrd">int</span> idx
= 0; idx &lt; rbl.Items.Count; idx++)</pre>
          <pre>            {</pre>
          <pre class="alt">                RegisterClientObjectFunction(page, rbl, idx, script);</pre>
          <pre>            }</pre>
          <pre class="alt">        }</pre>
          <pre> </pre>
          <pre class="alt">
            <span class="rem">///
&lt;summary&gt;</span>
          </pre>
          <pre>
            <span class="rem">/// </span>
          </pre>
          <pre class="alt">
            <span class="rem">///
&lt;/summary&gt;</span>
          </pre>
          <pre>
            <span class="rem">/// &lt;param name="page"&gt;The
Page the script is going to be appended to&lt;/param&gt;</span>
          </pre>
          <pre class="alt">
            <span class="rem">///
&lt;param name="rbl"&gt;RadioButtonList to apply script to&lt;/param&gt;</span>
          </pre>
          <pre>
            <span class="rem">///
&lt;param name="idx"&gt;the index of the radio button&lt;/param&gt;</span>
          </pre>
          <pre class="alt">
            <span class="rem">///
&lt;param name="script"&gt;The script to append&lt;/param&gt;</span>
          </pre>
          <pre>
            <span class="kwrd">static</span>
            <span class="kwrd">private</span>
            <span class="kwrd">void</span> RegisterClientObjectFunction(Page
page, RadioButtonList rbl, <span class="kwrd">int</span> idx, <span class="kwrd">string</span> script)</pre>
          <pre class="alt">        {</pre>
          <pre>            StringBuilder sw = <span class="kwrd">new</span> StringBuilder();</pre>
          <pre class="alt">
            <span class="kwrd">if</span> (!page.IsStartupScriptRegistered(rbl.ClientID
+ <span class="str">"_"</span> + idx.ToString() + <span class="str">"script"</span>))</pre>
          <pre>            {</pre>
          <pre class="alt">                sw.Append(<span class="str">@"&lt;SCRIPT&gt;"</span>);</pre>
          <pre>                sw.Append(<span class="str">@"document.all."</span> +
rbl.ClientID + <span class="str">"_"</span> + idx.ToString() + <span class="str">".onclick=function()
{"</span> + script + <span class="str">"return true;}"</span>);</pre>
          <pre class="alt">                sw.Append(<span class="str">@"&lt;/SCRIPT&gt;"</span>);</pre>
          <pre>                page.RegisterStartupScript(rbl.ClientID + <span class="str">"_"</span> +
idx.ToString() + <span class="str">"script"</span>,sw.ToString());</pre>
          <pre class="alt">            }</pre>
          <pre>        }</pre>
        </div>
        <p>
The key here is that each item in the list ends up with the ClientID of the RadioButtonList,
then an underscore (_), and finally the index of the item. Once you have that, you
have the keys to the city, as they say. In the example above, you are applying the
same script to all items.
</p>
        <p>
This function came out of a common library of mine. If your just going to place it
on the page itself, you don't need the page parameter. You can just use the Page object
itself. However, go ahead and throw it into a common library, because once you use
it once, it's a pretty good bet you'll need it somewhere else in the future.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0dae7654-84d5-4573-b49b-1eef072f24d5" />
      </body>
      <title>Adding client-side script to the individual items in a RadioButtonList</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,0dae7654-84d5-4573-b49b-1eef072f24d5.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/06/AddingClientsideScriptToTheIndividualItemsInARadioButtonList.aspx</link>
      <pubDate>Sat, 06 Nov 2004 05:31:28 GMT</pubDate>
      <description>&lt;p&gt;
I was faced with a challenge a while back where I needed to trigger a javascript function
when an individual item was clicked in a RadioButtonList. Unfortunately, the standard
Control.Attributes.Add functionality doesn't work here, because you can't directly
access the rendered controls easily with the RadioButtonList. In this case, I wanted
an image which indicated a required value to disappear anytime one of the options
was clicked.
&lt;/p&gt;
&lt;p&gt;
After a lot of playing around, I came up with this generic function which will append
some script to each item in a RadioButtonList. You can further modify this to apply
individual scripts to each item in the RadioButtonList. 
&lt;/p&gt;
&lt;p&gt;
&lt;style type=text/css&gt;
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
&lt;/style&gt;
&lt;div class=csharpcode&gt;&lt;pre class=alt&gt;        &lt;span class=rem&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class=rem&gt;///
Function to append client script to the onclick event of individual radiobuttonlist
buttons&lt;/span&gt;&lt;/pre&gt;&lt;pre class=alt&gt;        &lt;span class=rem&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class=rem&gt;///
&amp;lt;param name="rbl"&amp;gt;RadioButtonList to apply script to&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=alt&gt;        &lt;span class=rem&gt;///
&amp;lt;param name="page"&amp;gt;The Page the script is going to be appended to&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class=rem&gt;///
&amp;lt;param name="script"&amp;gt;The script to append&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=alt&gt;        &lt;span class=kwrd&gt;public&lt;/span&gt; &lt;span class=kwrd&gt;static&lt;/span&gt; &lt;span class=kwrd&gt;void&lt;/span&gt; SetRadioButtonListItemScript(RadioButtonList
rbl, Page page, &lt;span class=kwrd&gt;string&lt;/span&gt; script)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class=alt&gt;            &lt;span class=kwrd&gt;for&lt;/span&gt; (&lt;span class=kwrd&gt;int&lt;/span&gt; idx
= 0; idx &amp;lt; rbl.Items.Count; idx++)&lt;/pre&gt;&lt;pre&gt;            {&lt;/pre&gt;&lt;pre class=alt&gt;                RegisterClientObjectFunction(page, rbl, idx, script);&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class=alt&gt;        }&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class=alt&gt;        &lt;span class=rem&gt;///
&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class=rem&gt;/// &lt;/span&gt;&lt;/pre&gt;&lt;pre class=alt&gt;        &lt;span class=rem&gt;///
&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class=rem&gt;/// &amp;lt;param name="page"&amp;gt;The
Page the script is going to be appended to&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=alt&gt;        &lt;span class=rem&gt;///
&amp;lt;param name="rbl"&amp;gt;RadioButtonList to apply script to&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class=rem&gt;///
&amp;lt;param name="idx"&amp;gt;the index of the radio button&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=alt&gt;        &lt;span class=rem&gt;///
&amp;lt;param name="script"&amp;gt;The script to append&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;        &lt;span class=kwrd&gt;static&lt;/span&gt; &lt;span class=kwrd&gt;private&lt;/span&gt; &lt;span class=kwrd&gt;void&lt;/span&gt; RegisterClientObjectFunction(Page
page, RadioButtonList rbl, &lt;span class=kwrd&gt;int&lt;/span&gt; idx, &lt;span class=kwrd&gt;string&lt;/span&gt; script)&lt;/pre&gt;&lt;pre class=alt&gt;        {&lt;/pre&gt;&lt;pre&gt;            StringBuilder sw = &lt;span class=kwrd&gt;new&lt;/span&gt; StringBuilder();&lt;/pre&gt;&lt;pre class=alt&gt;            &lt;span class=kwrd&gt;if&lt;/span&gt; (!page.IsStartupScriptRegistered(rbl.ClientID
+ &lt;span class=str&gt;"_"&lt;/span&gt; + idx.ToString() + &lt;span class=str&gt;"script"&lt;/span&gt;))&lt;/pre&gt;&lt;pre&gt;            {&lt;/pre&gt;&lt;pre class=alt&gt;                sw.Append(&lt;span class=str&gt;@"&amp;lt;SCRIPT&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;                sw.Append(&lt;span class=str&gt;@"document.all."&lt;/span&gt; +
rbl.ClientID + &lt;span class=str&gt;"_"&lt;/span&gt; + idx.ToString() + &lt;span class=str&gt;".onclick=function()
{"&lt;/span&gt; + script + &lt;span class=str&gt;"return true;}"&lt;/span&gt;);&lt;/pre&gt;&lt;pre class=alt&gt;                sw.Append(&lt;span class=str&gt;@"&amp;lt;/SCRIPT&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre&gt;                page.RegisterStartupScript(rbl.ClientID + &lt;span class=str&gt;"_"&lt;/span&gt; +
idx.ToString() + &lt;span class=str&gt;"script"&lt;/span&gt;,sw.ToString());&lt;/pre&gt;&lt;pre class=alt&gt;            }&lt;/pre&gt;&lt;pre&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
The key here is that each item in the list ends up with the ClientID of the RadioButtonList,
then an underscore (_), and finally the index of the item. Once you have that, you
have the keys to the city, as they say. In the example above, you are applying the
same script to all items.
&lt;/p&gt;
&lt;p&gt;
This function came out of a common library of mine. If your just going to place it
on the page itself, you don't need the page parameter. You can just use the Page object
itself. However, go ahead and throw it into a common library, because once you use
it once, it's a pretty good bet you'll need it somewhere else in the future.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=0dae7654-84d5-4573-b49b-1eef072f24d5" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,0dae7654-84d5-4573-b49b-1eef072f24d5.aspx</comments>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=ea8639ae-7fd7-495d-8ad6-d61ccb151008</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,ea8639ae-7fd7-495d-8ad6-d61ccb151008.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,ea8639ae-7fd7-495d-8ad6-d61ccb151008.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ea8639ae-7fd7-495d-8ad6-d61ccb151008</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It's been over a week, and no posts. Did I suddenly get lazy? Nope. Let's see. I went
on a cruise, then came back and needed to land a new contract. If anyone says the
job market is bad, better update your skills or your resume. I actually landed a new
contract before I started looking which was quite a relief.
</p>
        <p>
The downside of all of it was that I was told I needed to look for a new project the
day before I left on vacation. Granted, it was like a 2 month notice, and should have
been stress free since I was given ample time and a lot of freedom about it, but still
when you know it's going to end, you worry about it. Secondly, I am not the type that
likes to wait, but there was no point in looking until I could act on it. So,
I enjoyed the time off as best I could. Fortunately, an old client of mine had called
while I was away, and asked if I wanted to help out with a new project. The pay was
very good, and the project sounded nice.
</p>
        <p>
Now, that's not the point of this writing. Before I knew about this offer, I started
looking as I had internet access. Being an independent contractor for years, I called
in all my cards, afraid the election might make everyone nervous. Lo and behold, and
much to the opposite of what the media was saying about the economy, the interest
came in. If I received less than 8 serious calls per day this week, I would be surprised. 
</p>
        <p>
OK, serious is a slight exaggeration. Why? It's hard to keep a straight face when
a recruiter calls, requests a VERY senior developer position, and then says the pay
is $35 / hour. One recruiter even called two days in a row, becuase she ran when I
quoted my standard rate the first time. The second day she called back, she couldn't
remember why she didn't list me as a possible candidate, until I pointed out there
was a very large discrepancy in what I consider a Sr. Developer rate and what she
was offering.
</p>
        <p>
All that behind me, there were still some promising leads. So I am not buying this
whole “tech death” market. If you have skills and experience, and can
market yourself, then there are good contracts still available.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ea8639ae-7fd7-495d-8ad6-d61ccb151008" />
      </body>
      <title>It's been a while...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,ea8639ae-7fd7-495d-8ad6-d61ccb151008.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/11/05/ItsBeenAWhile.aspx</link>
      <pubDate>Fri, 05 Nov 2004 05:17:14 GMT</pubDate>
      <description>&lt;p&gt;
It's been over a week, and no posts. Did I suddenly get lazy? Nope. Let's see. I went
on a cruise, then came back and needed to land a new contract. If anyone says the
job market is bad, better update your skills or your resume. I actually landed a new
contract before I started looking which was quite a relief.
&lt;/p&gt;
&lt;p&gt;
The downside of all of it was that I was told I needed to look for a new project the
day before I left on vacation. Granted, it was like a 2 month notice, and should have
been stress free since I was given ample time and a lot of freedom about it, but still
when you know it's going to end, you worry about it. Secondly, I am not the type that
likes to wait, but there was no point in looking until I could act&amp;nbsp;on it. So,
I enjoyed the time off as best I could. Fortunately, an old client of mine had called
while I was away, and asked if I wanted to help out with a new project. The pay was
very good, and the project sounded nice.
&lt;/p&gt;
&lt;p&gt;
Now, that's not the point of this writing. Before I knew about this offer, I started
looking as I had internet access. Being an independent contractor for years, I called
in all my cards, afraid the election might make everyone nervous. Lo and behold, and
much to the opposite of what the media was saying about the economy, the interest
came in. If I received less than 8 serious calls per day this week, I would be surprised. 
&lt;/p&gt;
&lt;p&gt;
OK, serious is a slight exaggeration. Why? It's hard to keep a straight face when
a recruiter calls, requests a VERY senior developer position, and then says the pay
is $35 / hour. One recruiter even called two days in a row, becuase she ran when I
quoted my standard rate the first time. The second day she called back, she couldn't
remember why she didn't list me as a possible candidate, until I pointed out there
was a very large discrepancy in what I consider a Sr. Developer rate and what she
was offering.
&lt;/p&gt;
&lt;p&gt;
All that behind me, there were still some promising leads. So I am not buying this
whole &amp;#8220;tech death&amp;#8221; market. If you have skills and experience, and can
market yourself, then there are good contracts still available.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ea8639ae-7fd7-495d-8ad6-d61ccb151008" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,ea8639ae-7fd7-495d-8ad6-d61ccb151008.aspx</comments>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=c3cbb979-216b-4db0-b8ca-922656e6da85</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,c3cbb979-216b-4db0-b8ca-922656e6da85.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,c3cbb979-216b-4db0-b8ca-922656e6da85.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=c3cbb979-216b-4db0-b8ca-922656e6da85</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Ran across this nifty little tool, so I decided to create a whole new feed dedicated
to some neat tools I have come across in my travels. So here's the first one. 
</p>
        <p>
This tool is an addin which takes source code from the Visual Studio IDE, and formats
it in HTML so you can post it on the web, in a blog, etc. It's easy to access and
use, just a simple right-mouse click. And now the moment of truth, what it looks like:
</p>
        <p>
          <style type="text/css">
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
</style>
        </p>
        <div class="csharpcode">
          <pre class="alt">
            <span class="kwrd"> public</span>
            <span class="kwrd">static</span>
            <span class="kwrd">string</span> ReadConfigurationValue(<span class="kwrd">string</span> p_strConfigString)</pre>
          <pre>        {</pre>
          <pre class="alt">
            <span class="kwrd">try</span>
          </pre>
          <pre>            {</pre>
          <pre class="alt">
            <span class="kwrd">string</span> strValue
= <span class="str">""</span>;</pre>
          <pre>                System.Configuration.AppSettingsReader l_configurationAppSettings = <span class="kwrd">new</span> System.Configuration.AppSettingsReader();</pre>
          <pre class="alt">                l_configurationAppSettings = <span class="kwrd">new</span> System.Configuration.AppSettingsReader();</pre>
          <pre>                strValue = (<span class="kwrd">string</span>)(l_configurationAppSettings.GetValue(p_strConfigString,Type.GetType(<span class="str">"System.String"</span>)));</pre>
          <pre class="alt"> </pre>
          <pre>
            <span class="kwrd">return</span> strValue;</pre>
          <pre class="alt">            }</pre>
          <pre>
            <span class="kwrd">catch</span> (Exception
ex)</pre>
          <pre class="alt">            {</pre>
          <pre>                ErrorHandler.LogError(ex);</pre>
          <pre class="alt">
            <span class="kwrd">return</span>
            <span class="str">""</span>;</pre>
          <pre>            }</pre>
          <pre class="alt">        }</pre>
        </div>
        <p>
So far, it looks great. I will need to get used to a couple of little quirks, but
all in all, I am impressed!
</p>
        <p>
Where to get this great tool?
</p>
        <p>
          <a href="http://www.jtleigh.com/people/colin/blog/archives/2004/10/copysourceashtm_1.html">http://www.jtleigh.com/people/colin/blog/archives/2004/10/copysourceashtm_1.html</a>
        </p>
        <p>
Enjoy!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=c3cbb979-216b-4db0-b8ca-922656e6da85" />
      </body>
      <title>Neat tool for blogging / web posting</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,c3cbb979-216b-4db0-b8ca-922656e6da85.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/10/23/NeatToolForBloggingWebPosting.aspx</link>
      <pubDate>Sat, 23 Oct 2004 16:31:16 GMT</pubDate>
      <description>&lt;p&gt;
Ran across this nifty little tool, so I decided to create a whole new feed dedicated
to some neat tools I have come across in my travels. So here's the first one. 
&lt;/p&gt;
&lt;p&gt;
This tool is an addin which takes source code from the Visual Studio IDE, and formats
it in HTML so you can post it on the web, in a blog, etc. It's easy to access and
use, just a simple right-mouse click. And now the moment of truth, what it looks like:
&lt;/p&gt;
&lt;p&gt;
&lt;style type=text/css&gt;
.csharpcode
{
 font-size: 10pt;
 color: black;
 font-family: Courier New , Courier, Monospace;
 background-color: #ffffff;
 /*white-space: pre;*/
}
.csharpcode pre { margin: 0px; }
.rem { color: #008000; }
.kwrd { color: #0000ff; }
.str { color: #006080; }
.op { color: #0000c0; }
.preproc { color: #cc6633; }
.asp { background-color: #ffff00; }
.html { color: #800000; }
.attr { color: #ff0000; }
.alt 
{
 background-color: #f4f4f4;
 width: 100%;
 margin: 0px;
}
.lnum { color: #606060; }
&lt;/style&gt;
&lt;div class=csharpcode&gt;&lt;pre class=alt&gt;&lt;span class=kwrd&gt; public&lt;/span&gt; &lt;span class=kwrd&gt;static&lt;/span&gt; &lt;span class=kwrd&gt;string&lt;/span&gt; ReadConfigurationValue(&lt;span class=kwrd&gt;string&lt;/span&gt; p_strConfigString)&lt;/pre&gt;&lt;pre&gt;        {&lt;/pre&gt;&lt;pre class=alt&gt;            &lt;span class=kwrd&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;            {&lt;/pre&gt;&lt;pre class=alt&gt;                &lt;span class=kwrd&gt;string&lt;/span&gt; strValue
= &lt;span class=str&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;                System.Configuration.AppSettingsReader l_configurationAppSettings = &lt;span class=kwrd&gt;new&lt;/span&gt; System.Configuration.AppSettingsReader();&lt;/pre&gt;&lt;pre class=alt&gt;                l_configurationAppSettings = &lt;span class=kwrd&gt;new&lt;/span&gt; System.Configuration.AppSettingsReader();&lt;/pre&gt;&lt;pre&gt;                strValue = (&lt;span class=kwrd&gt;string&lt;/span&gt;)(l_configurationAppSettings.GetValue(p_strConfigString,Type.GetType(&lt;span class=str&gt;"System.String"&lt;/span&gt;)));&lt;/pre&gt;&lt;pre class=alt&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre&gt;                &lt;span class=kwrd&gt;return&lt;/span&gt; strValue;&lt;/pre&gt;&lt;pre class=alt&gt;            }&lt;/pre&gt;&lt;pre&gt;            &lt;span class=kwrd&gt;catch&lt;/span&gt; (Exception
ex)&lt;/pre&gt;&lt;pre class=alt&gt;            {&lt;/pre&gt;&lt;pre&gt;                ErrorHandler.LogError(ex);&lt;/pre&gt;&lt;pre class=alt&gt;                &lt;span class=kwrd&gt;return&lt;/span&gt; &lt;span class=str&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;pre&gt;            }&lt;/pre&gt;&lt;pre class=alt&gt;        }&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
So far, it looks great. I will need to get used to a couple of little quirks, but
all in all, I am impressed!
&lt;/p&gt;
&lt;p&gt;
Where to get this great tool?
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.jtleigh.com/people/colin/blog/archives/2004/10/copysourceashtm_1.html"&gt;http://www.jtleigh.com/people/colin/blog/archives/2004/10/copysourceashtm_1.html&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Enjoy!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=c3cbb979-216b-4db0-b8ca-922656e6da85" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,c3cbb979-216b-4db0-b8ca-922656e6da85.aspx</comments>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=cf051622-b25b-46f2-9029-2dd665574888</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,cf051622-b25b-46f2-9029-2dd665574888.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,cf051622-b25b-46f2-9029-2dd665574888.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=cf051622-b25b-46f2-9029-2dd665574888</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Not a bad day. Finished my MCSD .Net (C#) finally (after putting off the final test
for almost a year out of sheer busy).. and figured out what the problem with the RSS
feed was. Good ol' URLScan was blocking some key functionality. A quick trip to the
log file, and viola, we're good as new! So, FINALLY I think we have this thing configured!
So, when I get back from vacation, let the real blogging begin!
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=cf051622-b25b-46f2-9029-2dd665574888" />
      </body>
      <title>Not so Bummed Anymore</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,cf051622-b25b-46f2-9029-2dd665574888.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/10/23/NotSoBummedAnymore.aspx</link>
      <pubDate>Sat, 23 Oct 2004 03:37:20 GMT</pubDate>
      <description>&lt;p&gt;
Not a bad day. Finished my MCSD .Net (C#) finally (after putting off the final test
for almost a year out of sheer busy).. and figured out what the problem with the RSS
feed was. Good ol' URLScan was blocking some key functionality. A quick trip to the
log file, and viola, we're good as new! So, FINALLY I think we have this thing configured!
So, when I get back from vacation, let the real blogging begin!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=cf051622-b25b-46f2-9029-2dd665574888" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,cf051622-b25b-46f2-9029-2dd665574888.aspx</comments>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=81acae9d-5ed6-41a5-aba2-0bff29db3ef6</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,81acae9d-5ed6-41a5-aba2-0bff29db3ef6.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,81acae9d-5ed6-41a5-aba2-0bff29db3ef6.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=81acae9d-5ed6-41a5-aba2-0bff29db3ef6</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was finally getting around to playing with dasBlog a bit, and noticed the RSS isn't
working correctly (rather, the web service isn't). So, I *might* get a chance to fix
it before I go on vacation, but it not, C'est le vie for a week. I suspect it has
to do with security on the server, but we'll see....
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=81acae9d-5ed6-41a5-aba2-0bff29db3ef6" />
      </body>
      <title>Bummer</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,81acae9d-5ed6-41a5-aba2-0bff29db3ef6.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/10/22/Bummer.aspx</link>
      <pubDate>Fri, 22 Oct 2004 05:41:03 GMT</pubDate>
      <description>&lt;p&gt;
I was finally getting around to playing with dasBlog a bit, and noticed the RSS isn't
working correctly (rather, the web service isn't). So, I *might* get a chance to fix
it before I go on vacation, but it not, C'est le vie for a week. I suspect it has
to do with security on the server, but we'll see....
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=81acae9d-5ed6-41a5-aba2-0bff29db3ef6" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,81acae9d-5ed6-41a5-aba2-0bff29db3ef6.aspx</comments>
      <category>General</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=40eea460-fff4-46be-aa87-e5b38db7558e</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,40eea460-fff4-46be-aa87-e5b38db7558e.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,40eea460-fff4-46be-aa87-e5b38db7558e.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=40eea460-fff4-46be-aa87-e5b38db7558e</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Arial">In my Design section today, I ranted a bit about automated testing
and a trend I have noticed to avoid directly accessing a database for that testing.
It didn't start out to be a rant, but rather a tip about grabbing a random SQL record.</font>
        </p>
        <p>
          <font face="Arial">Using an <font color="#0033ff">ORDER BY NewID()</font> clause,
you can either randomly order your data, or grab a random single row. I use the single
row method to grab data for testing so I am not always testing the same value, or
occassionally the random order when I am searching for a particular set of data using
a cursor for really complicated testing. Here's the usage:</font>
        </p>
        <p>
Random order:
</p>
        <p>
          <font color="#0033ff">SELECT * FROM Authors ORDER BY NewID()</font>
        </p>
        <p>
Single Random Record:
</p>
        <p>
          <font color="#0033ff">SELECT TOP 1 * FROM Authors ORDER BY NewID()</font>
        </p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=40eea460-fff4-46be-aa87-e5b38db7558e" />
      </body>
      <title>Grabbing a random record using T-SQL/SQL Server 2000</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,40eea460-fff4-46be-aa87-e5b38db7558e.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/10/21/GrabbingARandomRecordUsingTSQLSQLServer2000.aspx</link>
      <pubDate>Thu, 21 Oct 2004 05:58:16 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Arial&gt;In my Design section today, I ranted a bit about automated testing
and a trend I have noticed to avoid directly accessing a database for that testing.
It didn't start out to be a rant, but rather a tip about grabbing a random SQL record.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Arial&gt;Using an &lt;font color=#0033ff&gt;ORDER BY NewID()&lt;/font&gt; clause, you
can either randomly order your data, or grab a random single row. I use the single
row method to grab data for testing so I am not always testing the same value, or
occassionally the random order when I am searching for a particular set of data using
a cursor for really complicated testing. Here's the usage:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Random order:
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0033ff&gt;SELECT * FROM Authors ORDER BY NewID()&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Single Random Record:
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0033ff&gt;SELECT TOP 1 * FROM Authors ORDER BY NewID()&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=40eea460-fff4-46be-aa87-e5b38db7558e" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,40eea460-fff4-46be-aa87-e5b38db7558e.aspx</comments>
      <category>Tips and Tricks</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=ff152d67-a853-4be0-882b-518caaeaa7da</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,ff152d67-a853-4be0-882b-518caaeaa7da.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,ff152d67-a853-4be0-882b-518caaeaa7da.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ff152d67-a853-4be0-882b-518caaeaa7da</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
With the advent of test driven and test first development, writing meaningful
tests can be a bear. There are a lot of methods, such as data shunting and hardcoding
values, which avoid using the database for testing. While this can test the code,
it doesn't test the database CRUD. I believe I once read that 80% of all applications
are database applications, so testing the database portion is critical.
</p>
        <p>
Personally, if you write tests which avoid directly testing your data schema and access
methods, you're asking for trouble unless your Business Object tier is very robust.
Even then, schema changes might be missed in testing if they don't actually interact
with the database. 
</p>
        <p>
I am currently using nUnit for running the automated tests, and so far I absolutely
love it. However, writing meaningful tests can sometimes take longer than writing
the actual code, and as enhancements occur maintaining your tests can bog down the
progress of the application. Changes inevitable, expecially in XP programming
with their short development iterations. 
</p>
        <p>
Automated testing also invites buggy code if the developer is not careful. Here's
some examples:
</p>
        <ul>
          <li>
Some developers feel this takes place of unit and integration testing. This absolutely
isn't true, as automated testing typically only checks individual functional testing
(unless you have a very comprensive set of test cases developed -- suddenly these
tests don't seem so agile).</li>
          <li>
Automated testing for the UI is limited at best. While nUnitAsp exists, it's not quite
up to par to replace real-life beating-the-hell-out-of-the-UI testing.</li>
          <li>
There's absolutely no way to predict all of the ways a user if going to use your application
unless you are a UI and Process Flow God/Goddess. Most programmers aren't, so you
aren't going to be able to foresee all possible combinations of testing.</li>
        </ul>
        <p>
Bottom line is this. Use automated testing to test functionality against expected
results, but this is only about 25% of the actual testing you need to do, regardless
of whether the application is internal or external.
</p>
        <p>
How a tip turned into a rant, I don't know.. So I guess I am putting this under Design,
and making a second tip out of it.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ff152d67-a853-4be0-882b-518caaeaa7da" />
      </body>
      <title>Automated Testing and Bugs</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,ff152d67-a853-4be0-882b-518caaeaa7da.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/10/21/AutomatedTestingAndBugs.aspx</link>
      <pubDate>Thu, 21 Oct 2004 05:51:54 GMT</pubDate>
      <description>&lt;p&gt;
With the advent of test driven and test first&amp;nbsp;development, writing meaningful
tests can be a bear. There are a lot of methods, such as data shunting and hardcoding
values, which avoid using the database for testing. While this can test the code,
it doesn't test the database CRUD. I believe I once read that 80% of all applications
are database applications, so testing the database portion is critical.
&lt;/p&gt;
&lt;p&gt;
Personally, if you write tests which avoid directly testing your data schema and access
methods, you're asking for trouble unless your Business Object tier is very robust.
Even then, schema changes might be missed in testing if they don't actually interact
with the database. 
&lt;/p&gt;
&lt;p&gt;
I am currently using nUnit for running the automated tests, and so far I absolutely
love it. However, writing meaningful tests can sometimes take longer than writing
the actual code, and as enhancements occur maintaining your tests can bog down the
progress of the application.&amp;nbsp;Changes inevitable, expecially in XP programming
with their short development iterations. 
&lt;/p&gt;
&lt;p&gt;
Automated testing also invites buggy code if the developer is not careful. Here's
some examples:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Some developers feel this takes place of unit and integration testing. This absolutely
isn't true, as automated testing typically only checks individual functional testing
(unless you have a very comprensive set of test cases developed -- suddenly these
tests don't seem so agile).&lt;/li&gt;
&lt;li&gt;
Automated testing for the UI is limited at best. While nUnitAsp exists, it's not quite
up to par to replace real-life beating-the-hell-out-of-the-UI testing.&lt;/li&gt;
&lt;li&gt;
There's absolutely no way to predict all of the ways a user if going to use your application
unless you are a UI and Process Flow God/Goddess. Most programmers aren't, so you
aren't going to be able to foresee all possible combinations of testing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Bottom line is this. Use automated testing to test functionality against expected
results, but this is only about 25% of the actual testing you need to do, regardless
of whether the application is internal or external.
&lt;/p&gt;
&lt;p&gt;
How a tip turned into a rant, I don't know.. So I guess I am putting this under Design,
and making a second tip out of it.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=ff152d67-a853-4be0-882b-518caaeaa7da" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,ff152d67-a853-4be0-882b-518caaeaa7da.aspx</comments>
      <category>Design</category>
    </item>
    <item xml:lang="en">
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=355a9da7-0930-4c3e-afc4-5142835e7fe1</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,355a9da7-0930-4c3e-afc4-5142835e7fe1.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,355a9da7-0930-4c3e-afc4-5142835e7fe1.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=355a9da7-0930-4c3e-afc4-5142835e7fe1</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As part of an ongoing discussion with a developer (let's call him JDOAGD) I am paired
with, I had the opportunity to discuss the importance of Error Handling within an
application. The two sides:
</p>
        <ul>
          <li>
Minimalist -- only at the UI layer, and only then when the code is likely to fail</li>
          <li>
Solid -- Assume errors can happen anywhere, and handle them gracefully at ALL layers
of a multiple application. 
</li>
        </ul>
        <p>
          <br />
There's a school of thought that when an error condition occurs, throw an error or
bubble it up to the highest layer and handle it. OK, that's a strategy, but what happens
when the top layer doesn't catch the error? Crash. Fortunately, I was able to demonstrate
this fact to the developer today who adamantly insisted on handling it at the UI only.
He forgot to handle it, and BAM!, a crash ensued. 
</p>
        <p>
I wish I felt this was isolated, but I have had the privledge of working with several
hundred developers over the past 10 years, and I would guess error handling is one
of the most overlooked aspects of an architecture. Of those hundreds of developers,
I would venture error trapping and handling was considered an afterthought by 90%
of them. Some examples:
</p>
        <ul>
          <li>
Degrades performance, so why do it? (how about a dead app really performs slow)</li>
          <li>
The applicaion is for internal customers, so they are more forgiving than if we were
trying to deploy for general release</li>
          <li>
What's error handling and logging?</li>
        </ul>
        <p>
          <br />
I recall a project which I was brought into a few years ago. The 4 developers had
spent a month learning the business rules involved, and were chomping at the bit to
get started. When I came in, they mentioned they were ready to code. So, I asked a
few obvious (or so I thought) questions so I too would know how to code with them.
</p>
        <ul>
          <li>
What's the error handling strategy?</li>
          <li>
What's the data access strategy?</li>
          <li>
What's the physical architecture?</li>
          <li>
What type of security model are we implementing?</li>
          <li>
...and many more.</li>
        </ul>
        <p>
          <br />
Scary thing was, they didn't have an answer for any of them. The other scary thing
was they were billed as “Expert Coders” and were billing at a significantly
higher rate than myself. Had I less ethics, I would have asked for more $$ instead
of pushing to resolve these issues. That whole project was “interesting”
to say the least and someday I might write more about those experiences.
</p>
        <p>
Back to today. So, since I am on their payroll, I listened to JDOAGD's reasons for
not having error handling except on the UI layer. I watched him also forget to place
any at the UI level he was so adament about it. I had the hook, and he finally saw
the light. What was my point?
</p>
        <p>
In a multiple developer environment, you can never assume the other develper using
your code will trap the error (this is an encapsulation issue, which this same developer
once vehemently added encapsulation was a bad thing. In a non-web environment, crashes
kill the application. The browser is very forgiving!
</p>
        <p>
Finally, internal or not, as developers we are serving customers. Without them, we'd
have no jobs. It's important to ALWAYS give them the best possible user experience.
Anything else is simply lazy and unprofessional.
</p>
        <p>
Logging is a whole other issue, which I will save for a future session. For now, I'd
love to hear other opinions and experiences in this area, so please, drop me a comment!
</p>
        <p>
-- Daryl
</p>
        <p>
          <br />
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=355a9da7-0930-4c3e-afc4-5142835e7fe1" />
      </body>
      <title>Error Handling</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,355a9da7-0930-4c3e-afc4-5142835e7fe1.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/10/20/ErrorHandling.aspx</link>
      <pubDate>Wed, 20 Oct 2004 04:09:24 GMT</pubDate>
      <description>&lt;p&gt;
As part of an ongoing discussion with a developer (let's call him JDOAGD) I am paired
with, I had the opportunity to discuss the importance of Error Handling within an
application. The two sides:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Minimalist -- only at the UI layer, and only then when the code is likely to fail&lt;/li&gt;
&lt;li&gt;
Solid -- Assume errors can happen anywhere, and handle them gracefully at ALL layers
of a multiple application. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;br&gt;
There's a school of thought that when an error condition occurs, throw an error or
bubble it up to the highest layer and handle it. OK, that's a strategy, but what happens
when the top layer doesn't catch the error? Crash. Fortunately, I was able to demonstrate
this fact to the developer today who adamantly insisted on handling it at the UI only.
He forgot to handle it, and BAM!, a crash ensued. 
&lt;/p&gt;
&lt;p&gt;
I wish I felt this was isolated, but I have had the privledge of working with several
hundred developers over the past 10 years, and I would guess error handling is one
of the most overlooked aspects of an architecture. Of those hundreds of developers,
I would venture error trapping and handling was considered an afterthought by 90%
of them. Some examples:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Degrades performance, so why do it? (how about a dead app really performs slow)&lt;/li&gt;
&lt;li&gt;
The applicaion is for internal customers, so they are more forgiving than if we were
trying to deploy for general release&lt;/li&gt;
&lt;li&gt;
What's error handling and logging?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;br&gt;
I recall a project which I was brought into a few years ago. The 4 developers had
spent a month learning the business rules involved, and were chomping at the bit to
get started. When I came in, they mentioned they were ready to code. So, I asked a
few obvious (or so I thought) questions so I too would know how to code with them.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
What's the error handling strategy?&lt;/li&gt;
&lt;li&gt;
What's the data access strategy?&lt;/li&gt;
&lt;li&gt;
What's the physical architecture?&lt;/li&gt;
&lt;li&gt;
What type of security model are we implementing?&lt;/li&gt;
&lt;li&gt;
...and many more.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;br&gt;
Scary thing was, they didn't have an answer for any of them. The other scary thing
was they were billed as &amp;#8220;Expert Coders&amp;#8221; and were billing at a significantly
higher rate than myself. Had I less ethics, I would have asked for more $$ instead
of pushing to resolve these issues. That whole project was &amp;#8220;interesting&amp;#8221;
to say the least and someday I might write more about those experiences.
&lt;/p&gt;
&lt;p&gt;
Back to today. So, since I am on their payroll, I listened to JDOAGD's reasons for
not having error handling except on the UI layer. I watched him also forget to place
any at the UI level he was so adament about it. I had the hook, and he finally saw
the light. What was my point?
&lt;/p&gt;
&lt;p&gt;
In a multiple developer environment, you can never assume the other develper using
your code will trap the error (this is an encapsulation issue, which this same developer
once vehemently added encapsulation was a bad thing. In a non-web environment, crashes
kill the application. The browser is very forgiving!
&lt;/p&gt;
&lt;p&gt;
Finally, internal or not, as developers we are serving customers. Without them, we'd
have no jobs. It's important to ALWAYS give them the best possible user experience.
Anything else is simply lazy and unprofessional.
&lt;/p&gt;
&lt;p&gt;
Logging is a whole other issue, which I will save for a future session. For now, I'd
love to hear other opinions and experiences in this area, so please, drop me a comment!
&lt;/p&gt;
&lt;p&gt;
-- Daryl
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=355a9da7-0930-4c3e-afc4-5142835e7fe1" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,355a9da7-0930-4c3e-afc4-5142835e7fe1.aspx</comments>
      <category>Design</category>
    </item>
    <item>
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=5b5bbec9-9801-4c5c-b5e9-9dbfa1d7c6dc</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,5b5bbec9-9801-4c5c-b5e9-9dbfa1d7c6dc.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,5b5bbec9-9801-4c5c-b5e9-9dbfa1d7c6dc.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5b5bbec9-9801-4c5c-b5e9-9dbfa1d7c6dc</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h1>DBA Must Haves (IMHO)
</h1>
        <p>
First, a little about myself. I have been working with databases since SQL Server
6, and a little back when it was Sybase. Here are two procs I use so much, I have
to link them here. 
</p>
        <p>
First, there's <a href="http://vyaskn.tripod.com/index.htm" target="_blank">Narayana
Vyas Kondreddi's </a>sp_generete_inserts. It's a great utility/sproc for extracting
data from existing tables. I have used it from everything from migrating data to making
impromptu backups to text files, all the way to bailing out some hapless developers
who run against production and wipe out data they should not be touching. Here's where
you can get it: 
</p>
        <p>
          <a href="http://vyaskn.tripod.com/code/generate_inserts.txt" target="_blank">http://vyaskn.tripod.com/code/generate_inserts.txt</a>
        </p>
        <p>
Next, there's sp_findsp. Not the prettiest thing, but if I want to find out where
a string (such as a table or proc) is used, I can run this baby and it will return
to me a list where I can start looking. It's also very useful to me when I start a
new project to do some “mining“ to see what's going on. Here's where this
one can be found:
</p>
        <p>
          <a href="http://databasejournal.com/features/mssql/article.php/1458871" target="_blank">http://databasejournal.com/features/mssql/article.php/1458871</a>
        </p>
        <p>
These two follow me everywhere I go!
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=5b5bbec9-9801-4c5c-b5e9-9dbfa1d7c6dc" />
      </body>
      <title>DBA Must Haves IMHO First A Little About Myself I Have Been Working With Databases Since SQL Server 6 And A Lit</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,5b5bbec9-9801-4c5c-b5e9-9dbfa1d7c6dc.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/10/19/DBAMustHavesIMHOFirstALittleAboutMyselfIHaveBeenWorkingWithDatabasesSinceSQLServer6AndALit.aspx</link>
      <pubDate>Tue, 19 Oct 2004 14:07:53 GMT</pubDate>
      <description>&lt;h1&gt;DBA Must Haves (IMHO)
&lt;/h1&gt;
&lt;p&gt;
First, a little about myself. I have been working with databases since SQL Server
6, and a little back when it was Sybase. Here are two procs I use so much, I have
to link them here. 
&lt;/p&gt;
&lt;p&gt;
First, there's &lt;a href=http://vyaskn.tripod.com/index.htm target="_blank"&gt;Narayana
Vyas Kondreddi's &lt;/a&gt;sp_generete_inserts. It's a great utility/sproc for extracting
data from existing tables. I have used it from everything from migrating data to making
impromptu backups to text files, all the way to bailing out some hapless developers
who run against production and wipe out data they should not be touching. Here's where
you can get it: 
&lt;/p&gt;
&lt;p&gt;
&lt;a href=http://vyaskn.tripod.com/code/generate_inserts.txt target="_blank"&gt;http://vyaskn.tripod.com/code/generate_inserts.txt&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Next, there's sp_findsp. Not the prettiest thing, but if I want to find out where
a string (such as a table or proc) is used, I can run this baby and it will return
to me a list where I can start looking. It's also very useful to me when I start a
new project to do some &amp;#8220;mining&amp;#8220; to see what's going on. Here's where this
one can be found:
&lt;/p&gt;
&lt;p&gt;
&lt;a href=http://databasejournal.com/features/mssql/article.php/1458871 target="_blank"&gt;http://databasejournal.com/features/mssql/article.php/1458871&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
These two follow me everywhere I go!
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=5b5bbec9-9801-4c5c-b5e9-9dbfa1d7c6dc" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,5b5bbec9-9801-4c5c-b5e9-9dbfa1d7c6dc.aspx</comments>
      <category>Tips and Tricks</category>
    </item>
    <item xml:lang="en">
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=11106fa0-dae6-4f80-a646-d9e0774c7661</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,11106fa0-dae6-4f80-a646-d9e0774c7661.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,11106fa0-dae6-4f80-a646-d9e0774c7661.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=11106fa0-dae6-4f80-a646-d9e0774c7661</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This section is going to be where I place as many tips and tricks as I come across
them. I will try to attribute whomever I get the tip from where appropriate, but I
apologize in advance if I forget. They say imitation is the highest form of flattery,
so if I use it, consider yourself flattered! :)
</p>
        <p>
Since I work multiple projects at a time, these tips and tricks will generally be
posted as I discover them. However, I have a whole library of useful functions I can
pull from, so hopefully I won't dry up any time soon.
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=11106fa0-dae6-4f80-a646-d9e0774c7661" />
      </body>
      <title>Tip of the Day begins...</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,11106fa0-dae6-4f80-a646-d9e0774c7661.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/10/19/TipOfTheDayBegins.aspx</link>
      <pubDate>Tue, 19 Oct 2004 13:55:14 GMT</pubDate>
      <description>&lt;p&gt;
This section is going to be where I place as many tips and tricks as I come across
them. I will try to attribute whomever I get the tip from where appropriate, but I
apologize in advance if I forget. They say imitation is the highest form of flattery,
so if I use it, consider yourself flattered! :)
&lt;/p&gt;
&lt;p&gt;
Since I work multiple projects at a time, these tips and tricks will generally be
posted as I discover them. However, I have a whole library of useful functions I can
pull from, so hopefully I won't dry up any time soon.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=11106fa0-dae6-4f80-a646-d9e0774c7661" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,11106fa0-dae6-4f80-a646-d9e0774c7661.aspx</comments>
      <category>Tips and Tricks</category>
    </item>
    <item xml:lang="en">
      <trackback:ping>http://www.dotnettechnologies.com/Trackback.aspx?guid=523270e4-4551-4ea9-800d-136c8515cbcd</trackback:ping>
      <pingback:server>http://www.dotnettechnologies.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.dotnettechnologies.com/PermaLink,guid,523270e4-4551-4ea9-800d-136c8515cbcd.aspx</pingback:target>
      <dc:creator>Daryl</dc:creator>
      <wfw:comment>http://www.dotnettechnologies.com/CommentView,guid,523270e4-4551-4ea9-800d-136c8515cbcd.aspx</wfw:comment>
      <wfw:commentRss>http://www.dotnettechnologies.com/SyndicationService.asmx/GetEntryCommentsRss?guid=523270e4-4551-4ea9-800d-136c8515cbcd</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font face="Arial">I have finally decided what to do with this domain. Originally,
it was intended to host tips and tricks about using .Net that ihave acquired over
the last couple of years using .Net. That hasn't changed, but as I enter the blogging
world, it's going to get a bit easier to accomplish, I hope.</font>
        </p>
        <p>
          <font face="Arial">What took so long? Business, business, business... It's hard sometimes
to justify doing something like this when there's a ton of billable work which can
be done. I wanted to design the site, but it's hard to do when other people are willing
to pay you to design their sites. Heck, my original site is still static HTML, and
I didn't even design that one myself, since I had helped a web designer out, he decided
to help me by making my site pretty. While I still like it, I want to move in some
active content and play around with things on the site, especially when it comes to
do with some of the projects I have been working on for the past couple of years since
I became involved with .Net. </font>
        </p>
        <p>
          <font face="Arial">What do I plan on writing about? For starters, I want to share
some tips and tricks I have picked up. Other topics will be rants and raves about
everything from development methodologies I have been involved with (or thrust in,
as the current case is). I am a gadget freak, so you might hear me review off-handed
a few I like or dislike. </font>
        </p>
        <p>
          <font face="Arial">So if you are still here, enjoy the ride!</font>
        </p>
        <p>
-- Daryl
</p>
        <img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=523270e4-4551-4ea9-800d-136c8515cbcd" />
      </body>
      <title>Introduction!</title>
      <guid isPermaLink="false">http://www.dotnettechnologies.com/PermaLink,guid,523270e4-4551-4ea9-800d-136c8515cbcd.aspx</guid>
      <link>http://www.dotnettechnologies.com/2004/10/19/Introduction.aspx</link>
      <pubDate>Tue, 19 Oct 2004 03:11:43 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font face=Arial&gt;I have finally decided what to do with this domain. Originally, it
was intended to host tips and tricks about using .Net that ihave acquired over the
last couple of years using .Net. That hasn't changed, but as I enter the blogging
world, it's going to get a bit easier to accomplish, I hope.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Arial&gt;What took so long? Business, business, business... It's hard sometimes
to justify doing something like this when there's a ton of billable work which can
be done. I wanted to design the site, but it's hard to do when other people are willing
to pay you to design their sites. Heck, my original site is still static HTML, and
I didn't even design that one myself, since I had helped a web designer out, he decided
to help me by making my site pretty. While I still like it, I want to move in some
active content and play around with things on the site, especially when it comes to
do with some of the projects I have been working on for the past couple of years since
I became involved with .Net. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Arial&gt;What do I plan on writing about? For starters, I want to share some
tips and tricks I have picked up. Other topics will be rants and raves about everything
from development methodologies I have been involved with (or thrust in, as the current
case is). I am a gadget freak, so you might hear me review off-handed a few I like
or dislike. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Arial&gt;So if you are still here, enjoy the ride!&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
-- Daryl
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.dotnettechnologies.com/aggbug.ashx?id=523270e4-4551-4ea9-800d-136c8515cbcd" /&gt;</description>
      <comments>http://www.dotnettechnologies.com/CommentView,guid,523270e4-4551-4ea9-800d-136c8515cbcd.aspx</comments>
      <category>General</category>
    </item>
  </channel>
</rss>