<?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 - ASP.Net</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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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=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>
  </channel>
</rss>