<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" 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:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>ASP.NET</title>
        <link>http://www.nimblecoder.com/blog/category/6.aspx</link>
        <description>ASP.NET</description>
        <language>en-US</language>
        <copyright>Ryan Van Slooten</copyright>
        <generator>Subtext Version 2.1.1.1</generator>
        <item>
            <title>When aspnet_regsql.exe won't connect</title>
            <link>http://nimblecoder.com/blog/archive/2008/04/24/when-aspnet_regsql.exe-wont-connect.aspx</link>
            <description>&lt;p&gt;I was building a quick test web site and I was using the aspnet_regsql tool to add membership to a SQLEXPRESS database. At first, I tried:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;aspnet_regsql -A all -C "Data Source=.\SQLEXPRESS;Integrated Security=True;User Instance=True" -d "C:\code\Test\APP_DATA\aspnetdb.mdf"&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;For some reason, the SqlConnection insisted that it try to create the database and disregarded the full path to the database (note the path in the exception).&lt;/p&gt;&lt;pre&gt;SQL Exception:
System.Data.SqlClient.SqlException: Directory lookup for the file "C:\Documents and Settings\user\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS\C:\code\Asp.net\ServerControlTest\App_Data\Database.mdf" failed with the operating system error 123(The filename, directory name, or volume label syntax is incorrect.).
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Creating the C:\code\Asp.net\ServerControlTest\App_Data\Database database...
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at System.Web.Management.SqlServices.ExecuteFile(String file, String server, String database, String dbFileName, SqlConnection connection, Boolean sessionState, Boolean isInstall, SessionStateType sessionStatetype)
&lt;/pre&gt;
&lt;p&gt;Next I tried the simple commands (credit &lt;a href="http://www.4guysfromrolla.com/" target="_blank"&gt;Scott Mitchell&lt;/a&gt;) that worked great:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;sqlcmd -S localhost\SQLExpress -Q "EXEC sp_attach_db 'Foobar', N'pathToDBfile'"&lt;br /&gt;aspnet_regsql.exe -S localhost\SQLExpress -d Foobar -E -A all&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;References&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="http://scottonwriting.net/sowblog/posts/5480.aspx" target="_blank"&gt;Working with SQL Server 2005 Express Database&lt;/a&gt; 
&lt;/li&gt;&lt;li&gt;&lt;a href="http://weblogs.asp.net/lhunt/archive/2005/09/26/425966.aspx" target="_blank"&gt;Using ASPNET_RegSQL.exe with SQL Express databases in APP_DATA&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/67.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2008/04/24/when-aspnet_regsql.exe-wont-connect.aspx</guid>
            <pubDate>Thu, 24 Apr 2008 20:50:31 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/67.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2008/04/24/when-aspnet_regsql.exe-wont-connect.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/67.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/67.aspx</trackback:ping>
        </item>
        <item>
            <title>SharePoint FBA Limitations and Options</title>
            <link>http://nimblecoder.com/blog/archive/2008/04/23/sharepoint-fba-limitations-and-options.aspx</link>
            <description>&lt;p&gt;I recently set up an isolated, single-server SharePoint site with forms-based authentication (FBA) with the hopes that it would eliminate the need to create unrelated user accounts for all of the SharePoint users. The FBA setup and installation went fine and I used the &lt;a href="http://www.codeplex.com/fba" target="_blank"&gt;SharePoint FBA tool&lt;/a&gt; on &lt;a href="http://www.codeplex.com/" target="_blank"&gt;codeplex&lt;/a&gt; to administer the accounts and users which is great.&lt;/p&gt; &lt;p&gt;Unfortunately I didn't realize that disabling "Client Integration" in the SharePoint Cental Admin / Application Management / Authentication Providers would have such a dramatic effect on usability. Some of the challenges are using SharePoint Designer, the MySites functionality is impacted, inability to export list data to Excel, as well as inability to integrate with Outlook. The composite screen shot below shows the difference between enabled and disabled client integration.&lt;/p&gt; &lt;p&gt;&lt;a href="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/SharePointFBALimitationsandOptions_8EF4/SharePoint%20Client%20Integration_2.png"&gt;&lt;img height="480" alt="SharePoint Client Integration" src="http://nimblecoder.com/blog/images/nimblecoder_com/blog/WindowsLiveWriter/SharePointFBALimitationsandOptions_8EF4/SharePoint%20Client%20Integration_thumb.png" width="569" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;After spending quite a bit of time configuring and setting up FBA, I don't want to abandon it immediately. I am looking into two options to use the FBA user store (ASPNETDB) with IIS, basic authentication, and SSL. The two likely candidates are &lt;a title="Supporting HTTP Authentication and Forms Authentication in a Single ASP.NET Web Site" href="http://msdn2.microsoft.com/en-us/library/aa479391.aspx" target="_blank"&gt;MADAM&lt;/a&gt; (Mixed Authentication Disposition ASP.NET Module) and &lt;a title="Custom Basic Authentication for IIS" href="http://www.codeplex.com/CustomBasicAuth" target="_blank"&gt;Custom Basic Authentication&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;I will post updates as available.&lt;/p&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/65.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2008/04/23/sharepoint-fba-limitations-and-options.aspx</guid>
            <pubDate>Wed, 23 Apr 2008 15:07:22 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/65.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2008/04/23/sharepoint-fba-limitations-and-options.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/65.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/65.aspx</trackback:ping>
        </item>
        <item>
            <title>Using dpSyntaxHighlighter in Subtext</title>
            <link>http://nimblecoder.com/blog/archive/2007/11/16/using-dpsyntaxhighlighter-in-subtext.aspx</link>
            <description>&lt;p&gt;I finally worked on my blog theme last night and I managed to get the &lt;a href="http://code.google.com/p/syntaxhighlighter/" target="_blank"&gt;dp.SyntaxHighlighter&lt;/a&gt; to work with &lt;a href="http://subtextproject.com/" target="_blank"&gt;Subtext&lt;/a&gt;. I recall seeing someone else use it with Subtext, but I can't locate the blog anymore.&lt;/p&gt; &lt;p&gt;Here are the steps involved:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Create a custom skin for Subtext  &lt;/li&gt;&lt;li&gt;Copy the shCore.js, shBrushCSharp.js, shBrushXxx.js files in the custom skin Scripts directory (~/Skins/YourCustomSkin/Controls)  &lt;/li&gt;&lt;li&gt;Copy the SyntaxHighlighter.css file to the custom skin Styles directory (~/Skins/YourCustomSkin/Styles). If you choose to use the Flash clipboard.swf functionality, place it in the root Scripts directory.  &lt;/li&gt;&lt;li&gt;Create a Skins.User.config file in the ~/Admin directory. Add the following styles:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&amp;lt;SkinTemplates
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
&amp;gt;
  &amp;lt;Skins&amp;gt;
    &amp;lt;SkinTemplate Name="YourCustomSkin"
      TemplateFolder="YourCustomSkin"&amp;gt;
      &amp;lt;Styles&amp;gt;
        &amp;lt;!-- Use an existing skin for a template
          to include a "normal" set of files. In
          this example, I only listed the one
          required style. --&amp;gt;
        &amp;lt;Style href="Styles/SyntaxHighlighter.css" media="all" /&amp;gt;
      &amp;lt;/Styles&amp;gt;
      &amp;lt;Scripts&amp;gt;
        &amp;lt;!-- Same as above. This is only a partial list
          of scripts, and a partial list of the highlighting
          files. There are more styles to include if you
          desire. --&amp;gt;
        &amp;lt;Script Src="Scripts/shCore.js" /&amp;gt;
        &amp;lt;Script Src="Scripts/shBrushCpp.js" /&amp;gt;
        &amp;lt;Script Src="Scripts/shBrushCSharp.js" /&amp;gt;
        &amp;lt;Script Src="Scripts/shBrushJScript.js" /&amp;gt;
        &amp;lt;Script Src="Scripts/shBrushPython.js" /&amp;gt;
        &amp;lt;Script Src="Scripts/shBrushSql.js" /&amp;gt;
        &amp;lt;Script Src="Scripts/shBrushVb.js" /&amp;gt;
        &amp;lt;Script Src="Scripts/shBrushXml.js" /&amp;gt;
      &amp;lt;/Scripts&amp;gt;
    &amp;lt;/SkinTemplate&amp;gt;
  &amp;lt;/Skins&amp;gt;
&amp;lt;/SkinTemplates&amp;gt;
&lt;/pre&gt;
&lt;/li&gt;&lt;li&gt;Modify the custom skin PageTemplate.ascx file to include the following code:&lt;br /&gt;&lt;pre name="code" class="js"&gt;&amp;lt;yourskin:Footer id="Footer" runat="server" /&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
  init();
  addLoadEvent(
    function() {
      dp.SyntaxHighlighter.ClipboardSwf = subtextBlogInfo.getScriptsVirtualRoot() + 'clipboard.swf';
      dp.SyntaxHighlighter.HighlightAll('code');
    });
&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;At this point you are ready to use the highlighter. Just to test, here is a little JavaScript:&lt;/p&gt;&lt;pre class="js" name="code"&gt;// Append a new element to an existing element.
// Build the attributes from the attrs object.
function appendElem(elem, value, newNodeType, attrs)
{
  var t = document.createTextNode(value);
  if (newNodeType) {
    if (attrs &amp;amp;&amp;amp; ("name" in attrs))
      newNodeType = "&amp;lt;" + newNodeType + " name='" + attrs["name"] + "'&amp;gt;";
    var n = document.createElement(newNodeType);
    if (attrs)
    {
      for (var attr in attrs)
      {
        var value = attrs[attr];
        if (attr == "class")
          n.className = value;
        else
          n.setAttribute(attr, value);
      }
    }
    n.appendChild(t);
    t = n;
  }
  elem.appendChild(t);
  return elem;
}

var elem = $("some-id"); // need prototype/jQuery...
appendElem(elem, "Testing", "textarea", {'class':'js', name:'code', cols:'40', rows:'5'});

&lt;/pre&gt;
&lt;p&gt;Hopefully this will still work with RSS feeds and readers, otherwise I may be going back to the old method pasting code. &lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c182bcfe-4302-4b40-bfa3-450100fa4ea8" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/Subtext" rel="tag"&gt;Subtext&lt;/a&gt;&lt;/div&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/48.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2007/11/16/using-dpsyntaxhighlighter-in-subtext.aspx</guid>
            <pubDate>Fri, 16 Nov 2007 18:00:00 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/48.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2007/11/16/using-dpsyntaxhighlighter-in-subtext.aspx#feedback</comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/48.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/48.aspx</trackback:ping>
        </item>
        <item>
            <title>Death of single-threaded development?</title>
            <link>http://nimblecoder.com/blog/archive/2007/06/08/Death-of-single-threaded-development.aspx</link>
            <description>&lt;p&gt;I was reading my email when I came across this blog about the &lt;a href="http://blogs.zdnet.com/Ou/?p=519"&gt;death of single-threaded development&lt;/a&gt;. Now I've written many multi-threaded applications in C++ for applications, communications, and graphical displays, but I don't see the death of single-threaded development any time soon. I even wrote a paper while I was at university about how multi-threaded programming should be introduced in the curriculum much earlier. At the very least, the multi-threaded thought process should be taught but I don't see that happening.&lt;/p&gt; &lt;p&gt;Samples are usually distributed as single-threaded applications because they are easier to understand. Unfortunately people replicate the same style and methodology in their own applications. Until sample applications are distributed as multi-threaded applications, I do not believe single-threaded application will die or even that multi-threaded applications will outnumber single-threaded applications.&lt;/p&gt; &lt;h3&gt;My First "Real" (as in Commercial) Multi-Threaded Experience&lt;/h3&gt; &lt;p&gt;Personally, I'd love for more people to use multi-threading in applications. Unfortunately there is a significant learning curve where you progress from novice to expert. I remember one of my first multi-threaded applications involved reading communications data from a device asynchronously as the display updated the values. During QA, a bug was found if you clicked this dialog and pressed that button in just the right (or wrong) sequence you could crash the application. It turned out to be an issue where I forgot to suspend the communications thread before changing some key values. Actually, it wouldn't have crashed if there had been a semaphore in the communications thread to protect the resizing of an array.&lt;/p&gt; &lt;h3&gt;The Classic Case of Debugging Multi-Threaded Applications&lt;/h3&gt; &lt;p&gt;Another multi-threaded issue I had was a communications driver that has to run 24x7 on an embedded controller. There were four-&lt;em&gt;plus&lt;/em&gt; threads: one for the application, one to monitor and handle configuration changes, one for the TCP/IP source data, and one for each of the configured serial ports. The source data thread read data from the host and then allow the serial ports to read the data. During the update of the source data, I protected the data with a class modeled after the Delphi &lt;em&gt;TMultiReadExclusiveWriteSynchronizer&lt;/em&gt;. The application would mysteriously lock up after about 7 days and it was a particularly stubborn. Debugging crashes that occur only every 7 days takes a little while to find and fix. I suspected it was an issue with my scheduler (the component that controlled how quickly the threads execute or resume after completing an iteration). There was an issue with the scheduler early in the development where the tick counter could roll over (a &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/gettickcount.asp"&gt;DWORD holding milliseconds&lt;/a&gt; can count up to 49.7 days), but I knew that could be an issue from the beginning and fixed that quickly. After a good deal of debugging, I found the issue was with my &lt;em&gt;TMultiReadExclusiveWriteSynchronizer&lt;/em&gt; class. I wrote a stress test application which hammered the synchronizer and sure enough found the problem. The application is still in production and running in many different plants around the US.&lt;/p&gt; &lt;h3&gt;The Purpose or Need of Multi-Threading&lt;/h3&gt; &lt;p&gt;In the case of the &lt;a href="http://blogs.zdnet.com/Ou/?p=519"&gt;blog article&lt;/a&gt; mentioned at the beginning of this post, the author is promoting multi-threading for graphic and game algorithms but I believe it is broader than just graphic algorithms. I get frustrated when Outlook doesn't respond when it is downloading messages. Programming multi-threaded applications makes you a better programmer and a better debugger -- that is if you are successful at it. Some programmers are just not cut out for multi-threading applications.&lt;/p&gt; &lt;p&gt;Many web applications are moving to AJAX to provide a more seemless experience without a bunch of page loads. Unfortunately, some tasks still take a long time and should be handled differently. I modified a JobHandler (based on a &lt;a href="http://www.devx.com/asp/Article/29617"&gt;DevX article&lt;/a&gt;) to support long-running tasks (BizTalk orchestrations, web services, communications, etc.). I added an Abort function, a watchdog timer, and general information like start and finish time, Session ID, and user name. In web-based applications, usually you must poll the JobHandler to see if it is complete. In OS-based applications, you can use a notifier or callback function to avoid polling.&lt;/p&gt; &lt;p&gt;There are typically two reasons for multi-threading: to complete a task quicker and to provide a seemless response. The first reason is most compelling due to the enormous performance gains that can be achevied. It is also the more difficult case to design more since you have to divide the tasks or calculations across multiple threads. The second case usually doesn't increase performance significantly, but the user appreciates the application more when it isn't frozen and not updating. At least in this case, you can monitor the thread, provide feedback, and attempt to abort it if necessary.&lt;/p&gt; &lt;h3&gt;Common Issues with Multi-Threading&lt;/h3&gt; &lt;ol&gt; &lt;li&gt;Deadlocks -- classic issue, but also includes handling "hung" threads and using watchdog timers&lt;/li&gt; &lt;li&gt;Scheduling threads -- figuring out how to run the threads quickly or pause the threads without overloading the system&lt;/li&gt; &lt;li&gt;Notifications -- notifying the application or external systems about status or progress&lt;/li&gt;&lt;/ol&gt; &lt;h3&gt;Conclusion&lt;/h3&gt; &lt;p&gt;Multi-theading is broader than just game and graphics programming, although the need for multi-threading in those areas is significant and absolute. Multi-threading increases your ability and experience, although you must expect challenges along the way.&lt;/p&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/28.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2007/06/08/Death-of-single-threaded-development.aspx</guid>
            <pubDate>Fri, 08 Jun 2007 16:08:01 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/28.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2007/06/08/Death-of-single-threaded-development.aspx#feedback</comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/28.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/28.aspx</trackback:ping>
        </item>
        <item>
            <title>Subtext Configuration</title>
            <link>http://nimblecoder.com/blog/archive/2007/05/03/SubText-Configuration.aspx</link>
            <description>&lt;p&gt;I really like Subtext, but unfortunately I haven't had too much time to try to configure my blog. I've looked through the wiki, but haven't seen enough information to emulate the configuration of Subtext founder &lt;a href="http://haacked.com/"&gt;Phil Haack&lt;/a&gt;. For example, the FeedBurner plugin which lists the number of subscribers and links to get the RSS and even email feeds -- how exactly is that configured? I suppose I should RTFM but I'm having trouble finding it at the moment (not to mention I have &lt;strong&gt;way too much &lt;/strong&gt;to do right now with work!). It seems the &lt;a href="http://www.subtextproject.com/Home/Wiki/tabid/150/Default.aspx"&gt;Subtext Wiki&lt;/a&gt; is describing &lt;a href="http://www.subtextproject.com/DesktopDefault.aspx?tabid=150&amp;amp;pageID=4&amp;amp;pageName="&gt;plug-in features&lt;/a&gt; in Subtext 2.0 (I'm running 1.9.x currently -- 2.0 is not released yet) so that doesn't help.&lt;/p&gt; &lt;p&gt;Sooner or later I will install &lt;a href="http://www.php-compiler.net/doku.php"&gt;Phalanger&lt;/a&gt; and test out &lt;a href="http://wiki.splitbrain.org/wiki:dokuwiki"&gt;DokuWiki&lt;/a&gt;. I also want to install &lt;a href="http://umbraco.org/"&gt;umbraco&lt;/a&gt; and possibly &lt;a href="http://community.rainbowportal.net/"&gt;Rainbow portal&lt;/a&gt; while I'm at it. I'd love to have &lt;a href="http://www.gnu.org/software/mailman/"&gt;GNU Mailman&lt;/a&gt; installed to manage mailing lists, but there are too many issues related its dependence on UNIX-style usernames and groups and I would probably need to user &lt;a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython"&gt;IronPython&lt;/a&gt; for the &lt;a href="http://python.org/"&gt;Python&lt;/a&gt; functionality. I guess it is just too much work right now, especially as I am utterly swamped at work. Unfortunately at work I am stuck working on a design portion of a project and I don't even get to do "real" programming that much -- sometimes you long to launch Visual Studio or work on source code. Oh well, hopefully this phase will end soon.&lt;/p&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/21.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2007/05/03/SubText-Configuration.aspx</guid>
            <pubDate>Thu, 03 May 2007 14:32:25 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/21.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2007/05/03/SubText-Configuration.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/21.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/21.aspx</trackback:ping>
        </item>
        <item>
            <title>Disabling Fields on Submit</title>
            <link>http://nimblecoder.com/blog/archive/2007/05/01/Disabling-Fields-on-Submit.aspx</link>
            <description>&lt;p&gt;A while back I needed to disable fields on a web page during submit and I found a utility written by Nancy Michell for &lt;a href="http://msdn.microsoft.com/msdnmag/issues/05/07/WebQA/default.aspx"&gt;MSDN Magazine&lt;/a&gt;. The utility covered the basic cases, but I found that I needed to use it for AJAX style calls as well as standard submits. So I modified the code to include an enable function as well. Finally I added exception handling around the disable and enable code to avoid pesky Javascript errors. The only thing I might change is to capture an array of the controls that were successfully disabled and then process only those controls on enable.&lt;/p&gt; &lt;p&gt;To use the disable utility, do the following:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// Method 1: Using the param string[] for controls&lt;/span&gt;
DisableHelper.DisableCtrlOnSubmit(&lt;span class="kwrd"&gt;this&lt;/span&gt;,
    &lt;span class="str"&gt;"ServerForm.btnCancel"&lt;/span&gt;,
    &lt;span class="str"&gt;"ServerForm.btnSave"&lt;/span&gt;);

&lt;span class="rem"&gt;// Method 2: Using the ArrayList of controls&lt;/span&gt;
aryDisableControls = &lt;span class="kwrd"&gt;new&lt;/span&gt; ArrayList();
aryDisableControls.Add(&lt;span class="str"&gt;"ConfigLoopForm.btnCancel"&lt;/span&gt;);
aryDisableControls.Add(&lt;span class="str"&gt;"ConfigLoopForm.btnSave"&lt;/span&gt;);
DisableHelper.DisableCtrlOnSubmit(&lt;span class="kwrd"&gt;this&lt;/span&gt;, aryDisableControls);
&lt;/pre&gt;
&lt;p&gt;Here is the utility source:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Utility.Web.UI
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; DisableHelper
    {
        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// Adds client-side javascript code to disable controls on a submit.&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;param name="Page"&amp;gt;Reference to the current page&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;param name="strControls"&amp;gt;String array of client-side control names.&amp;lt;/param&amp;gt;&lt;/span&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; DisableCtrlOnSubmit(
            System.Web.UI.Page Page, 
            &lt;span class="kwrd"&gt;params&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;[] strControls)
        {
            StringBuilder sbJS = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder(200);
            sbJS.Append(&lt;span class="str"&gt;@"
&amp;lt;script language="&lt;/span&gt;&lt;span class="str"&gt;"javascript"&lt;/span&gt;&lt;span class="str"&gt;"&amp;gt;
function MSDisable() {
    try {
        if (Page_IsValid==false) return;
        window.setTimeout('MSDisableCtrls(true)',0);
    } catch (e) {
        window.setTimeout('MSDisableCtrls(true)',0);
    }
}

function MSEnable() {
    try {
        window.setTimeout('MSDisableCtrls(false)',0);
    } catch (e) {
        window.setTimeout('MSDisableCtrls(false)',0);
    }
}
"&lt;/span&gt;
                );

            sbJS.Append(&lt;span class="str"&gt;@"
function MSDisableCtrls(value) {
"&lt;/span&gt;
                );

            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt; strControl &lt;span class="kwrd"&gt;in&lt;/span&gt; strControls)
            {
                sbJS.Append(&lt;span class="str"&gt;"\ttry { "&lt;/span&gt;);
                sbJS.Append(strControl);
                sbJS.Append(&lt;span class="str"&gt;".disabled = value;"&lt;/span&gt;);
                sbJS.Append(&lt;span class="str"&gt;" } catch (e) {}\n"&lt;/span&gt;);
            }

            sbJS.Append(&lt;span class="str"&gt;@"
}
&amp;lt;/script&amp;gt;
"&lt;/span&gt;
                );

            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!Page.IsClientScriptBlockRegistered(&lt;span class="str"&gt;"MSDisableImpl"&lt;/span&gt;))
            {
                Page.RegisterClientScriptBlock(
                    &lt;span class="str"&gt;"MSDisableImpl"&lt;/span&gt;, 
                    sbJS.ToString());
            }

            Page.RegisterOnSubmitStatement(&lt;span class="str"&gt;"MSDisable"&lt;/span&gt;, &lt;span class="str"&gt;"MSDisable(false);"&lt;/span&gt;);
        }

        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// Adds client-side javascript code to disable controls on a submit.&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;param name="Page"&amp;gt;Reference to the current page&amp;lt;/param&amp;gt;&lt;/span&gt;
        &lt;span class="rem"&gt;/// &amp;lt;param name="aryClientControlNames"&amp;gt;ArrayList with the client-side control names&amp;lt;/param&amp;gt;&lt;/span&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; DisableCtrlOnSubmit(
            System.Web.UI.Page Page, 
            ArrayList aryClientControlNames)
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (aryClientControlNames != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
            {
                &lt;span class="kwrd"&gt;string&lt;/span&gt;[] strControls = (&lt;span class="kwrd"&gt;string&lt;/span&gt;[]) aryClientControlNames.ToArray(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;));
                DisableCtrlOnSubmit(Page, strControls);
            }
        }

        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DiableCtrlOnSubmit(
            System.Web.UI.Page Page, 
            ArrayList aryClientControlNames)
        {
            DisableCtrlOnSubmit(Page, aryClientControlNames);
        }
    }
}
&lt;/pre&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/20.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2007/05/01/Disabling-Fields-on-Submit.aspx</guid>
            <pubDate>Wed, 02 May 2007 03:31:24 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/20.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2007/05/01/Disabling-Fields-on-Submit.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/20.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/20.aspx</trackback:ping>
        </item>
        <item>
            <title>Exceptions and the Event Log</title>
            <link>http://nimblecoder.com/blog/archive/2007/02/26/Exceptions-and-the-Event-Log.aspx</link>
            <description>&lt;p&gt;I was just reading an article on Builder.com about &lt;a href="http://builder.com.com/5100-6370_14-6161320.html"&gt;exception handling&lt;/a&gt; and it reminded me of some of my pet peeves regarding exception handling.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;span style="font-weight: bold"&gt;Don't assume you have permissions to write to the Event Log!&lt;/span&gt; - Many people add code to log exceptions to the Event Log however they do not add any exception handling in case it fails. This is especially true for ASP.NET as many corporate networks are severely restricting permissions. It is possible for the &lt;span style="font-family: courier new"&gt;System.Diagnostics.EventLog.WriteEntry()&lt;/span&gt; to throw exceptions! The exception for permissions issue is &lt;span style="font-family: courier new"&gt;System.Security.SecurityException&lt;/span&gt;.  &lt;ul&gt; &lt;li&gt;Best practice is to use a wrapper function write the information. This also makes it possible to abstract which event log to write to instead of hard-coding to System.Diagnostics.EventLog. For more information search the net for classes such as LogException or use the Microsoft Patterns &amp;amp; Practices Exception Handling Block.&lt;br /&gt; &lt;/li&gt;&lt;li&gt;Use regedit to give permissions to write to the Event Log. Open regedit to &lt;span style="font-family: courier new"&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Security&lt;/span&gt; and right-click on the node and select Permissions. For ASP.NET add the ASPNET user if you are using Win2k3 or 'NETWORK SERVICE' for WinXP. See this &lt;a href="http://geekswithblogs.net/timh/archive/2005/10/05/56029.aspx"&gt;blog entry&lt;/a&gt; for more information. &lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold"&gt;Don't throw away the handled exception!&lt;/span&gt; - If you "re-throw" the exception or derive another exception type, do not discard the current exception information. It makes debugging applications so much more difficult without that information. Do not display the gory details to the end user, but at least provide a means to debug the application. &lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// Example poor exception handling from a DAL.
// Not my code, but just an example. Comments reflect code deficiencies.
// DO NOT USE CODE LIKE THIS!!!!&lt;/span&gt;
&lt;span class="kwrd"&gt;try&lt;/span&gt;
{
    SqlCommand cmd = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlCommand();
    cmd.Connection = SqlConn;
    cmd.CommandText = &lt;span class="str"&gt;"..."&lt;/span&gt;;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.ExecuteNonQuery();
}
&lt;span class="kwrd"&gt;catch&lt;/span&gt;(Exception ee)
{
    SqlConn.Close();
    &lt;span class="rem"&gt;// Notice only the ee.Message is used
    // so extended details (StackTrace, etc.) are lost
    // the catch should have specified DBException first&lt;/span&gt;
    &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; DBException(ee.Message);
}
&lt;span class="rem"&gt;// DO NOT USE CODE LIKE THIS!!!!&lt;/span&gt;
&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Updated: 2007-05-04 09:05:48 -05:00 Added comments to bad exception handling example.&lt;/p&gt;&lt;img src="http://nimblecoder.com/blog/aggbug/12.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2007/02/26/Exceptions-and-the-Event-Log.aspx</guid>
            <pubDate>Mon, 26 Feb 2007 21:00:57 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/12.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2007/02/26/Exceptions-and-the-Event-Log.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/12.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/12.aspx</trackback:ping>
        </item>
        <item>
            <title>Time Zone Adjustment in Datasets</title>
            <link>http://nimblecoder.com/blog/archive/2007/02/04/Time-Zone-Adjustment-in-DatasetsAgain.aspx</link>
            <description>I decided to publish a short article about time zone adjustment. While it uses a Microsoft KB article as the basis for the algorithm, the interesting portion of the code actually has to do with setting the client time zone and cookies. See the article &lt;a href="http://nimblecoder.com/blog/archive/2007/02/04/Time-Zone-Adjustment-in-Datasets.aspx"&gt;here&lt;/a&gt;.&lt;img src="http://nimblecoder.com/blog/aggbug/9.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Ryan Van Slooten</dc:creator>
            <guid>http://nimblecoder.com/blog/archive/2007/02/04/Time-Zone-Adjustment-in-DatasetsAgain.aspx</guid>
            <pubDate>Sun, 04 Feb 2007 06:41:21 GMT</pubDate>
            <wfw:comment>http://nimblecoder.com/blog/comments/9.aspx</wfw:comment>
            <comments>http://nimblecoder.com/blog/archive/2007/02/04/Time-Zone-Adjustment-in-DatasetsAgain.aspx#feedback</comments>
            <wfw:commentRss>http://nimblecoder.com/blog/comments/commentRss/9.aspx</wfw:commentRss>
            <trackback:ping>http://nimblecoder.com/blog/services/trackbacks/9.aspx</trackback:ping>
        </item>
    </channel>
</rss>