<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-32465434</id><updated>2011-09-25T21:02:09.779-05:00</updated><category term='roles'/><category term='javascript'/><category term='agile'/><category term='gotcha'/><category term='windows authentication'/><category term='validation'/><category term='intranet applications'/><title type='text'>Code Luck</title><subtitle type='html'>Like a pot luck, except you bring code. So what have YOU brought today?</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Alexis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>36</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-32465434.post-5461291267473699507</id><published>2007-08-09T22:02:00.001-05:00</published><updated>2007-08-19T19:59:47.657-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='agile'/><category scheme='http://www.blogger.com/atom/ns#' term='validation'/><title type='text'>Validation and Agile Principles</title><content type='html'>I had earlier posted a javascript version of the&lt;br /&gt;trim method, since a prebuilt one is not available.&lt;br /&gt;But while watching Peter blum's DNRTV episode,&lt;br /&gt;he showed that a prebuilt Trim method is available only when the method is used as (set as)a client side validator of the customvalidato control.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;txtVal .value = ValidatorTrim(txtVal.value);&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;To hook up an additional control to the&lt;br /&gt;ControlTovalidate use:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;ValidatorHookupControlID("secondcontrolClientID",&lt;br /&gt;"clientIDOfTheCustomValidator");&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;All credit goes to Peter Blum and DnrTV, blogging only for future reference purposes.&lt;br /&gt;&lt;br /&gt;Also, ValidatorEnable(clientID) to enable/disable validators on the client side.&lt;br /&gt;&lt;br /&gt;What I find funny is that these functions don't find a mention in the Professional series of&lt;br /&gt;asp.net not have I come across these in forums/blogs I browsed up till now. I wonder how one is supposed to find out helpful things like these.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Also here is a list of Agile principles mentioned by Venkat on DrntV episode on agile design&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;DRY - Don't repeat yourself&lt;br /&gt;YAGNI - You aren't gonna need it&lt;br /&gt;OCP - Open Closed Principle&lt;br /&gt;LSP - Liskov's substitution principle&lt;br /&gt;DIP - Dependency inversion principle ( used in creating enumerators for various classes such as ArrayList, queue...)&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Will expand on these as time goes.&lt;br /&gt;&lt;br /&gt;Amazing shows, hail dnrtv.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-5461291267473699507?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/5461291267473699507/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=5461291267473699507' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/5461291267473699507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/5461291267473699507'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/08/validation-and-agile-principles.html' title='Validation and Agile Principles'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-8979128961403123933</id><published>2007-07-16T17:17:00.000-05:00</published><updated>2007-08-04T10:48:39.790-05:00</updated><title type='text'>Using HTTP Handler for dynamic image generation</title><content type='html'>I was working on a project recently that needed bar charts to be created dynamically. We were not using sql reporting for this project. The bar chart needed to be changed/ updated based on certain criteria chosen from date controls, dropdowns etc.&lt;br /&gt;&lt;br /&gt;One of the ways to achieve this is to create the image server side, store it on the disk on server and set the ImageUrl property of the image on the page to that saved image and send it to the browser.&lt;br /&gt;This approach works but leads to addditional maintenance tasks, such as cleaning up old images, managing disk space etc...&lt;br /&gt;&lt;br /&gt;One of the short comings of the asp.net image control Vs the image control in WinForms is that it lacks a property called "Bitmap" which allows you to assign a dynamically generated bitmap to the image control.&lt;br /&gt;&lt;br /&gt;The only property exposed is the "ImageUrl".&lt;br /&gt;&lt;br /&gt;I heard about http handlers and modules in podcats from polymorphic podcasts where Miguel Castro was explaining the use of HttpHandler to process certain file types.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Here is a formal definition from msdn : &lt;em&gt;"An ASP.NET HTTP handler is the process (frequently referred to as the "endpoint") that runs in response to a request made to an ASP.NET Web application. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page via the page handler.&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;em&gt;HTTP handlers have access to the application context, including the requesting user's identity (if known), application state, and session information. When an HTTP handler is requested, ASP.NET calls the &lt;/em&gt;&lt;a onclick="javascript:Track('ctl00_LibFrame_ctl07ctl00_LibFrame_ctl08',this);" href="http://msdn2.microsoft.com/en-us/library/system.web.ihttphandler.processrequest.aspx"&gt;&lt;em&gt;ProcessRequest&lt;/em&gt;&lt;/a&gt;&lt;em&gt; method on the appropriate handler. The handler's ProcessRequest method creates a response, which is sent back to the requesting browser. As with any page request, the response goes through any HTTP modules that have subscribed to events that occur after the handler has run."&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Scott Hanselman says : &lt;em&gt;"Remember, an HttpHandler is the kind of thing you want to use when an HttpRequest is going to return a file or image to the browser. Basically anything other than a standard page. True, you could use a page, remove all the HTML from the ASPX part, and return stuff in Page_Load, but that's not really what pages are for, right? Also, Pages are themselves an HttpHandler (returned by &lt;/em&gt;&lt;a href="http://aspnet.4guysfromrolla.com/articles/011404-1.aspx"&gt;&lt;em&gt;PageHandlerFactory&lt;/em&gt;&lt;/a&gt;&lt;em&gt;) so why not write your own HttpHandler?"&lt;/em&gt;&lt;/p&gt;&lt;p&gt;The processRequest for our bar chart image handler looks like this.&lt;/p&gt;&lt;span style="font-family:verdana;"&gt;&lt;blockquote&gt;&lt;span style="font-family:verdana;"&gt;public void ProcessRequest (HttpContext context)&lt;br /&gt;{&lt;br /&gt;mPresenter = new ChartsPresenter(this);&lt;br /&gt;ProcessQueryString(context);&lt;br /&gt;DrawBarChart(context);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;When the bitmap generation is completed, we output the bitmap in this fashion &lt;span style="font-family:verdana;"&gt;&lt;/p&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:verdana;"&gt;context.Response.ContentType = "image/gif";&lt;br /&gt;bitmap.Save(context.Response.OutputStream,&lt;br /&gt;System.Drawing.Imaging.ImageFormat.Gif);&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;p&gt;We associate the ImageUrl property of the image to the http handler created to output the bar chart. Here is an &lt;a href="http://haacked.com/archive/2005/03/17/AnAbstractBoilerplateHttpHandler.aspx"&gt;abstract base class &lt;/a&gt;for creating http handlers that return proper error codes in case of problems. Phil Haack wrote it. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-8979128961403123933?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/8979128961403123933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=8979128961403123933' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/8979128961403123933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/8979128961403123933'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/07/using-http-handler-for-dynamic-image.html' title='Using HTTP Handler for dynamic image generation'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-8489008148151242648</id><published>2007-07-11T15:15:00.000-05:00</published><updated>2007-07-12T11:46:37.047-05:00</updated><title type='text'>Databind dropdowns to Enums</title><content type='html'>&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20     \cf2 protected\cf0  \cf2 void\cf0  Page_Load(\cf2 object\cf0  sender, \cf10 EventArgs\cf0  e)\par ??    \{\par ??        \cf2 if\cf0  (!IsPostBack)\par ??        \{\par ??            \cf11 //if (GetTotalExceptionsByVendor != null)\par ??\cf0             \cf11 //\{\par ??\cf0             \cf11 //    GetTotalExceptionsByVendor(this, EventArgs.Empty);\par ??\cf0             \cf11 //\}\par ??\cf0             \cf11 //gvVendorBarChart.DataBind();\par ??\cf0             ddlReportTypes.DataSource = \cf10 Enum\cf0 .GetNames(\cf2 typeof\cf0 (\cf10 ReportTypes\cf0 ));\par ??            \cf11 //imgVendorBarChart.ImageUrl = "~/bargraph.aspx";\par ??\cf0         \}\par ??    \}\par ??    \cf2 protected\cf0  \cf2 void\cf0  ddlReportTypes_SelectedIndexChanged(\cf2 object\cf0  sender, \cf10 EventArgs\cf0  e)\par ??    \{\par ??        \cf10 ReportTypes\cf0  rType =\par ??            \cf10 Enum\cf0 .Parse(\cf2 typeof\cf0 (\cf10 ReportTypes\cf0 ), ddlReportTypes.SelectedValue);\par ??        \cf2 switch\cf0  (rType)\par ??        \{\par ??            \cf2 case\cf0  \cf10 ReportTypes\cf0 .ByVendor:\par ??                ddlReportTypes.Enabled = \cf2 false\cf0 ;\par ??                \cf2 break\cf0 ;\par ??            \cf2 case\cf0  \cf10 ReportTypes\cf0 .ByCategory:                \par ??                ddlReportTypes.DataSource = \cf10 RcsExceptionType\cf0 .GetCategories();\par ??                ddlReportTypes.DataBind();\par ??                \cf2 break\cf0 ;\par ??            \cf2 case\cf0  \cf10 ReportTypes\cf0 .ByType:\par ??                \cf2 break\cf0 ;\par ??        \}\par ??    \}} --&gt; &lt;div    style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;pre style="margin: 0px;"&gt;Here is how you do it.&lt;br /&gt;&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20     \cf2 private\cf0  \cf2 enum\cf0  \cf10 ReportTypes\cf0  : \cf2 int\par ??\cf0     \{\par ??        ByVendor = 1,\par ??        ByCategory = 2,\par ??        ByType = 3\par ??    \}} --&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div face="Courier New" size="10pt" color="black" style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   20&lt;/span&gt;     &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;enum&lt;/span&gt; &lt;span style="color:teal;"&gt;ReportTypes&lt;/span&gt; : &lt;span style="color:blue;"&gt;int&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   21&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   22&lt;/span&gt;         ByVendor = 1,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   23&lt;/span&gt;         ByCategory = 2,&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   24&lt;/span&gt;         ByType = 3&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   25&lt;/span&gt;     }&lt;br /&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   35&lt;/span&gt;     &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; Page_Load(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:teal;"&gt;EventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;/div&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   36&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   37&lt;/span&gt;         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (!IsPostBack)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   38&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   44&lt;/span&gt;             ddlReportTypes.DataSource = &lt;span style="color:teal;"&gt;Enum&lt;/span&gt;.GetNames(&lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:teal;"&gt;ReportTypes&lt;/span&gt;));&lt;br /&gt;&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20             ddlReportTypes.DataBind();\par ??} --&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   45&lt;/span&gt;             ddlReportTypes.DataBind();&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   46&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   47&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   48&lt;/span&gt;     &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; ddlReportTypes_SelectedIndexChanged(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;span style="color:teal;"&gt;EventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   49&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   50&lt;/span&gt;         &lt;span style="color:teal;"&gt;ReportTypes&lt;/span&gt; rType =&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   51&lt;/span&gt;             (&lt;span style="color:teal;"&gt;ReportTypes&lt;/span&gt;)&lt;span style="color:teal;"&gt;Enum&lt;/span&gt;.Parse(&lt;span style="color:blue;"&gt;typeof&lt;/span&gt;(&lt;span style="color:teal;"&gt;ReportTypes&lt;/span&gt;), ddlReportTypes.SelectedValue);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   52&lt;/span&gt;         &lt;span style="color:blue;"&gt;switch&lt;/span&gt; (rType)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   53&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   54&lt;/span&gt;             &lt;span style="color:blue;"&gt;case&lt;/span&gt; &lt;span style="color:teal;"&gt;ReportTypes&lt;/span&gt;.ByVendor:&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   56&lt;/span&gt;                 &lt;span style="color:blue;"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   57&lt;/span&gt;             &lt;span style="color:blue;"&gt;case&lt;/span&gt; &lt;span style="color:teal;"&gt;ReportTypes&lt;/span&gt;.ByCategory:                &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   60&lt;/span&gt;                 &lt;span style="color:blue;"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   61&lt;/span&gt;             &lt;span style="color:blue;"&gt;case&lt;/span&gt; &lt;span style="color:teal;"&gt;ReportTypes&lt;/span&gt;.ByType:&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   62&lt;/span&gt;                 &lt;span style="color:blue;"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   63&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   64&lt;/span&gt;     }&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-8489008148151242648?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/8489008148151242648/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=8489008148151242648' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/8489008148151242648'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/8489008148151242648'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/07/databinf-dropdowns-to-enums.html' title='Databind dropdowns to Enums'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-8918259031103590079</id><published>2007-07-04T14:21:00.000-05:00</published><updated>2007-07-05T07:19:45.262-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gotcha'/><title type='text'>Web.Config Gotcha</title><content type='html'>&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf2 &lt;\cf13 configuration\cf2  \cf6 xmlns\cf2 =\cf0 "\cf2 http://schemas.microsoft.com/.NetConfiguration/v2.0\cf0 "\cf2 &gt;} --&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family: arial;"&gt;Midway into the project we sometimes realize that the intellisense in the web.config has vanished all of a sudden. The culprit being this line.&lt;/span&gt;&lt;/span&gt; &lt;div    style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;&lt;br /&gt;  10&lt;/span&gt; &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;configuration&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;xmlns&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;http://schemas.microsoft.com/.NetConfiguration/v2.0&lt;/span&gt;"&lt;span style="color:blue;"&gt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family: arial;"&gt;Removing the xmlns attribute from the configuration tag brings back the intellisense for the Web.Config.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  10&lt;/span&gt; &lt;span style="color:blue;"&gt;&lt;&lt;/span&gt;&lt;span style="color:maroon;"&gt;configuration&lt;/span&gt;&lt;span style="color:blue;"&gt;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family: arial;"&gt;I saw this on one of the dnrtv shows, so credit goes to the author Miguel Castro.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color:blue;"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-family: arial;"&gt;&lt;span style="font-family: arial;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color:blue;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-8918259031103590079?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/8918259031103590079/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=8918259031103590079' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/8918259031103590079'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/8918259031103590079'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/07/webconfig-gotcha.html' title='Web.Config Gotcha'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-1543746307862270554</id><published>2007-07-03T16:14:00.000-05:00</published><updated>2007-08-04T10:43:31.136-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='windows authentication'/><category scheme='http://www.blogger.com/atom/ns#' term='roles'/><category scheme='http://www.blogger.com/atom/ns#' term='intranet applications'/><title type='text'>Setting up Windows Authentication for Intranet Websites</title><content type='html'>&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;" align="justify"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;&lt;/span&gt;&lt;span style="font-family:times new roman;"&gt; &lt;span style="color:#000000;"&gt;Recently I was put on a project that needed to harness the built in windows security &lt;/span&gt;&lt;span style="color:#000000;"&gt;for user authentication. Idea was to allow access only tousers of subscribed to &lt;/span&gt;&lt;span style="color:#000000;"&gt;certain groups. Once authenticated, based on the group the user is subscribed to, &lt;/span&gt;&lt;span style="color:#000000;"&gt;I needed to perform custom actions. &lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p align="justify"&gt;&lt;span style="font-family:times new roman;"&gt;The configuration started with the Web.Config. I added the authentication andauthorization sections to the Web.Config, specifying the authentication type and the groups authorized to access the site. &lt;/span&gt;&lt;/p&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;" align="justify"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;We deny access to anonymous users. Also, with the "Impersonate clause" we tell ASP.NET&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;" align="justify"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;to run using the permission/priveledges of the authenticated user&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;" align="justify"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;instead of the default asp_net user.&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;   37&lt;/span&gt; &lt;span style="color:blue;"&gt;        &lt;/span&gt;&lt;span style="color:maroon;"&gt;authentication&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;mode&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;Windows"&lt;/span&gt;&lt;span style="color:blue;"&gt;        &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;   38&lt;/span&gt; &lt;span style="color:blue;"&gt;        &lt;/span&gt;&lt;span style="color:maroon;"&gt;authorization&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;   39&lt;/span&gt; &lt;span style="color:blue;"&gt;            &lt;/span&gt;&lt;span style="color:maroon;"&gt;allow&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;roles&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;MSDomain\Buyers,&lt;/span&gt;&lt;span style="color:blue;"&gt;MSDomain&lt;/span&gt;&lt;span style="color:blue;"&gt;\Clerks,&lt;/span&gt;&lt;span style="color:blue;"&gt;MSDomain&lt;/span&gt;&lt;span style="color:blue;"&gt;\Receivers&lt;/span&gt;"&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;   40&lt;/span&gt; &lt;span style="color:blue;"&gt;            &lt;/span&gt;&lt;span style="color:maroon;"&gt;deny&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;users&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;*&lt;/span&gt;"&lt;span style="color:blue;"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;   41&lt;/span&gt; &lt;/span&gt;&lt;span style="color:blue;"&gt;&lt;span style="font-family:times new roman;"&gt;        &lt;/&lt;&gt;&lt;span style="COLOR: maroon"&gt;authorization&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;   42&lt;/span&gt; &lt;span style="color:blue;"&gt;        &lt;/span&gt;&lt;span style="color:maroon;"&gt;identity&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;impersonate&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;"&lt;span style="color:blue;"&gt;true&lt;/span&gt;"&lt;span style="color:blue;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="font-size:100%;color:#000000;"&gt;In order to be able to find out whether a user belongs to a particular group &lt;/span&gt;&lt;span style="font-size:100%;color:#000000;"&gt;and to get a list of groups a user is subscribed to, we needed to&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;specify a "roleManager" config section and set the default provider to "AspNetWindowsTokenRoleProvider". Until this is done, the any code written&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="color:blue;"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;to check whether the user is part of a group/list of groups will not work.&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="color:blue;"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;"Role Manager" helps us manage groups(roles) and perform group based authorization&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="color:#000000;"&gt;in the applicaion. We need the role manager to help us identify the &lt;/span&gt;&lt;span style="color:#000000;"&gt;groups of which the authenticated user is a part of and perform actions like wise.&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="color:#000000;"&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms998314.aspx"&gt;&lt;span style="font-family:times new roman;"&gt;Msdn article about role management&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:times new roman;"&gt; says:&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;&lt;em&gt;"The main benefits of using role manager are that it allows you to &lt;/em&gt;&lt;/span&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;&lt;em&gt;look up users' roles without writing and maintaining code. Additionally, the &lt;/em&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;&lt;em&gt;role providers offer a consistent way for you to check the role membership &lt;/em&gt;&lt;/span&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;&lt;em&gt;of your users, regardless of the underlying data store. Therefore, &lt;/em&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;&lt;em&gt;if your role store were to change tomorrow, you would only need to &lt;/em&gt;&lt;/span&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;&lt;em&gt;change the configuration settings to make your code work."&lt;/em&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;br /&gt; &lt;/pre&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt; roleManager enabled="true" defaultProvider="WindowsTokenRoleProvider" &gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;The default role providers are as follows:&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="color:#000000;"&gt;&lt;blockquote&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;1. SqlRoleProvider&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt; - role information kept in SQL Server&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;2. WindowsTokenRoleProvider&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt; - read-only provider that retrieves role information for a &lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;   Windows user account based on the account's Windows security &lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;   group membership&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;3. AuthorizationStoreRoleProvider&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt; - used if your application uses Authorization Manager (AzMan)&lt;/span&gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="color:#000000;"&gt;In my case, all I needed was to redirect user to corresponding portion &lt;/span&gt;&lt;span style="color:#000000;"&gt;of the site depending on their role, hence read-only role provider was&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;sufficient.&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;Msdn article says "The Windows security system acts as role store for this &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="color:#000000;"&gt;provider, so no additional configuration is required to set up the role store"&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;" align="justify"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt; &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="color:#000000;"&gt;Once the user is authenticated, we need to check if the user is &lt;/span&gt;&lt;span style="color:#000000;"&gt;part of a particular group, if yes, then perform the custom action.&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="color:#000000;"&gt;Below is the code required to validate whether a user is part of a &lt;/span&gt;&lt;span style="color:#000000;"&gt;inranet group.&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="color:#000000;"&gt;&lt;/span&gt;&lt;br /&gt; &lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  120&lt;/span&gt;         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (User.IsInRole   (&lt;span style="color:teal;"&gt;WindowsGroupSettings&lt;/span&gt;.SettingFor.Buyers))&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  121&lt;/span&gt;         {&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  122&lt;/span&gt;             &lt;span style="color:blue;"&gt;if&lt;/span&gt; (&lt;span style="color:blue;"&gt;this&lt;/span&gt;.LoadPricesForBuyer != &lt;span style="color:blue;"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  123&lt;/span&gt;             {&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  124&lt;/span&gt;                 _buyerName = User.Identity.Name;&lt;/pre&gt;&lt;/div&gt;&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  125&lt;/span&gt;                 LoadPricesForBuyer(&lt;span style="color:blue;"&gt;this&lt;/span&gt;, &lt;span style="color:teal;"&gt;EventArgs&lt;/span&gt;.Empty);&lt;/pre&gt;&lt;/div&gt;&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white 0% 50%; COLOR: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  126&lt;/span&gt;             }&lt;/pre&gt;&lt;/div&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  127&lt;/span&gt;         }&lt;/pre&gt;&lt;/div&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="color:#000000;"&gt;To get a list of groups a user is part of use the following code:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20         \cf2 if\cf0  (!IsPostBack)\par ??        \{\par ??            gvRoles.DataSource = \cf10 Roles\cf0 .GetRolesForUser(User.Identity.Name);\par ??            gvRoles.DataBind();\par ??            lblUserInRole.Text = \cf13 "User.IsInRole('RcsBuyers') = "\cf0  + User.IsInRole(\cf13 "RcsBuyers"\cf0 ).ToString();\par ??            \cf11 //gvShipments.DataSource = Shipments;\par ??\cf0             \cf11 //        DataSource='&lt;%# Shipments %&gt;'\par ??\cf0             gvShipments.DataSource = GetShipmentsByUserType();\par ??            gvShipments.DataBind();\par ??        \}\par ??} --&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial" color="black" size="10pt" face="Courier New"&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  140&lt;/span&gt;         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (!IsPostBack)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  141&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  142&lt;/span&gt;             gvRoles.DataSource = &lt;span style="color:teal;"&gt;Roles&lt;/span&gt;.GetRolesForUser(User.Identity.Name);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  143&lt;/span&gt;             gvRoles.DataBind();&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  149&lt;/span&gt;         }&lt;/pre&gt;&lt;/div&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:times new roman;color:#000000;"&gt;Notice that I have used the WebNavigator, MVP pattern in this project. :)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:Times New Roman;color:#000000;"&gt;I am having a torrid time fighting the fonts/html in post that contain code copied using copySourceAsHtml, &lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="font-family:Times New Roman;color:#000000;"&gt;especially code containing tags.&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-1543746307862270554?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/1543746307862270554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=1543746307862270554' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/1543746307862270554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/1543746307862270554'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/07/setting-up-windows-authentication-for.html' title='Setting up Windows Authentication for Intranet Websites'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-5289330175100045181</id><published>2007-06-28T12:13:00.001-05:00</published><updated>2007-06-28T22:01:34.751-05:00</updated><title type='text'>ASP.Net FormView Control.</title><content type='html'>&amp;t&lt;div&gt;I was posed with the problem of a showing a list of data, displaying the details of a particular enry in the list and letting the user edit/update the entry, all on one page. I have seen such an scenario implemented with gridview with an &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;"Edit"&lt;/span&gt; button as a column on the gridview and displaying the details on a modal popup. the modal popup would be either a &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;"showModalDialog&lt;/span&gt;" based window or an Telerik RadWindow.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;I wanted to specifically avoid having popups due to cross browser issues (did not have Telerik suite available for this project). To implement all of this functionality on a page I decided to user the Master-Detail mode with either the &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;GridView-DetailsView&lt;/span&gt; or the &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;GridView&lt;/span&gt;-&lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;FormView&lt;/span&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I srated off with a &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;DetailsView&lt;/span&gt; by using TemplateFields for editable fields. soon, I realized the I had no control over the layout of the &lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;DetailsView&lt;/span&gt; and since I wanted to keep evething in the 1024X768 boundry, I decided on using the &lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;FormView&lt;/span&gt;.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;FormView&lt;/span&gt; is very much like the &lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;DetailsView&lt;/span&gt;, it displays data item by item with paging support. What it offers you over the &lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;DetailsView&lt;/span&gt; is the ability to control the layout of the elements of the Detail and it also aleviates the need to implement an TemplateField for eahc and every field that needs to be edited. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;It basically has an &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;ItemTemplate&lt;/span&gt; &amp;amp; an&lt;span class="Apple-style-span"  style="font-family:courier new;"&gt; EditTemplate&lt;/span&gt;, the contents/layouts of which are totally in the developers control.&lt;/div&gt;&lt;div&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  319&lt;/span&gt;         asp:&lt;span style="color:teal;"&gt;FormView ID=&lt;span style="color:maroon;"&gt;"fvExceptionDetails"&lt;/span&gt; runat=&lt;span style="color:maroon;"&gt;"server"&lt;/span&gt;/asp:&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  320&lt;/span&gt;         AllowPaging=&lt;span style="color:maroon;"&gt;"true"&lt;/span&gt; DataKeyNames=&lt;span style="color:maroon;"&gt;"Oid"&lt;/span&gt; &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  321&lt;/span&gt;         OnModeChanging=&lt;span style="color:maroon;"&gt;"fvExceptionDetails_ModeChanging"&lt;/span&gt; &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  322&lt;/span&gt;         OnPageIndexChanging=&lt;span style="color:maroon;"&gt;"fvExceptionDetails_PageIndexChanging"&lt;/span&gt; &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  323&lt;/span&gt;         OnItemUpdating=&lt;span style="color:maroon;"&gt;"fvExceptionDetails_ItemUpdating"&lt;/span&gt;&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  324&lt;/span&gt;             ItemTemplate&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  325&lt;/span&gt;             /ItemTemplate&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  326&lt;/span&gt;             EditTemplate&lt;edititemtemplate&gt;&lt;/edititemtemplate&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  327&lt;/span&gt;             /EditTemplate&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  328&lt;/span&gt;         FormView&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Since I am well versed with the event model of the GridView, I felt &lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;FormView&lt;/span&gt; would be similar to use and implement. But it is a bit different than the GridView and here are the events that need to handled in order for the &lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;FormView&lt;/span&gt; to work.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;Each entry in the list displayed in the GridView was associated with zero or more detail entries that needed too be displayed in the &lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;FormView&lt;/span&gt;. Hence use of paging was obvious choice and had to have an handler in place for the &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;PageIndexChanging&lt;/span&gt; event. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20     \cf2 protected\cf0  \cf2 void\cf0  fvExceptionDetails_PageIndexChanging(\cf2 object\cf0  sender, \cf10 FormViewPageEventArgs\cf0  e)\par ??    \{\par ??        fvExceptionDetails.PageIndex = e.NewPageIndex;\par ??        DataBindExceptionDetails();\par ??    \}} --&gt; &lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20     \cf2 protected\cf0  \cf2 void\cf0  fvExceptionDetails_PageIndexChanging(\cf2 object\cf0  sender, \par ??        \cf10 FormViewPageEventArgs\cf0  e)\par ??    \{\par ??        fvExceptionDetails.PageIndex = e.NewPageIndex;\par ??        DataBindExceptionDetails();\par ??    \}} --&gt; &lt;div    style="background: white none repeat scroll 0% 50%;    -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  261&lt;/span&gt;     &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; fvExceptionDetails_PageIndexChanging(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  262&lt;/span&gt;         &lt;span style="color:teal;"&gt;FormViewPageEventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  263&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  264&lt;/span&gt;         fvExceptionDetails.PageIndex = e.NewPageIndex;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  265&lt;/span&gt;         DataBindExceptionDetails();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  266&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;The ItemTemplate had a LinkButton that had an &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;CommandName="Edit"&lt;/span&gt; that when pressed should transform the &lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;FormView&lt;/span&gt; in the "Edit" Mode. so had to handle the &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;ModeChanging&lt;/span&gt; event. Since I had did not want the user to move to anoher while editing, I disabled the Paging when in this mode. Also, I found that it was critical to &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;DataBind()&lt;/span&gt; again in this even handler.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;One thing to note would be that, in order to be able to access any of the elements inside the EditItemTemplate, the &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;FormView&lt;/span&gt; has to be in that mode before you try and find the control using &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;.FindControl("txtComment")&lt;/span&gt;. Hence the first statement in the &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;ModeChanging&lt;/span&gt; event handler is the the &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;.ChangeMode()&lt;/span&gt; method call.&lt;br /&gt;&lt;div    style="background: white none repeat scroll 0% 50%;    -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span class="Apple-style-span" style="color: rgb(43, 145, 175);"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  267&lt;/span&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;&lt;summary&gt;&lt;/summary&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  268&lt;/span&gt;     &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; event invoked only when mode changed through UI.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  269&lt;/span&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;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  270&lt;/span&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;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  271&lt;/span&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;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  272&lt;/span&gt;     &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; fvExceptionDetails_ModeChanging(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  273&lt;/span&gt;         &lt;span style="color:teal;"&gt;FormViewModeEventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  274&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  275&lt;/span&gt;         fvExceptionDetails.ChangeMode(e.NewMode);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  276&lt;/span&gt;         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (e.NewMode == &lt;span style="color:teal;"&gt;FormViewMode&lt;/span&gt;.Edit)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  277&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  278&lt;/span&gt;             fvExceptionDetails.AllowPaging = &lt;span style="color:blue;"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  279&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  280&lt;/span&gt;         &lt;span style="color:blue;"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  281&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  282&lt;/span&gt;             fvExceptionDetails.AllowPaging = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  283&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  284&lt;/span&gt;         &lt;span style="color:blue;"&gt;if&lt;/span&gt; (e.NewMode != &lt;span style="color:teal;"&gt;FormViewMode&lt;/span&gt;.Insert)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  285&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  286&lt;/span&gt;             DataBindExceptionDetails();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  287&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  288&lt;/span&gt;         SetJSonclickAttribute();&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  289&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;The &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;EditTemplate&lt;/span&gt; contained 2 buttons at the end, namely the "Update" and "Cancel". In order to implement the "Update" functionality I had to have implement the &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;ItemUpdating&lt;/span&gt; event handler. &lt;div&gt;&lt;br /&gt;&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20     \cf2 protected\cf0  \cf2 void\cf0  fvExceptionDetails_ItemUpdating(\cf2 object\cf0  sender, \cf10 FormViewUpdateEventArgs\cf0  e)\par ??    \{\par ??        \cf11 //perform update logic here.\par ??\cf0         fvExceptionDetails.ChangeMode(\cf10 FormViewMode\cf0 .ReadOnly);\par ??        fvExceptionDetails.AllowPaging = \cf2 true\cf0 ;\par ??        DataBindExceptionDetails();\par ??    \}} --&gt; &lt;div face="Courier New" size="10pt" color="black" style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt; &lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20     \cf2 protected\cf0  \cf2 void\cf0  fvExceptionDetails_ItemUpdating(\cf2 object\cf0  sender, \par ??        \cf10 FormViewUpdateEventArgs\cf0  e)\par ??    \{\par ??        \cf11 //perform update logic here.\par ??\cf0         fvExceptionDetails.ChangeMode(\cf10 FormViewMode\cf0 .ReadOnly);\par ??        fvExceptionDetails.AllowPaging = \cf2 true\cf0 ;\par ??        DataBindExceptionDetails();\par ??    \}  } --&gt; &lt;div    style="background: white none repeat scroll 0% 50%;    -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;font-family:Courier New;font-size:10pt;color:black;"&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  322&lt;/span&gt;     &lt;span style="color:blue;"&gt;protected&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; fvExceptionDetails_ItemUpdating(&lt;span style="color:blue;"&gt;object&lt;/span&gt; sender, &lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  323&lt;/span&gt;         &lt;span style="color:teal;"&gt;FormViewUpdateEventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  324&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  325&lt;/span&gt;         &lt;span style="color:green;"&gt;//perform update logic here.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  326&lt;/span&gt;         fvExceptionDetails.ChangeMode(&lt;span style="color:teal;"&gt;FormViewMode&lt;/span&gt;.ReadOnly);&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  327&lt;/span&gt;         fvExceptionDetails.AllowPaging = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  328;/span&gt;         DataBindExceptionDetails();&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  329&lt;/span&gt;     }  &lt;/pre&gt;&lt;/div&gt; &lt;/div&gt;&lt;br /&gt;I hope this implementation detail helps. One thing to note would be that I was not using an &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;ObjectDataSource/SqlDataSource&lt;/span&gt; to populate the &lt;span class="Apple-style-span"  style="font-family:courier new;"&gt;Detailsview&lt;/span&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-5289330175100045181?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/5289330175100045181/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=5289330175100045181' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/5289330175100045181'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/5289330175100045181'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/06/aspnet-formview-control.html' title='ASP.Net FormView Control.'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-1660156656272195764</id><published>2007-06-24T14:31:00.000-05:00</published><updated>2007-06-24T15:11:58.378-05:00</updated><title type='text'>ASP.Net Page Cycle</title><content type='html'>Understanding the ASP.Net page cycle is important and helpful in cases where you need to make changes to a control/ add a conrol/ change the master page at runtime, etc..&lt;br /&gt;&lt;br /&gt;Here is the sequence of events and a brief description of the critical ones. I haven't had the chance to use of all of them as yet.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:trebuchet ms;"&gt;&lt;strong&gt;Order top to bottom&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;PreInit&lt;/em&gt; (method: Page_PreInit)&lt;br /&gt;&lt;blockquote&gt;&lt;p align="justify"&gt;&lt;span style="font-family:courier new;"&gt;Themes and master pages are applied between PreInit and Init, hence PreInit is the last place to programtically modify the selected theme/masterpage. When implmenting "Nested Master pages" while maintaining the ability to see pages in design mode in VS 2005, one needs to set the the change the page's current master page ( the base master page) to the nested master page using this event.&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;em&gt;Init&lt;/em&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;blockquote&gt;&lt;div align="justify"&gt;&lt;span style="font-family:courier new;"&gt;This event is called before any state is restored from the&lt;br /&gt;client response. It is used to prepare the Page for processing the request. Dynamic controls can be added in this event.&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;em&gt;InitComplete&lt;/em&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;Child controls are created between this event and the "InitComplete" event if it is a postback. Also, Control/View State is loaded if it is a postback.&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;em&gt;PreLoad&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Load&lt;/em&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;span style="font-family:courier new;"&gt;&lt;blockquote&gt;&lt;div align="justify"&gt;&lt;span style="font-family:courier new;"&gt;Most commonly used event. It is used to initialize control values on a GET request &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;(!IsPostBack). It is called after&lt;br /&gt;the control/view state has been restored in the Init event on a POST request (IsPostBack) before control passes to the specific event that caused the postback.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;em&gt;LoadComplete&lt;/em&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;span style="font-family:courier new;"&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;To be used to move code from the PreRender event,&lt;br /&gt;the place to make last minute changes to controls.&lt;/span&gt; &lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;em&gt;PreRender&lt;/em&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;span style="font-family:courier new;"&gt;&lt;blockquote&gt;&lt;div align="justify"&gt;&lt;span style="font-family:courier new;"&gt;Used to make any post-event modifications to the controls (Last place to make a change before they get rendered). &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;Recently, I created an editable gridview consiting of 2 columns, one a "State" dropdown and the other "Type" dropdown whose content needed to be changed based on the state selected. I had a Telerik RadAjaxPanel around the Grid and wanted to change the content of the "type" dropdown based on the selection in the "State" dropdown. I had specifically used the PreRender event to tie the "State" dropdown to the "Type" dropdown for every row in the Grid.&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;/div&gt;&lt;em&gt;PreRenderComplete&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Render&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;UnLoad&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-1660156656272195764?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/1660156656272195764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=1660156656272195764' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/1660156656272195764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/1660156656272195764'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/06/aspnet-page-cycle.html' title='ASP.Net Page Cycle'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-447698926132735927</id><published>2007-06-12T08:02:00.000-05:00</published><updated>2007-06-12T08:07:38.061-05:00</updated><title type='text'>Safari Beta 3 for PC released</title><content type='html'>I am excited, Apple has released Safari Beta 3 for the Windows. Though it crashed on my machine and I still haven't been able to see it run on my machine, I did see it running on my colleague's win xp box.&lt;br /&gt;&lt;br /&gt;A substantial amount of education related community use the mac's and we had a lot of requests to make the sites "Safari" compatible.&lt;br /&gt;&lt;br /&gt;This is a big player entering the pc browser market and should make things interesting.&lt;br /&gt;&lt;br /&gt;Get it &lt;a href="http://www.apple.com/safari/download/"&gt;at Safari Beta 3 for PC&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-447698926132735927?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/447698926132735927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=447698926132735927' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/447698926132735927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/447698926132735927'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/06/safari-beta-3-for-pc-released.html' title='Safari Beta 3 for PC released'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-2623076441512607453</id><published>2007-06-09T11:10:00.000-05:00</published><updated>2007-06-11T07:17:49.962-05:00</updated><title type='text'>Asp.net Release mode Request timeout</title><content type='html'>On one of the projects, the administrator triggered of an event that created a flat file based on the contents of a database. This task needed around 10-20 minutes to complete. The task completed fine when in debug mode but never in release mode.&lt;br /&gt;&lt;br /&gt;Upon talking to an Architect in the company it dawned upon me that there ASP.NET has something called "Request Timeout" (seperate than Session timeout) and this varies between the debug and the release mode. For the debug mode, the duration is a year while for release mode the request timeout is 90 seconds. Hence the abrupt request termination.&lt;br /&gt;&lt;br /&gt;He pointed me to this:&lt;br /&gt;&lt;a href="http://codebetter.com/blogs/peter.van.ooijen/archive/2006/06/15/146446.aspx"&gt;Code Better: Peter Gekko: Timeout of an asp.net page&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In short the code looks like this:&lt;br /&gt;&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20     \cf2 protected\cf0  \cf2 override\cf0  \cf2 void\cf0  OnInit(\cf10 EventArgs\cf0  e)\par ??    \{\par ??        timeOut = Server.ScriptTimeout;\par ??        \cf11 // Give it 5 hour = (3600 * 5) = 18000 seconds\par ??\cf0         Server.ScriptTimeout = 18000;\par ??    \}} --&gt; &lt;div style="background: white none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  279&lt;/span&gt;     &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnInit(&lt;span style="color: teal;"&gt;EventArgs&lt;/span&gt; e)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  280&lt;/span&gt;     {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  281&lt;/span&gt;         timeOut = Server.ScriptTimeout;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  282&lt;/span&gt;         &lt;span style="color: green;"&gt;// Give it 5 hour = (3600 * 5) = 18000 seconds&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  283&lt;/span&gt;         Server.ScriptTimeout = 18000;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  284&lt;/span&gt;     }&lt;/pre&gt; &lt;/div&gt; &lt;br /&gt;This task can be completed using an ASP.NET Async page or by spawning a separate thread/process. I will make a post on that experience.  Till then, this is workable.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-2623076441512607453?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/2623076441512607453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=2623076441512607453' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/2623076441512607453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/2623076441512607453'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/06/aspnet-release-mode-request-timeout.html' title='Asp.net Release mode Request timeout'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-6985217251994462539</id><published>2007-06-08T09:14:00.000-05:00</published><updated>2007-06-08T09:27:54.934-05:00</updated><title type='text'>Javascript gotcha</title><content type='html'>I recently ran into an issue with JavaScript where the script tag was ended with&lt;br /&gt;&lt;br /&gt;Please overlook the missing "&lt;" at the start of the script tags, since blogger understandingly has issues with script tags.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;script src="../jscalender-1.0/calender.js" /&gt;&lt;br /&gt;script src="../jscalender-1.0/calender/look.js" /&gt;&lt;br /&gt;script src="../jscalender-1.0/calender/feel.js" /&gt;&lt;br /&gt;script language="javascript" type="text/javascript"&gt;&lt;br /&gt;function showCalender()&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;/script&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;In spite of the rendered page containing the above script blocks, the showCalender function was not found and I kept getting a runtime javascript error: Object not found.&lt;br /&gt;&lt;br /&gt;IE provided no clues about what is happening, finally when I looked at the source in Firefox with the color scheme, it dawned upon me that only the first script tag is being recognized while the rest are being ignored.&lt;br /&gt;&lt;br /&gt;When I changed them to:&lt;br /&gt;&lt;blockquote&gt;script src="../jscalender-1.0/calender.js"&gt; /script&gt;&lt;br /&gt;script src="../jscalender-1.0/calender/look.js" &gt; /script&gt;&lt;br /&gt;script src="../jscalender-1.0/calender/feel.js" &gt; /script&gt;&lt;br /&gt;script language="javascript" type="text/javascript"&gt;&lt;br /&gt;function showCalender()&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;/script&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;So the moral is, close the JavaScript tags with /script&gt; even though the /&gt; might work in certain cases, it baffles you in cases like this.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-6985217251994462539?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/6985217251994462539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=6985217251994462539' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/6985217251994462539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/6985217251994462539'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/06/javascript-gotcha.html' title='Javascript gotcha'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-5694669502762859927</id><published>2007-06-02T17:48:00.000-05:00</published><updated>2007-06-11T07:34:27.872-05:00</updated><title type='text'>Books and Tree Surgeon</title><content type='html'>I am almost about to finish &lt;a href="http://www.joelonsoftware.com/BuytheBooks.html"&gt;&lt;span style="font-family:courier new;"&gt;Joel on software&lt;/span&gt;&lt;/a&gt;. It is a fun book for developer and actually puts a smile on your face. I really liked his style of writing and presenting this experiences.&lt;br /&gt;&lt;br /&gt;He says on recruiting, he only looks for 2 qualities in "Smart" and "gets things done".&lt;br /&gt;&lt;br /&gt;I also like his "Joel Test" for evaluating employers. Quoting him:&lt;br /&gt;&lt;blockquote&gt;&lt;p&gt; &lt;span style="font-family:courier new;"&gt;     1.Do you use source control?&lt;br /&gt;    2.Can you make a built in one step?&lt;br /&gt;    3.Do you make daily builds?&lt;br /&gt;    4.Do you have a bug database?&lt;br /&gt;    5.Do you fix bugs vefore writing new code?&lt;br /&gt;    6.Do you have an up-to-date schedule?&lt;br /&gt;    7.Do you have a spec?&lt;br /&gt;    8.Do programmers have a quite working conditions?&lt;br /&gt;    9.Do you use the best tools money can buy?&lt;br /&gt;   10.Do you have testers?&lt;br /&gt;   11.Do new candidates write code during their&lt;/span&gt;&lt;span style="font-family:courier new;"&gt; interview?&lt;br /&gt;   12.Do you do hallway usability testing?&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;Also interesting is his idea about "hallway usability testing", which I actually implemented on a recent project. Its amazing how much input you get from fellow developers, their criticism, ideas to make the ap better. Hallway testing will stay with me forever.&lt;br /&gt;&lt;br /&gt;I recently bought &lt;a href="http://cc2e.com/"&gt;&lt;span style="font-family:courier new;"&gt;Code Complete&lt;/span&gt;&lt;/a&gt;, Jeff Atwood swears by this book. I want to read this book, its  a big one. He considers it as the bible for all software developers.&lt;br /&gt;&lt;br /&gt;I went to Barnes and nobles to read a book called &lt;a href="http://www.oreilly.com/catalog/hfdesignpat/"&gt;&lt;span style="font-family:courier new;"&gt;Head First Design Patterns&lt;/span&gt;&lt;/a&gt;, I really liked the book and concepts were explained so beautifully. I just read about the "Strategy Pattern" and loved the way they presented the materials. I liked the line "Just because you know every OO concept doesnt mean you know how to use they".&lt;br /&gt;some of the concepts I can still remember are&lt;br /&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;Encapsulate everything that changes&lt;br /&gt;Use Composition over inheritance&lt;br /&gt;Code to Interfaces and not implementations.&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;I came accross an amazing tool called &lt;span style="font-family:courier new;"&gt;"&lt;/span&gt;&lt;a href="http://www.codeplex.com/treesurgeon"&gt;&lt;span style="font-family:courier new;"&gt;Tree Surgeon&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new;"&gt;"&lt;/span&gt; which creates a development tree for you. just give it a project name and "voila" it creates a development tree for your project. One of the criticism asp.net received from &lt;a href="http://www.loudthinking.com/"&gt;&lt;span style="font-family:courier new;"&gt;David Heinemeier Hansson&lt;/span&gt;&lt;/a&gt; was that asp.net gives you a clean slate when you start with a new project. One has to be knowledgeble enough to setup the testing framework, business layer, build project. If you are new to .Net and not fortunate enough to have a good mentor, you would probably end up with a bloated project. Tree Surgeon does all that for you.&lt;br /&gt;&lt;br /&gt;I am going to try and use it in some home project, probably a project to do an existing project using the MVP pattern. I will report my findings.&lt;br /&gt;&lt;br /&gt;It will also introduce me to NAnt build system. I have only been using VS 2005 for building my projects uptill now.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-5694669502762859927?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/5694669502762859927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=5694669502762859927' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/5694669502762859927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/5694669502762859927'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/06/books-and-tree-surgeon.html' title='Books and Tree Surgeon'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-8005585746561712898</id><published>2007-06-01T08:50:00.000-05:00</published><updated>2007-06-01T09:06:59.269-05:00</updated><title type='text'>IIS User</title><content type='html'>It might be a 101 but this week it struck me that the user under which IIS runs differs in WinXP and Win 2003. I was always under the impression that IIS runs under the local aspnet account (hostname\ASPNET).&lt;br /&gt;&lt;br /&gt;Well, it turns out that it runs under ASPNET in XP (which most developers have) but runs under "Network Service" in Win 2003 which most servers have. I was setting an old website for maintainance purposes and the IIS user needed write permission to a certain folder (for ActiveReports PDFs to be written) .&lt;br /&gt;&lt;br /&gt;Cassini, the internal web server for VS 2005 seemed to have access to that folder fine. I then setup a virtual dir for this project on my local IIS and gave ASPNET user write access and it worked. It took me a while to realise that under Win 2003, IIS runs under "Network Service".&lt;br /&gt;&lt;br /&gt;Anyways, here is an article about it.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms998320.aspx"&gt;How To: Use the Network Service Account to Access Resources in ASP.NET&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:Arial;font-size:85%;"&gt;&lt;span style="font-size: 10pt; font-family: Arial;"&gt;&lt;o:p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-8005585746561712898?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/8005585746561712898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=8005585746561712898' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/8005585746561712898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/8005585746561712898'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/06/iis-user.html' title='IIS User'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-5355900572443832206</id><published>2007-05-23T11:29:00.000-05:00</published><updated>2007-05-23T11:33:54.651-05:00</updated><title type='text'>Mozilla Blogspot Issue</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_KFBAFYeh98I/RlRsqQJ8M9I/AAAAAAAAARE/37UCBGX9z1U/s1600-h/MozillaBlogSpotIssue.JPG"&gt;&lt;img style="cursor: pointer;" src="http://4.bp.blogspot.com/_KFBAFYeh98I/RlRsqQJ8M9I/AAAAAAAAARE/37UCBGX9z1U/s320/MozillaBlogSpotIssue.JPG" alt="" id="BLOGGER_PHOTO_ID_5067794953845617618" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;   I am having this weird issue with Mozilla not able to display the html spurted out by CopySourceAsHtml utility and it happens only with the first post with html created by CopysourceAsHtml.&lt;br /&gt;&lt;br /&gt;IE displays the posts correctly. Will have to look into this.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-5355900572443832206?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/5355900572443832206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=5355900572443832206' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/5355900572443832206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/5355900572443832206'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/05/mozilla-blogspot-issue.html' title='Mozilla Blogspot Issue'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_KFBAFYeh98I/RlRsqQJ8M9I/AAAAAAAAARE/37UCBGX9z1U/s72-c/MozillaBlogSpotIssue.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-1350612743257055745</id><published>2007-05-23T10:51:00.000-05:00</published><updated>2007-06-02T17:47:38.647-05:00</updated><title type='text'>Compact Framework : Table Exist Method</title><content type='html'>In PDA based database applications one has to sometimes pull database/tables from the host machine/server onto the PDA (such as specific insurance agent's collection data). The procedure used is Remote Data Access (RDA). Compact framework has a stripped down version of the framework and some functionality available in the full framework isn't present on it.&lt;br /&gt;&lt;br /&gt;I had a condition where I needed to I needed to check if a certain table existed on the pda database and if not then pull it from the server. I needed a table exist method and wanted to avoid the try catch code block which I have seen in use to derive that a table doesn't exist if you get a exception on something like this&lt;br /&gt;'select (count(*) from premiums;'&lt;br /&gt;&lt;br /&gt;I knew there would be a cleaner way to know if a table exist in a database or not.&lt;br /&gt;&lt;br /&gt;Here is the method :&lt;br /&gt;&lt;br /&gt;We query the meta data and get a clean answer, no try/catch needed derive the answer.&lt;br /&gt;&lt;br /&gt;&lt;div style="BACKGROUND: white 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initialfont-family:Courier New;font-size:10pt;color:black;"   &gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  430&lt;/span&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;&lt;summary&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  431&lt;/span&gt;         &lt;span style="color:gray;"&gt;///&lt;/span&gt;&lt;span style="color:green;"&gt; Queries the information schema to find whether a table exists or not&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  432&lt;/span&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;&lt;/summary&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  433&lt;/span&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;&lt;param name="table"&gt;&lt;/param&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  434&lt;/span&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;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  435&lt;/span&gt;         &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;bool&lt;/span&gt; TableExists(&lt;span style="color:blue;"&gt;string&lt;/span&gt; table)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  436&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  437&lt;/span&gt;             &lt;span style="color:blue;"&gt;bool&lt;/span&gt; retAnswer = &lt;span style="color:blue;"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  438&lt;/span&gt;             &lt;span style="color:blue;"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  439&lt;/span&gt;             {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  440&lt;/span&gt;                 &lt;span style="color:blue;"&gt;int&lt;/span&gt; exist = (&lt;span style="color:blue;"&gt;int&lt;/span&gt;)&lt;span style="color:teal;"&gt;ConnectionManager&lt;/span&gt;.DBInfoConnection.ExecuteScalar(&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  441&lt;/span&gt;                     &lt;span style="color:maroon;"&gt;"SELECT count(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='"&lt;/span&gt; + table + &lt;span style="color:maroon;"&gt;"'"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  442&lt;/span&gt;                 &lt;span style="color:blue;"&gt;if&lt;/span&gt; (exist == 1)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  443&lt;/span&gt;                     retAnswer = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  444&lt;/span&gt;             }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  445&lt;/span&gt;             &lt;span style="color:blue;"&gt;catch&lt;/span&gt; (&lt;span style="color:teal;"&gt;Exception&lt;/span&gt; ex)&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  446&lt;/span&gt;             {&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  447&lt;/span&gt;                 &lt;span style="color:teal;"&gt;GenericLogger&lt;/span&gt;.Error(&lt;span style="color:maroon;"&gt;"Could not query database for list of tables"&lt;/span&gt;, ex);&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  448&lt;/span&gt;             }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  449&lt;/span&gt;             &lt;span style="color:blue;"&gt;return&lt;/span&gt; retAnswer;&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;&lt;span style="COLOR: rgb(43,145,175)"&gt;  450&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt; &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;Please ignore the non use of SqlParameters. I had to add this as a maintainence method in an &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;2-3 years old app and when you have to decide between your urge to make drastic(essential) &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;changes to a system and the number of hours that have been alotted &lt;/pre&gt;&lt;pre style="MARGIN: 0px"&gt;to this task, I think pragmatism wins.&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-1350612743257055745?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/1350612743257055745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=1350612743257055745' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/1350612743257055745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/1350612743257055745'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/05/compact-framework-table-exist-method.html' title='Compact Framework : Table Exist Method'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-7553138253392381055</id><published>2007-05-20T11:26:00.000-05:00</published><updated>2007-07-24T09:28:07.755-05:00</updated><title type='text'>Visual Studio Must have tools &amp; blog roll</title><content type='html'>If you are in ASP.NET development you are sure to stumble upon Scott Hanselman, the author of Professional ASP.NET 2.0. Recently I have started reading his blog reliously. Here is his list of tools and VS 2005 addins that are a must have and not to be missed.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.hanselman.com/blog/ScottHanselmans2005UltimateDeveloperAndPowerUsersToolList.aspx"&gt;Scott Hanselman's list of power tools&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;He has a important take on blogging. He rightfully contends that you will have returning audience only if your blog content is well formatted/indented and easy on the eyes.&lt;br /&gt;&lt;br /&gt;I have started using the CopySourceAsHtml VS2005 plugin to do code blog posts. As you can see, I need to clean up old code posts on this blog and use the tool above to have the posts easy on the eyes.&lt;br /&gt;&lt;br /&gt;I also like &lt;a href="http://www.blogger.com/www.codinghorror.com"&gt;Jeff Atwood's &lt;/a&gt;writing, he says make it a habit to blog atleast once a week and make a commitement, since interpersonal and communication skills are so important and needs to honed with time. He writes on human factors in software development.&lt;br /&gt;&lt;br /&gt;You can't miss Joel Spolsky author of the blog &lt;a href="http://joelonsoftware.com/"&gt;Joel on Software&lt;/a&gt;. His books are hilarious and fun to read.&lt;br /&gt;&lt;br /&gt;I listen to&lt;a href="http://polymorphicpodcast.com/"&gt; Craig Shoemaker&lt;/a&gt; as often as I can. His show/blog is essential for every asp.net developer. He has the knack to explain beautifully the why/how/where approach for a solution.&lt;br /&gt;Most podcasts/screencasts assume you know about things, while he explains things from the ground up.&lt;br /&gt;&lt;br /&gt;One cannot miss the blog of the ASP.Net guru &lt;a href="http://weblogs.asp.net/scottgu/"&gt;Scott Guthrie&lt;/a&gt; for ASP.Net tricks, tips, hacks, patches and advice.&lt;br /&gt;&lt;br /&gt;I like to read blog by &lt;a href="http://www.jpboodhoo.com/blog/"&gt;Jean Paul Boodhoo&lt;/a&gt; for knowledge about Test Driven Development and pattern based development.&lt;br /&gt;&lt;br /&gt;I also sometimes refer to &lt;a href="http://scottonwriting.net/sowblog/"&gt;Scott Mitchel's &lt;/a&gt;blog. Scott, is a ASP.NET guru and consultant. He has an excellent series on "Working with Data in ASP.NET 2.0".&lt;br /&gt;&lt;br /&gt;I will be editing this list this week, it is no way near completion.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-7553138253392381055?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/7553138253392381055/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=7553138253392381055' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/7553138253392381055'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/7553138253392381055'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/05/visual-studio-must-have-tools-blog-roll.html' title='Visual Studio Must have tools &amp; blog roll'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-3997156995780470394</id><published>2007-05-17T08:31:00.000-05:00</published><updated>2007-05-17T08:42:54.999-05:00</updated><title type='text'>Sanitization against Sql injection attacks.</title><content type='html'>&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20         \cf15 ///\cf11  \cf15 &lt;summary&gt;\par ??\cf0         \cf15 ///\cf11  make search text input sql safe.\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;/summary&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;param name="inputSQL"&gt;&lt;/param&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;returns&gt;&lt;/returns&gt;\par ??\cf0         \cf2 private\cf0  \cf2 static\cf0  \cf2 string\cf0  SafeSqlLikeClauseLiteral(\cf2 string\cf0  inputSQL)\par ??        \{\par ??            \cf11 // Make the following replacements:\par ??\cf0             \cf11 // '  becomes  ''\par ??\cf0             \cf11 // [  becomes  [[]\par ??\cf0             \cf11 // %  becomes  [%]\par ??\cf0             \cf11 // _  becomes  [_]\par ??\par ??\cf0             \cf2 string\cf0  s = inputSQL;\par ??            s = inputSQL.Replace(\cf13 "'"\cf0 , \cf13 "''"\cf0 );\par ??            s = s.Replace(\cf13 "["\cf0 , \cf13 "[[]"\cf0 );\par ??            s = s.Replace(\cf13 "%"\cf0 , \cf13 "[%]"\cf0 );\par ??            s = s.Replace(\cf13 "_"\cf0 , \cf13 "[_]"\cf0 );\par ??            \cf2 return\cf0  s;\par ??        \}\par ??        \cf15 ///\cf11  \cf15 &lt;summary&gt;\par ??\cf0         \cf15 ///\cf11  make text input sql safe\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;/summary&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;param name="inputSQL"&gt;&lt;/param&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;returns&gt;&lt;/returns&gt;\par ??\cf0         \cf2 private\cf0  \cf2 static\cf0  \cf2 string\cf0  SafeSqlLiteral(\cf2 string\cf0  inputSQL)\par ??        \{\par ??            \cf2 return\cf0  inputSQL.Replace(\cf13 "'"\cf0 , \cf13 "''"\cf0 );\par ??        \}\par ??        \cf15 ///\cf11  \cf15 &lt;summary&gt;\par ??\cf0         \cf15 ///\cf11  convert '' to ' when returning to the user, Remember, only to be used\par ??\cf0         \cf15 ///\cf11  when returning strings to user.\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;/summary&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;param name="output"&gt;&lt;/param&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;returns&gt;&lt;/returns&gt;\par ??\cf0         \cf2 private\cf0  \cf2 static\cf0  \cf2 string\cf0  Desanitize(\cf2 string\cf0  output)\par ??        \{\par ??            \cf2 return\cf0  output.Replace(\cf13 "''"\cf0 , \cf13 "'"\cf0 );\par ??        \}} --&gt; &lt;div face="Courier New" size="10pt" color="black" style="background: white none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;&lt;br /&gt;&lt;p style="margin: 0px; color: rgb(0, 0, 0);"&gt;Here is what I use to sanitize my text input before inserting into DB. Most of the code is from a msdn article on how to avoid sql injection attacks.&lt;/p&gt;&lt;p style="margin: 0px; color: rgb(0, 0, 0);"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="margin: 0px; color: rgb(0, 0, 0);"&gt; &lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20         \cf15 ///\cf11  \cf15 &lt;summary&gt;\par ??\cf0         \cf15 ///\cf11  make search text input sql safe.\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;/summary&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;param name="inputSQL"&gt;&lt;/param&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;returns&gt;&lt;/returns&gt;\par ??\cf0         \cf2 private\cf0  \cf2 static\cf0  \cf2 string\cf0  SafeSqlLikeClauseLiteral(\cf2 string\cf0  inputSQL)\par ??        \{\par ??            \cf11 // Make the following replacements:\par ??\cf0             \cf11 // '  becomes  ''\par ??\cf0             \cf11 // [  becomes  [[]\par ??\cf0             \cf11 // %  becomes  [%]\par ??\cf0             \cf11 // _  becomes  [_]\par ??\par ??\cf0             \cf2 string\cf0  s = inputSQL;\par ??            s = inputSQL.Replace(\cf13 "'"\cf0 , \cf13 "''"\cf0 );\par ??            s = s.Replace(\cf13 "["\cf0 , \cf13 "[[]"\cf0 );\par ??            s = s.Replace(\cf13 "%"\cf0 , \cf13 "[%]"\cf0 );\par ??            s = s.Replace(\cf13 "_"\cf0 , \cf13 "[_]"\cf0 );\par ??            \cf2 return\cf0  s;\par ??        \}\par ??        \cf15 ///\cf11  \cf15 &lt;summary&gt;\par ??\cf0         \cf15 ///\cf11  make text input sql safe\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;/summary&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;param name="inputSQL"&gt;&lt;/param&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;returns&gt;&lt;/returns&gt;\par ??\cf0         \cf2 private\cf0  \cf2 static\cf0  \cf2 string\cf0  SafeSqlLiteral(\cf2 string\cf0  inputSQL)\par ??        \{\par ??            \cf2 return\cf0  inputSQL.Replace(\cf13 "'"\cf0 , \cf13 "''"\cf0 );\par ??        \}\par ??        \cf15 ///\cf11  \cf15 &lt;summary&gt;\par ??\cf0         \cf15 ///\cf11  convert '' to ' when returning to the user, Remember, only to be used\par ??\cf0         \cf15 ///\cf11  when returning strings to user.\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;/summary&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;param name="output"&gt;&lt;/param&gt;\par ??\cf0         \cf15 ///\cf11  \cf15 &lt;returns&gt;&lt;/returns&gt;\par ??\cf0         \cf2 private\cf0  \cf2 static\cf0  \cf2 string\cf0  Desanitize(\cf2 string\cf0  output)\par ??        \{\par ??            \cf2 return\cf0  output.Replace(\cf13 "''"\cf0 , \cf13 "'"\cf0 );\par ??        \}} --&gt; &lt;/p&gt;&lt;div style="background: white none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   29&lt;/span&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;&lt;summary&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   30&lt;/span&gt;         &lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; make search text input sql safe.&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   31&lt;/span&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;&lt;/summary&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   32&lt;/span&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;&lt;param name="inputSQL"&gt;&lt;/param&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   33&lt;/span&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;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   34&lt;/span&gt;         &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; SafeSqlLikeClauseLiteral(&lt;span style="color: blue;"&gt;string&lt;/span&gt; inputSQL)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   35&lt;/span&gt;         {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   36&lt;/span&gt;             &lt;span style="color: green;"&gt;// Make the following replacements:&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   37&lt;/span&gt;             &lt;span style="color: green;"&gt;// '  becomes  ''&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   38&lt;/span&gt;             &lt;span style="color: green;"&gt;// [  becomes  [[]&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   39&lt;/span&gt;             &lt;span style="color: green;"&gt;// %  becomes  [%]&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   40&lt;/span&gt;             &lt;span style="color: green;"&gt;// _  becomes  [_]&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   41&lt;/span&gt; &lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   42&lt;/span&gt;             &lt;span style="color: blue;"&gt;string&lt;/span&gt; s = inputSQL;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   43&lt;/span&gt;             s = inputSQL.Replace(&lt;span style="color: maroon;"&gt;"'"&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"''"&lt;/span&gt;);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   44&lt;/span&gt;             s = s.Replace(&lt;span style="color: maroon;"&gt;"["&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"[[]"&lt;/span&gt;);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   45&lt;/span&gt;             s = s.Replace(&lt;span style="color: maroon;"&gt;"%"&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"[%]"&lt;/span&gt;);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   46&lt;/span&gt;             s = s.Replace(&lt;span style="color: maroon;"&gt;"_"&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"[_]"&lt;/span&gt;);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   47&lt;/span&gt;             &lt;span style="color: blue;"&gt;return&lt;/span&gt; s;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   48&lt;/span&gt;         }&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   49&lt;/span&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;&lt;summary&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   50&lt;/span&gt;         &lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; make text input sql safe&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   51&lt;/span&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;&lt;/summary&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   52&lt;/span&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;&lt;param name="inputSQL"&gt;&lt;/param&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   53&lt;/span&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;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   54&lt;/span&gt;         &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; SafeSqlLiteral(&lt;span style="color: blue;"&gt;string&lt;/span&gt; inputSQL)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   55&lt;/span&gt;         {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   56&lt;/span&gt;             &lt;span style="color: blue;"&gt;return&lt;/span&gt; inputSQL.Replace(&lt;span style="color: maroon;"&gt;"'"&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"''"&lt;/span&gt;);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   57&lt;/span&gt;         }&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   58&lt;/span&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;&lt;summary&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   59&lt;/span&gt;         &lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; convert '' to ' when returning to the user, Remember, only to be used&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   60&lt;/span&gt;         &lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; when returning strings to user.&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   61&lt;/span&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;&lt;/summary&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   62&lt;/span&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;&lt;param name="output"&gt;&lt;/param&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   63&lt;/span&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;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   64&lt;/span&gt;         &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; Desanitize(&lt;span style="color: blue;"&gt;string&lt;/span&gt; output)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   65&lt;/span&gt;         {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   66&lt;/span&gt;             &lt;span style="color: blue;"&gt;return&lt;/span&gt; output.Replace(&lt;span style="color: maroon;"&gt;"''"&lt;/span&gt;, &lt;span style="color: maroon;"&gt;"'"&lt;/span&gt;);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   67&lt;/span&gt;         }&lt;/pre&gt; &lt;/div&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-3997156995780470394?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/3997156995780470394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=3997156995780470394' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/3997156995780470394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/3997156995780470394'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2007/05/sanitization-against-sql-injection.html' title='Sanitization against Sql injection attacks.'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-116481859264316959</id><published>2006-11-29T10:39:00.000-06:00</published><updated>2006-11-29T10:44:10.386-06:00</updated><title type='text'>Group Number in SQL Reporting Services</title><content type='html'>Found this after lot of searching.&lt;br /&gt;&lt;br /&gt;I was grouping data in a table in a SQL report. I could successfully add row numbers to the details of the group but was unable to add row numbers to group header.&lt;br /&gt;Something like this&lt;br /&gt;&lt;br /&gt;1 ClaimID1&lt;br /&gt;&lt;blockquote&gt;    1&lt;br /&gt;   2&lt;br /&gt;   3&lt;/blockquote&gt;&lt;br /&gt;2 ClaimID2&lt;br /&gt;&lt;blockquote&gt;    1&lt;br /&gt;   2&lt;br /&gt;   3&lt;br /&gt;   4&lt;br /&gt;   5&lt;/blockquote&gt;&lt;br /&gt;3 ClaimID3&lt;br /&gt;&lt;blockquote&gt;    1&lt;/blockquote&gt;The following expression helped adding the row number for the groups&lt;br /&gt;=RunningValue(Fields!ClaimID.Value, CountDistinct, Nothing)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-116481859264316959?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/116481859264316959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=116481859264316959' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/116481859264316959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/116481859264316959'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/11/group-number-in-sql-reporting-services.html' title='Group Number in SQL Reporting Services'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-116257214889993177</id><published>2006-11-03T10:34:00.000-06:00</published><updated>2007-05-23T08:08:16.257-05:00</updated><title type='text'>javascript Trim method</title><content type='html'>Javascript has no trim() method that is required all the time.&lt;br /&gt;&lt;br /&gt;This script will strip starting and ending spaces for you..&lt;br /&gt;&lt;br /&gt;&lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf11 // JScript File\par ??//javascript left &amp; right trim similar to stringObj.Trim() in C#\par ??\cf0 function trimAll(sString)\par ??\{\par ??    \cf2 while\cf0  (sString.substring(0,1) == \cf13 ' '\cf0 )\par ??    \{\par ??        sString = sString.substring(1, sString.length);\par ??    \}\par ??    \cf2 while\cf0  (sString.substring(sString.length-1, sString.length) == \cf13 ' '\cf0 )\par ??    \{\par ??        sString = sString.substring(0,sString.length-1);\par ??    \}\par ??    \cf2 return\cf0  sString;\par ??\}} --&gt; &lt;div style="background: white none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   72&lt;/span&gt; &lt;span style="color: green;"&gt;// JScript File&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   73&lt;/span&gt; &lt;span style="color: green;"&gt;//javascript left &amp; right trim similar to stringObj.Trim() in C#&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   74&lt;/span&gt; function trimAll(sString)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   75&lt;/span&gt; {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   76&lt;/span&gt;     &lt;span style="color: blue;"&gt;while&lt;/span&gt; (sString.substring(0,1) == &lt;span style="color: maroon;"&gt;' '&lt;/span&gt;)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   77&lt;/span&gt;     {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   78&lt;/span&gt;         sString = sString.substring(1, sString.length);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   79&lt;/span&gt;     }&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   80&lt;/span&gt;     &lt;span style="color: blue;"&gt;while&lt;/span&gt; (sString.substring(sString.length-1, sString.length) == &lt;span style="color: maroon;"&gt;' '&lt;/span&gt;)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   81&lt;/span&gt;     {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   82&lt;/span&gt;         sString = sString.substring(0,sString.length-1);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   83&lt;/span&gt;     }&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   84&lt;/span&gt;     &lt;span style="color: blue;"&gt;return&lt;/span&gt; sString;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;   85&lt;/span&gt; }&lt;/pre&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-116257214889993177?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/116257214889993177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=116257214889993177' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/116257214889993177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/116257214889993177'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/11/javascript-trim-method.html' title='javascript Trim method'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115991515599678213</id><published>2006-10-03T17:34:00.000-05:00</published><updated>2007-05-20T14:16:19.283-05:00</updated><title type='text'>Detecting Session Timeout in Asp.Net</title><content type='html'>Alas post after a while. I wanted to detect session timeouts and redirect the user to the logon page with the appropriate message.&lt;br /&gt;I stumbled upto this code (it works) which helps detect a session timeout in asp.Net.&lt;br /&gt;&lt;br /&gt;One needs to follow the common BasePage pattern and inherit all the pages from this common page.&lt;br /&gt;All the common functions can be put in this page.&lt;br /&gt;&lt;br /&gt;///&lt;br /&gt;/// This overriden method helps handle Session timeouts.&lt;br /&gt;/// Credit to author.&lt;br /&gt;///&lt;br /&gt;///&lt;br /&gt;&lt;!--&lt;br /&gt;{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20     \cf15 ///\cf11  \cf15 &amp;lt;summary&amp;gt;\par ??\cf0     \cf15 ///\cf11  This overriden method helps handle Session timeouts.\par ??\cf0     \cf15 ///\cf11  \cf15 &amp;lt;/summary&amp;gt;\par ??\cf0     \cf15 ///\cf11  \cf15 &amp;lt;param name="e"&amp;gt;&amp;lt;/param&amp;gt;\par ??\cf0     \cf2 override\cf0  \cf2 protected\cf0  \cf2 void\cf0  OnInit(\cf10 EventArgs\cf0  e)\par ??    \{\par ??        \cf2 base\cf0 .OnInit(e);\par ??\par ??\par ??        \cf11 //It appears from testing that the Request and Response both share the \par ??\cf0         \cf11 // same cookie collection.  If I set a cookie myself in the Reponse, it is \par ??\cf0         \cf11 // also immediately visible to the Request collection.  This just means that \par ??\cf0         \cf11 // since the ASP.Net_SessionID is set in the Session HTTPModule (which \par ??\cf0         \cf11 // has already run), thatwe can't use our own code to see if the cookie was \par ??\cf0         \cf11 // actually sent by the agent with the request using the collection. Check if \par ??\cf0         \cf11 // the given page supports session or not (this tested as reliable indicator \par ??\cf0         \cf11 // if EnableSessionState is true), should not care about a page that does \par ??\cf0         \cf11 // not need session\par ??\cf0         \cf2 if\cf0  (Context.Session != \cf2 null\cf0 )\par ??        \{\par ??            \cf11 //Tested and the IsNewSession is more advanced then simply checking if \par ??\cf0             \cf11 // a cookie is present, it does take into account a session timeout, because \par ??\cf0             \cf11 // I tested a timeout and it did show as a new session\par ??\cf0             \cf2 if\cf0  (Session.IsNewSession)\par ??            \{\par ??                \cf11 // If it says it is a new session, but an existing cookie exists, then it must \par ??\cf0                 \cf11 // have timed out (can't use the cookie collection because even on first \par ??\cf0                 \cf11 // request it already contains the cookie (request and response\par ??\cf0                 \cf11 // seem to share the collection)\par ??\cf0                 \cf2 string\cf0  szCookieHeader = Request.Headers[\cf13 "Cookie"\cf0 ];\par ??                \cf2 if\cf0  ((\cf2 null\cf0  != szCookieHeader) &amp;amp;&amp;amp; (szCookieHeader.IndexOf(\cf13 "ASP.NET_SessionId"\cf0 ) &amp;gt;= 0))\par ??                \{\par ??                    \cf11 //string url = "~/Default.aspx?x=" + RedirectMessage("Session Timed out.");\par ??\cf0                     \cf11 //Response.Redirect(url);\par ??\cf0                     Session[\cf13 "TimeoutMessage"\cf0 ] = \cf13 "Your Session timed out"\cf0 ;\par ??                    Response.Redirect(\cf13 "~/Default.aspx"\cf0 );\par ??                \}\par ??            \}\par ??        \}\par ??    \}}&lt;br /&gt;--&gt;&lt;br /&gt;&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;84&lt;/span&gt;&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;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;85&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; This overriden method helps handle Session timeouts.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;86&lt;/span&gt;&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;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;87&lt;/span&gt;&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="e"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;88&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; OnInit(&lt;span style="color: teal;"&gt;EventArgs&lt;/span&gt; e)&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;89&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;90&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;base&lt;/span&gt;.OnInit(e);&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;91&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;92&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;93&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;//It appears from testing that the Request and Response both share the &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;94&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// same cookie collection.&amp;nbsp; If I set a cookie myself in the Reponse, it is &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;95&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// also immediately visible to the Request collection.&amp;nbsp; This just means that &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;96&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// since the ASP.Net_SessionID is set in the Session HTTPModule (which &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;97&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// has already run), thatwe can't use our own code to see if the cookie was &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;98&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// actually sent by the agent with the request using the collection. Check if &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;99&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// the given page supports session or not (this tested as reliable indicator &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;100&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// if EnableSessionState is true), should not care about a page that does &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;101&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;// not need session&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;102&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;if&lt;/span&gt; (Context.Session != &lt;span style="color: blue;"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;103&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;104&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: green;"&gt;//Tested and the IsNewSession is more advanced then simply checking if &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;105&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: green;"&gt;// a cookie is present, it does take into account a session timeout, because &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;106&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: green;"&gt;// I tested a timeout and it did show as a new session&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;107&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;if&lt;/span&gt; (Session.IsNewSession)&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;108&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;109&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: green;"&gt;// If it says it is a new session, but an existing cookie exists, then it must &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;110&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: green;"&gt;// have timed out (can't use the cookie collection because even on first &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;111&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: green;"&gt;// request it already contains the cookie (request and response&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;112&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: green;"&gt;// seem to share the collection)&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;113&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;string&lt;/span&gt; szCookieHeader = Request.Headers[&lt;span style="color: maroon;"&gt;"Cookie"&lt;/span&gt;];&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;114&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; ((&lt;span style="color: blue;"&gt;null&lt;/span&gt; != szCookieHeader) &amp;amp;&amp;amp; (szCookieHeader.IndexOf(&lt;span style="color: maroon;"&gt;"ASP.NET_SessionId"&lt;/span&gt;) &amp;gt;= 0))&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;115&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;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;116&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;//string url = "~/Default.aspx?x=" + RedirectMessage("Session Timed out.");&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;117&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;//Response.Redirect(url);&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;118&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; Session[&lt;span style="color: maroon;"&gt;"TimeoutMessage"&lt;/span&gt;] = &lt;span style="color: maroon;"&gt;"Your Session timed out"&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;119&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; Response.Redirect(&lt;span style="color: maroon;"&gt;"~/Default.aspx"&lt;/span&gt;);&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;120&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;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;121&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;122&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;pre style="margin: 0px;"&gt;&lt;span style="color: #2b91af;"&gt;&amp;nbsp;&amp;nbsp;123&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115991515599678213?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115991515599678213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115991515599678213' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115991515599678213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115991515599678213'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/10/detecting-session-timeout-in-aspnet.html' title='Detecting Session Timeout in Asp.Net'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115945906082064876</id><published>2006-09-28T10:48:00.000-05:00</published><updated>2006-10-01T13:37:13.220-05:00</updated><title type='text'>Object Databases, Part I</title><content type='html'>The choice of the backing store in a large project is almost always a political decision that's already been made for you. If your company already has a farm of Oracle 9 databases, well... that automatically becomes your choice. Rarely does a single consultant or developer get to pick a database solution. It's almost always a case of, "This is what we have; deal with it."&lt;br /&gt;&lt;br /&gt;So chances are high that I'll never ever get to use Object Databases in a project situation, given their poor market penetration. However, &lt;a href="http://archive.devx.com/dbzone/articles/sf0601/sf0601-1.asp"&gt;here is an excellent comparison of Object Databases versus traditional RDBMS systems from DevX&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I am playing around with an Object Database called &lt;a href="http://www.db4o.com/Default.aspx?AspxAutoDetectCookieSupport=1"&gt;db4o&lt;/a&gt;, which is licensed under GPL for non-commerical use. More on that later.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115945906082064876?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115945906082064876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115945906082064876' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115945906082064876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115945906082064876'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/09/object-databases-part-i.html' title='Object Databases, Part I'/><author><name>Alexis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115921632577134354</id><published>2006-09-25T14:57:00.000-05:00</published><updated>2006-09-25T15:32:12.383-05:00</updated><title type='text'>Configuration using Jakarta Commons</title><content type='html'>I've played around quite a bit with the Jakarta Commons libraries over time and over several projects. Among these, the &lt;a href="http://jakarta.apache.org/commons/configuration/index.html"&gt;Jakarta Commons Configuration&lt;/a&gt; library is extremely useful.&lt;br /&gt;&lt;br /&gt;Very often, we encounter a particular crosscutting concern when developing medium to large scale projects: that of managing user and/or application preferences. This seemingly simple task often leads to much wasted and duplicated effort when the development team should really be focusing on core project tasks. The Commons Configuration library can come to the rescue in such situations.&lt;br /&gt;&lt;br /&gt;Managing user/application preferences can get complex depending on the requirements. Consider:&lt;br /&gt;&lt;br /&gt;(1) The project may start out storing configuration information in simple ".properties" files, but later, some genius might want to migrate everything to XML files. In such instances, you want the property accessor calls abstracted out enough so that the migration can take place with minimal, localized code change and without breaking property accessor calls which might be sprinkled throughout the codebase.&lt;br /&gt;&lt;br /&gt;(2)  You might want to support a hierarchy of property sources. For example, you might have an application-wide property source that provides the default values, but allow each user to specify his or her own property file to override the defaults. In other words, you need to support multi-source, composite configurations.&lt;br /&gt;&lt;br /&gt;(3) You will in some cases want to support nested and/or list-based properties in your properties files.&lt;br /&gt;&lt;br /&gt;(4) You will want to synchronize access to shared properties files in case of concurrent updates.&lt;br /&gt;&lt;br /&gt;(5) You might want to provide an "autosave" feature or an "auto reload" feature when a preference/property is updated.&lt;br /&gt;&lt;br /&gt;Well, the Jakarta Commons Configuration library goes a long way in providing a very flexible framework for configuration/preferences management. It supports ".properties" file based configurations and XML files. The accessor syntax for the XML files is XPath-like and can get quite intricate, I noticed.&lt;br /&gt;&lt;br /&gt;A wonderful feature is the provision of configuration change listeners which can listen for changes to a properties file and respond appropriately. Any Java class can set itself up as a listener to a Configuration object, which fires the required events.&lt;br /&gt;&lt;br /&gt;I have yet to compare the Jakarta Configuration library with the Preferences API in Java, but from a cursory glance, it seems to me like the Preferences API does not even come close in power. Also, the .Net System.Configuration classes seem to be much more specific in the sense that they seem to concentrate on providing access to the .Net framework config files like &lt;em&gt;machine.config&lt;/em&gt; and &lt;em&gt;web.config&lt;/em&gt; and not so much on supplying a flexible and generic configuration management framework.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Wishlist: A nice addition to the Commons Configuration library might be access methods to configuration data stored in relational databases and hierarchical stores like LDAP, but that is probably asking for too much.&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115921632577134354?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115921632577134354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115921632577134354' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115921632577134354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115921632577134354'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/09/configuration-using-jakarta-commons.html' title='Configuration using Jakarta Commons'/><author><name>Alexis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115884752970004085</id><published>2006-09-21T08:57:00.000-05:00</published><updated>2006-09-21T09:22:47.466-05:00</updated><title type='text'>More powerful collections</title><content type='html'>If the Java Collections Framework is too limiting for you, then you should check out the open source &lt;a href="http://jakarta.apache.org/commons/collections/"&gt;Jakarta Commons Collections&lt;/a&gt; from the Apache project.&lt;br /&gt;&lt;br /&gt;It adds several important extensions such as ordered maps, bi-directional maps, bags (i.e. multi-sets), Fifo queues, and certain other convenience features like iterators and transformation primitives.&lt;br /&gt;&lt;br /&gt;I believe .Net has a multiset implementation in its System.Collections.Specialized namespace, but no bidi maps. Also Jakarta Collections adds a type-check primitive to ensure that only objects of a certain type get stored in a collections, though I don't think this removes the overhead of boxing and unboxing that you typically encounter in generic collections that store data as "Objects". Type-safe collections that don't do boxing and unboxing will necessarily speed up operations on large collections, but the only way to have that seems to be the C++ templates, .Net generics, or Java 5 generics. The trade0ff with generics is of course binary code bloat leading to larger executables, not to mention more intricate syntax.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115884752970004085?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115884752970004085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115884752970004085' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115884752970004085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115884752970004085'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/09/more-powerful-collections.html' title='More powerful collections'/><author><name>Alexis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115876579586769685</id><published>2006-09-20T10:12:00.000-05:00</published><updated>2006-09-20T10:23:15.886-05:00</updated><title type='text'>10 Things You Shouldn't Do with SQL Server</title><content type='html'>I came across this old post about some 'Don't' with SQL server. I found it helpful and elightening about some facts.&lt;br /&gt;&lt;span name="intelliTxt" id="intelliTxt"&gt;&lt;span id="_ctl0_ContentTitle" class="PageTitle"&gt;http://www.sqljunkies.com/Article/92CC4817-604D-4344-8BE0-4490F8ED24B6.scuk&lt;br /&gt;&lt;br /&gt;Here are some snippets from it.&lt;br /&gt;&lt;br /&gt;1. SCOPE_IDENTITY()     Vs     @@IDENTITY&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span name="intelliTxt" id="intelliTxt"&gt;&lt;span id="_ctl0_ArticleText"&gt;&lt;p nd="15"&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p nd="15"&gt;@@IDENTITY will return the last identity value entered into a table in your     current session (this is limited to your session only, so you won't get     identities entered by other users). While @@IDENTITY is limited to the current     session, it is not limited to the current scope. In other words, if you have a     trigger on a table that causes an identity to be created in another table, you     will get the identity that was created last, even if it was the trigger that     created it. Now this isn't bad, as long as you ensure that things are done in     the correct order. Where this can get ugly is when there is an application     revision and a new trigger gets added that gets fired from your stored     procedure. Your code didn't anticipate this new trigger, so you could now be     getting an incorrect value back.&lt;/p&gt;   &lt;p nd="16"&gt;SCOPE_IDENTITY(), like @@IDENTITY, will return the last identity value created     in the current session, but it will also limit it to your current scope as     well. In other words, it will return the last identity value that you     explicitly created, rather than any identity that was created by a trigger or a     user defined function.&lt;/p&gt;&lt;/blockquote&gt;&lt;p nd="16"&gt;&lt;/p&gt;&lt;p nd="16"&gt;2. &lt;span name="intelliTxt" id="intelliTxt"&gt;&lt;span id="_ctl0_ArticleText"&gt;Prefix Stored Procedures with "sp_"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p nd="16"&gt;&lt;span name="intelliTxt" id="intelliTxt"&gt;&lt;span id="_ctl0_ArticleText"&gt;&lt;p nd="54"&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p nd="54"&gt;It is strongly recommended that you do not create any stored procedures using &lt;strong nd="55"&gt;      sp_&lt;/strong&gt; as a prefix. SQL Server always looks for a stored procedure      beginning with &lt;strong nd="56"&gt;sp_&lt;/strong&gt; in this order:     &lt;/p&gt;&lt;ol&gt;&lt;li nd="57"&gt;       The stored procedure in the &lt;b nd="58"&gt;master&lt;/b&gt; database.&lt;br /&gt;     &lt;/li&gt;&lt;li nd="59"&gt;       The stored procedure based on any qualifiers provided (database name or owner).&lt;br /&gt;     &lt;/li&gt;&lt;li nd="60"&gt;       The stored procedure using &lt;b nd="61"&gt;dbo&lt;/b&gt; as the owner, if one is not specified.      &lt;/li&gt;&lt;/ol&gt;    &lt;p nd="62"&gt;Therefore, although the user-created stored procedure prefixed with &lt;b nd="63"&gt;sp_&lt;/b&gt; may      exist in the current database, the &lt;b nd="64"&gt;master&lt;/b&gt; database is always checked      first, even if the stored procedure is qualified with the database name.&lt;/p&gt;&lt;/blockquote&gt;&lt;p nd="62"&gt;&lt;/p&gt;&lt;p nd="62"&gt;I took time and broke the tradition of prefixing the stored procs with sp_ and renamed all my stored procs by removing the prefix, also replaced @@IDENTITY with SCOPE_IDENTITY() for future maintainance purposes.&lt;/p&gt;&lt;p nd="62"&gt;For Pros these might be 101s, but his article explained by exactly not to do some things, rather than just putting it down as a rule on the holy grail.&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115876579586769685?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115876579586769685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115876579586769685' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115876579586769685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115876579586769685'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/09/10-things-you-shouldnt-do-with-sql.html' title='10 Things You Shouldn&apos;t Do with SQL Server'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115868634835360753</id><published>2006-09-19T11:55:00.000-05:00</published><updated>2006-09-20T10:23:49.773-05:00</updated><title type='text'>Velocity Templates</title><content type='html'>HTML templating has always appealed to me. For most database-backed web pages, dynamic generation of the entire page--especially the static parts that don't change--is a bit of a bother. Conceptually, a HTML page can be seen as a combination of static bits that don't change often and dynamic bits that change often depending on data coming from a backend data store. A good example is a roster of students signed up for a course. The static bits in this page might be the navigation bars, course information, faculty information, etc. while the list of students might be an incremental and dynamic HTML table that grows/shrinks as students sign up or drop the course.&lt;br /&gt;&lt;br /&gt;Generating the static parts of the above page in say, a servlet, is a pain. A simple edit like a change in a faculty's phone number will require a code change if the generation of the static parts is embedded in code. Templates solve this problem by abstracting the static parts out in a template file which looks like a HTML file but with the addition of placeholders for dynamic content. In the case of &lt;a href="http://jakarta.apache.org/velocity/"&gt;Velocity&lt;/a&gt;, the dynamic content is generated by a Java program or a servlet. The dynamic content is then merged with the template to produce the final output to the client. An edit to a prof's phone number now becomes a simple edit in a text editor to the template. No code change is required.&lt;br /&gt;&lt;br /&gt;Velocity facilitates a separation of concerns. Web designers can work with the template (provided they don't mess with the dynamic content), while business logic gurus can take care of serving up the dynamic data in the page.&lt;br /&gt;&lt;br /&gt;In my opinion, the separation is not very clean because it is quite easy to distribute the dynamic placeholders all over the template, making the template look like a horrible mess of HTML tags and Velocity tags. Web Designers might recoil in horror at working with such a template. But if some discipline is exercised in the structuring of the templates, it can be an useful tool.&lt;br /&gt;&lt;br /&gt;One concern that might be expressed is that the merging of templates is a relatively slower operation than generating the page by hand. The good news is that some of that loss in speed can be mitigated by turning on template caching in a properties file that Velocity supplies for configuration purposes. If the data does not change between requests, the output page is fetched from the cache instead of being merged and re-generated.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Note: Velocity is a generic template engine and therefore can be used for any sort of templating task, not just HTML templates. For example, it can be used for sending out bulk mail with a mail merge sort of feature by utilizing email templating.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115868634835360753?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115868634835360753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115868634835360753' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115868634835360753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115868634835360753'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/09/velocity-templates.html' title='Velocity Templates'/><author><name>Alexis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115824544845657168</id><published>2006-09-14T09:10:00.000-05:00</published><updated>2006-09-14T10:01:37.006-05:00</updated><title type='text'>Google Web Toolkit</title><content type='html'>The idea behind the &lt;a href="http://code.google.com/webtoolkit/"&gt;Google Web Toolkit&lt;/a&gt; is simple.&lt;br /&gt;&lt;br /&gt;When building rich-n-thin clients using DHTML and AJAX, many people have noticed that Javascript standardization in browsers is--how shall we say it--piss-poor. Differences in event handling, divergent error handling, DOM quirks; it's a party. Throw in the fact that Javascript is loosely typed and you will soon start pulling your hair out by the handfuls.&lt;br /&gt;&lt;br /&gt;The Google Web Toolkit offers this proposition: Write your AJAX apps in Java and then compile the code into Javascript. You get the benefits of programming in a strongly typed, true OO language and also some protection from browser quirks since they are abstracted out for you by the GWT.&lt;br /&gt;&lt;br /&gt;Note that you can't use the entire set of Java libraries while coding a GWT app, of course. You can only use a subset that can be translated into Javascript. For example, it is crazy to use the threading classes and expect that to be translated into Javascript. But quite a few classes from the java.lang and java.util are available for you to use. Personally, I wasn't very impressed with this. For example, why can't I use the Drag and Drop Java API and have the resulting code translated into browser-agnostic Javascript? More and more AJAX apps are providing drag-n-drop support; it would have been nice to have this support in GWT.&lt;br /&gt;&lt;br /&gt;Where GWT really shines is in the custom wrapper classes that are provided for you. The DOM has been completely abstracted out for you. So have events, cookies, timers, the top level browser window, the history list. A HTTPRequest object serves as an interface to the XMLHTTPRequest to make AJAX calls in a cross-browser way. There are classes for JSON parsing, XML parsing, and making RPC calls.&lt;br /&gt;&lt;br /&gt;Also, the list of widgets provided is impressive: a Grid, a FlexTable (a dynamically growing/shrinking table), a Tree, a TabPanel, among others. It really beats coding these common UI elements in pure DHTML and Javascript.&lt;br /&gt;&lt;br /&gt;What really speeds up the development cycle is that you can code up a storm in Java and then run your app in a "hosted" mode which is like a local Java runtime. If your application runs in hosted mode, it is guaranteed to run in "web" mode, which means it will run cross-browser. Once you have your code tweaked in hosted mode, it is a simple matter to run a compile shell script (provided by the GWT) to translate the Java to Javascript.&lt;br /&gt;&lt;br /&gt;Shortcomings of GWT: Sometimes you have to get down and dirty with Javascript because the GWT doesn't quite manage to encapsulate everything for you behind a Java facade. A good example is lack of support for drag and drop. Or something like, say the Observer/Observable classes in Java--surely that could have been translated to Javascript. I know that pure Javascript libraries exist that implement the Observer pattern.&lt;br /&gt;&lt;br /&gt;Personal opinion: I think GWT is here to stay, unless the next version of ECMAScript i.e. version 4, makes toolkits like the GWT philosophically redundant.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Note: I believe the Microsoft community has something similar to the GWT called Script# that uses C# as the front-end language instead of Java.&lt;/em&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115824544845657168?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115824544845657168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115824544845657168' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115824544845657168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115824544845657168'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/09/google-web-toolkit.html' title='Google Web Toolkit'/><author><name>Alexis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115757014130648901</id><published>2006-09-06T13:51:00.000-05:00</published><updated>2006-09-06T14:24:25.736-05:00</updated><title type='text'>asp:RangeValidator gotcha!!!</title><content type='html'>I was using rangevalidator in my user controls.&lt;br /&gt;&lt;br /&gt;the ranges I was setting was&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote style="color: rgb(204, 153, 51);"&gt;&lt;span style="font-family:courier new;"&gt;    0 - 49&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    0 - 100&lt;/span&gt;&lt;/blockquote&gt;For some reason, the validator for (0-100) range was validating only 0 &amp; 100 and invalidating the rest.  It wasn't clear to me why it wasn't working for &lt;span style="font-family:courier new;"&gt;0-100&lt;/span&gt; while it was working for &lt;span style="font-family:courier new;"&gt;0-49&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Both being part of same user control there was no discrepancy in settings of the control.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;After searching on the net&lt;/span&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;I found that one has to set the &lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 0);font-family:courier new;" &gt;"Type"&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt; property of the &lt;/span&gt;&lt;span style="color: rgb(204, 153, 51); font-weight: bold;font-family:courier new;" &gt;asp:RangeValidator&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt; to&lt;/span&gt; &lt;span style="font-weight: bold;font-family:courier new;" &gt;"Integer"&lt;/span&gt; &lt;span style="color: rgb(0, 153, 0);"&gt;apart from setting the &lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;font-family:courier new;" &gt;MaximumValue&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;"&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;"&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;font-family:courier new;" &gt;MinimumValue&lt;/span&gt;&lt;span style="color: rgb(0, 153, 0);"&gt;&lt;span style="color: rgb(0, 0, 0); font-weight: bold;"&gt;"&lt;/span&gt;, in order for it to consistantly work for any range of integers.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Other &lt;span style="font-weight: bold;"&gt;Type&lt;/span&gt; options are&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote style="color: rgb(204, 102, 0);"&gt;&lt;span style="font-family:courier new;"&gt;    Currency&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    Date&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    Double&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    Integer&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    String&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115757014130648901?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115757014130648901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115757014130648901' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115757014130648901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115757014130648901'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/09/asprangevalidator-gotcha.html' title='asp:RangeValidator gotcha!!!'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115751395088033315</id><published>2006-09-05T22:04:00.000-05:00</published><updated>2007-05-23T10:45:03.582-05:00</updated><title type='text'>Generic Business layer</title><content type='html'>On my current project I have discovered a nice way to write generic database access code in the business layer.&lt;br /&gt;Most database access operations are&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;   a. returning DataTable of results (for binding with&lt;br /&gt;     objectdatasource &amp; other controls)&lt;br /&gt;&lt;/span&gt;   &lt;span style="font-family:courier new;"&gt;&lt;br /&gt; b. Inserting/updating data&lt;br /&gt;&lt;/span&gt;   &lt;span style="font-family:courier new;"&gt;&lt;br /&gt; c. returning a single value (execute scalar)&lt;/span&gt;&lt;/blockquote&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The approach I have been following is to reduce the number of places where I write database code (code reuse) so as to make it maintainable and make necessary changes in a few places instead in all of the business layer.&lt;br /&gt;&lt;br /&gt;e.g&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt; &lt;!-- {\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs20 \cf2 public\cf0  \cf2 class\cf0  \cf10 DBHandler\par ??\cf0 \{\par ??    \cf2 private\cf0  \cf2 static\cf0  \cf10 DataTable\cf0  GenericGetDataTable(\cf2 string\cf0  storedProc,\par ??    \cf2 params\cf0  SqlParameters[] parameters)\par ??    \{\par ??        \cf10 DataTable\cf0  retTable = \cf2 null\cf0 ;\par ??        \cf2 string\cf0  connStr = \cf10 Configuration\cf0 .AppSettings[\cf13 "ConnectionString"\cf0 ];\par ??        \cf2 using\cf0  (\cf10 SqlConnection\cf0  conn = \cf2 new\cf0  \cf10 SqlConnection\cf0 (connstr))\par ??        \{\par ??            conn.open();\par ??            \cf10 SqlCommand\cf0  cmd = \cf2 new\cf0  \cf10 SqlCommand\cf0 (storedProc, conn);\par ??            \cf2 foreach\cf0  (\cf10 SqlParameter\cf0  para \cf2 in\cf0  parameters)\par ??            \{\par ??            cmd.Parameters.Add(para);\par ??            \}\par ??            cmd.CommandType = \cf10 CommandType\cf0 .StoredProcedure;\par ??            .\par ??            .\par ??            .\par ??            .\par ??            conn.close();\par ??        \}\par ??        \cf2 return\cf0  retTable;\par ??    \}\par ??    \cf2 public\cf0  \cf2 static\cf0  \cf10 DataTable\cf0  GetBooks( \cf2 int\cf0  publicationID, \cf2 string\cf0  authorName)\par ??    \{\par ??        \cf10 SqlParameter\cf0  pubID = \cf2 new\cf0  \cf10 SqlParameter\cf0 (\cf13 "@pubID"\cf0 , publicationID);\par ??        \cf10 SqlParameter\cf0  authName = \cf2 new\cf0  \cf10 SqlParameter\cf0 (\cf13 "@authName"\cf0 , authorName);\par ??        \cf2 return\cf0  GenericGetDataTable(\cf13 "sp_getAllBooks"\cf0 , pubID, authName);\par ??    \}\par ??    \cf2 public\cf0  \cf2 static\cf0  \cf10 DataTable\cf0  GetPapers(\cf2 int\cf0  journalID, \cf2 int\cf0  year)\par ??    \{\par ??        \cf10 SqlParameter\cf0  jourID = \cf2 new\cf0  \cf10 SqlParameter\cf0 (\cf13 "@journalID"\cf0 , journalID);\par ??        \cf10 SqlParameter\cf0  jYear = \cf2 new\cf0  \cf10 SqlParameter\cf0 (\cf13 "@year"\cf0 , year);\par ??        \cf2 return\cf0  GenericGetDataTable(\cf13 "sp_getAllPublications"\cf0 , jourID, jYear);\par ??    \}\par ??    .\par ??    .\par ??    .\par ??    .\par ??    \cf11 // similarly for INSERT &amp; Execute Scalar methods\par ??\cf0     \cf2 private\cf0  \cf2 static\cf0  \cf2 object\cf0  GenericExecuteScalar(\cf2 string\cf0  storedProc,\par ??    \cf2 params\cf0  SqlParameters[] parameters)\par ??    \{\par ??\par ??    \}\par ??    \cf2 private\cf0  \cf2 static\cf0  \cf2 int\cf0  GenericInsert(\cf2 string\cf0  storedProc,\par ??    \cf2 params\cf0  SqlParameters[] parameters)\par ??    \{\par ??\par ??    \}\par ??\}} --&gt; &lt;div style="background: white none repeat scroll 0%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  148&lt;/span&gt; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;DBHandler&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  149&lt;/span&gt; {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  150&lt;/span&gt;     &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: teal;"&gt;DataTable&lt;/span&gt; GenericGetDataTable(&lt;span style="color: blue;"&gt;string&lt;/span&gt; storedProc,&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  151&lt;/span&gt;     &lt;span style="color: blue;"&gt;params&lt;/span&gt; SqlParameters[] parameters)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  152&lt;/span&gt;     {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  153&lt;/span&gt;         &lt;span style="color: teal;"&gt;DataTable&lt;/span&gt; retTable = &lt;span style="color: blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  154&lt;/span&gt;         &lt;span style="color: blue;"&gt;string&lt;/span&gt; connStr = &lt;span style="color: teal;"&gt;Configuration&lt;/span&gt;.AppSettings[&lt;span style="color: maroon;"&gt;"ConnectionString"&lt;/span&gt;];&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  155&lt;/span&gt;         &lt;span style="color: blue;"&gt;using&lt;/span&gt; (&lt;span style="color: teal;"&gt;SqlConnection&lt;/span&gt; conn = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;SqlConnection&lt;/span&gt;(connstr))&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  156&lt;/span&gt;         {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  157&lt;/span&gt;             conn.open();&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  158&lt;/span&gt;             &lt;span style="color: teal;"&gt;SqlCommand&lt;/span&gt; cmd = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;SqlCommand&lt;/span&gt;(storedProc, conn);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  159&lt;/span&gt;             &lt;span style="color: blue;"&gt;foreach&lt;/span&gt; (&lt;span style="color: teal;"&gt;SqlParameter&lt;/span&gt; para &lt;span style="color: blue;"&gt;in&lt;/span&gt; parameters)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  160&lt;/span&gt;             {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  161&lt;/span&gt;             cmd.Parameters.Add(para);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  162&lt;/span&gt;             }&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  163&lt;/span&gt;             cmd.CommandType = &lt;span style="color: teal;"&gt;CommandType&lt;/span&gt;.StoredProcedure;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  164&lt;/span&gt;             .&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  165&lt;/span&gt;             .&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  166&lt;/span&gt;             .&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  167&lt;/span&gt;             .&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  168&lt;/span&gt;             conn.close();&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  169&lt;/span&gt;         }&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  170&lt;/span&gt;         &lt;span style="color: blue;"&gt;return&lt;/span&gt; retTable;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  171&lt;/span&gt;     }&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  172&lt;/span&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: teal;"&gt;DataTable&lt;/span&gt; GetBooks( &lt;span style="color: blue;"&gt;int&lt;/span&gt; publicationID, &lt;span style="color: blue;"&gt;string&lt;/span&gt; authorName)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  173&lt;/span&gt;     {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  174&lt;/span&gt;         &lt;span style="color: teal;"&gt;SqlParameter&lt;/span&gt; pubID = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;SqlParameter&lt;/span&gt;(&lt;span style="color: maroon;"&gt;"@pubID"&lt;/span&gt;, publicationID);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  175&lt;/span&gt;         &lt;span style="color: teal;"&gt;SqlParameter&lt;/span&gt; authName = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;SqlParameter&lt;/span&gt;(&lt;span style="color: maroon;"&gt;"@authName"&lt;/span&gt;, authorName);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  176&lt;/span&gt;         &lt;span style="color: blue;"&gt;return&lt;/span&gt; GenericGetDataTable(&lt;span style="color: maroon;"&gt;"sp_getAllBooks"&lt;/span&gt;, pubID, authName);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  177&lt;/span&gt;     }&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  178&lt;/span&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: teal;"&gt;DataTable&lt;/span&gt; GetPapers(&lt;span style="color: blue;"&gt;int&lt;/span&gt; journalID, &lt;span style="color: blue;"&gt;int&lt;/span&gt; year)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  179&lt;/span&gt;     {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  180&lt;/span&gt;         &lt;span style="color: teal;"&gt;SqlParameter&lt;/span&gt; jourID = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;SqlParameter&lt;/span&gt;(&lt;span style="color: maroon;"&gt;"@journalID"&lt;/span&gt;, journalID);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  181&lt;/span&gt;         &lt;span style="color: teal;"&gt;SqlParameter&lt;/span&gt; jYear = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;SqlParameter&lt;/span&gt;(&lt;span style="color: maroon;"&gt;"@year"&lt;/span&gt;, year);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  182&lt;/span&gt;         &lt;span style="color: blue;"&gt;return&lt;/span&gt; GenericGetDataTable(&lt;span style="color: maroon;"&gt;"sp_getAllPublications"&lt;/span&gt;, jourID, jYear);&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  183&lt;/span&gt;     }&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  184&lt;/span&gt;     .&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  185&lt;/span&gt;     .&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  186&lt;/span&gt;     .&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  187&lt;/span&gt;     .&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  188&lt;/span&gt;     &lt;span style="color: green;"&gt;// similarly for INSERT &amp; Execute Scalar methods&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  189&lt;/span&gt;     &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;object&lt;/span&gt; GenericExecuteScalar(&lt;span style="color: blue;"&gt;string&lt;/span&gt; storedProc,&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  190&lt;/span&gt;     &lt;span style="color: blue;"&gt;params&lt;/span&gt; SqlParameters[] parameters)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  191&lt;/span&gt;     {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  192&lt;/span&gt; &lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  193&lt;/span&gt;     }&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  194&lt;/span&gt;     &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt; GenericInsert(&lt;span style="color: blue;"&gt;string&lt;/span&gt; storedProc,&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  195&lt;/span&gt;     &lt;span style="color: blue;"&gt;params&lt;/span&gt; SqlParameters[] parameters)&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  196&lt;/span&gt;     {&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  197&lt;/span&gt; &lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  198&lt;/span&gt;     }&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;  199&lt;/span&gt; }&lt;/pre&gt; &lt;/div&gt;  &lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/blockquote&gt;Here we use the &lt;span style="font-family:courier new;"&gt;params SqlParameters[] parameters &lt;/span&gt;to accept variable number of arguments in turn enabling us to write generic methods.&lt;br /&gt;This way we minimize the places where  we write database access  code.  I think  I achieved a lot of code reuse by this aproach.&lt;br /&gt;&lt;br /&gt;One would say that why not have ONE generic public method in DBHandler (for each operation) that accepts a storedProc &amp;amp; parameters. The only argument I have against this approach is that, with this approach my "page behinds" (controllers) will be clouded by names of stored procedures and SqlParameters statements. I think this would cause more maintainance depending on all the places from where it is called. I think it wouldn't be completely MVC complaint.&lt;br /&gt;&lt;br /&gt;In this approach, only the changes need to made to the DBHandler class and specific methods if needed.&lt;br /&gt;&lt;br /&gt;I have also realised from reading some posts from microsoft gurus that they are prominently using "using () { }" in their database access operations in order to dispose of the connection objects.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115751395088033315?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115751395088033315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115751395088033315' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115751395088033315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115751395088033315'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/09/generic-business-layer.html' title='Generic Business layer'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115680662520448260</id><published>2006-08-28T18:05:00.000-05:00</published><updated>2006-08-28T18:12:12.996-05:00</updated><title type='text'>Good &amp; tested RegularExpression for validating passwords?</title><content type='html'>Any sample tested and working Regular expression for validating the password?&lt;br /&gt;&lt;br /&gt;I was using&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;RequiredFieldValidator&lt;/span&gt;&lt;br /&gt;  &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;asp:requiredfieldvalidator&gt;&lt;/asp:requiredfieldvalidator&gt;&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;ID&lt;/span&gt;=&lt;span style="color: rgb(0, 0, 0);"&gt;"RequiredFieldValidator1"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;runat="server&lt;/span&gt;"&lt;br /&gt;  ErrorMessage="Please enter password" ControlToValidate="txtPassword" Display="none"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;RegularExpressionValidator&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;asp:regularexpressionvalidator&gt;&lt;/asp:regularexpressionvalidator&gt;&lt;/span&gt; ID="regValPassword" runat="server"&lt;br /&gt;  ErrorMessage="Enter valid password" Display="None"&lt;br /&gt;  ControlToValidate="txtPassword" ValidationExpression="^\w{3,12}$"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;for basic filtering&lt;br /&gt;&lt;br /&gt;any better thoughts for allowing 8-12 char passwords with special characters too?&lt;br /&gt;&lt;br /&gt;I found some scripts on the net but they didn't seem to work with&lt;br /&gt;&lt;br /&gt;asp.net's &lt;span style="color: rgb(204, 0, 0);"&gt;RegularExpressionValidator&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;asp:regularexpressionvalidator&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Thoughts welcome.&lt;/span&gt;&lt;br /&gt;&lt;/asp:regularexpressionvalidator&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115680662520448260?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115680662520448260/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115680662520448260' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115680662520448260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115680662520448260'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/08/good-tested-regularexpression-for.html' title='Good &amp; tested RegularExpression for validating passwords?'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115680552601052972</id><published>2006-08-28T17:25:00.000-05:00</published><updated>2006-08-29T15:25:19.420-05:00</updated><title type='text'>Setting up SSL in ASP.Net 2.0</title><content type='html'>Today I was given the task of setting up SSL support for a ASP.Net website.&lt;br /&gt;Here are the steps I had to take&lt;br /&gt;&lt;br /&gt;1. Install IIS 6.0 Resource Kit,&lt;br /&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=56FC92EE-A71A-4C73-B628-ADE629C89499&amp;displaylang=en&lt;br /&gt;&lt;br /&gt;which contains "&lt;font&gt;Selfssl.exe".&lt;br /&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;SelfSSL (SelfSSL.exe) can help you generate and install a self-signed SSL  certificate. Because the SelfSSL tool generates a self-signed certificate that  does not originate from a trusted source, use the SelfSSL tool only in the  following scenarios:  &lt;table class="list ul"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="bullet"&gt;•&lt;/td&gt;&lt;td class="text"&gt;When you have to create a security-enhanced private channel  between your server and a limited, known group of users&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class="bullet"&gt;•&lt;/td&gt;&lt;td class="text"&gt;When you have to troubleshoot third-party certificate problems&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;table class="list ul"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="text"&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;br /&gt;2. Create a certificate for use, similar to this&lt;br /&gt;&lt;font&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;selfssl.exe /N:CN=testMachine /K:1024 /V:7 /S:1 /P:443&lt;/span&gt;&lt;br /&gt;where&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;blockquote style="color: rgb(0, 102, 0);"&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;/K:key size      Specifies the key length. Default is 1024.&lt;br /&gt;/V:validity days Specifies the validity of the certificate. Default is 7 days.&lt;br /&gt;/S:site id       Specifies the id of the site. Default is 1 (Default Site).&lt;br /&gt;/P:port          Specifies the SSL port. Default is 443.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;3. Go to your IIS MMC-&gt; "&lt;font&gt;Default Website" and right click for "&lt;font&gt;Properties". Go to the "&lt;font&gt;Directory Security" tab and under "&lt;font&gt;Secure Communication" associate the recently created certificate to the server certificate. Now all websites under the "Default Website" will have this Server certificate.&lt;br /&gt;&lt;br /&gt;4. Browse to your virtual directory under the "&lt;font&gt;Default website" and right click for "&lt;font&gt;Properties".Go to the "Directory Security" tab and under "&lt;font&gt;Secure Communication" click "&lt;font&gt;Edit".&lt;br /&gt;Then check the "&lt;font&gt;Require Secure Channel" checkbox.&lt;br /&gt;&lt;br /&gt;Now the entire site will be under ssl and the url that would be needed to use will need "https" and not "http".&lt;br /&gt;&lt;br /&gt;&lt;font&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;But we also need to take care of the default redirecting to the start page if someone uses &lt;/span&gt;&lt;font&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;"http"&lt;/span&gt;&lt;font&gt; &lt;span style="color: rgb(204, 102, 0);"&gt;instead&lt;/span&gt;&lt;span style="color: rgb(204, 102, 0);"&gt; of "https"&lt;/span&gt;&lt;font&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;&lt;/span&gt;&lt;font&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;. If this feature is not implemented then the user will see a 403;4 page and will have to manually change the &lt;/span&gt;&lt;font&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;"http"&lt;/span&gt;&lt;font&gt;&lt;span style="color: rgb(204, 102, 0);"&gt; to &lt;/span&gt;&lt;font&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;"https"&lt;/span&gt;&lt;font&gt;&lt;span style="color: rgb(204, 102, 0);"&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The following steps are needed to enable default redirection to the secure start page.&lt;br /&gt;Please refer&lt;br /&gt;http://weblogs.asp.net/pwilson/archive/2004/12/23/331455.aspx&lt;br /&gt;for details&lt;br /&gt;1. In your project, create a basic html page &lt;font&gt;"Redirect.htm" with the following code&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;body onload="Redirect()"&lt;/span&gt;&lt;br /&gt;&lt;javascript&gt;&lt;br /&gt;&lt;font&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;[javascript]&lt;/span&gt;&lt;br /&gt;&lt;font&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    function Redirect()&lt;/span&gt;&lt;br /&gt;&lt;font&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;font&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;        window.location = "https://testMachine/SllTest/SignOn.aspx";&lt;/span&gt;&lt;br /&gt;&lt;font&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;font&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;[/javascript]&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/javascript&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;Note: Replace javascript with script tags and put braces before and after "body" tag&lt;br /&gt;&lt;br /&gt;2.  Browse to your virtual directory under the "Default website" and right click for "Properties". Click the "Custom Errors" tab and select the "403;4" error. Then click "Edit Properties" and set the error page to "Redirect.htm" in you r project directory.&lt;br /&gt;&lt;br /&gt;3. Browse to your virtual directory under the "Default website" and rightclick on "Redirect.htm" and in the "Directory Security" click "edit" and turn off "Require Secure Channel" for this page.&lt;br /&gt;&lt;br /&gt;So now our Redirect.htm is the only page that is unsecured and all it does is to redirect the user to the sign in page.&lt;br /&gt;&lt;br /&gt;Happy SSLing. ;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115680552601052972?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115680552601052972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115680552601052972' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115680552601052972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115680552601052972'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/08/setting-up-ssl-in-aspnet-20.html' title='Setting up SSL in ASP.Net 2.0'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115652134209200922</id><published>2006-08-25T10:18:00.000-05:00</published><updated>2006-08-25T11:02:27.210-05:00</updated><title type='text'>Cool Collaboration</title><content type='html'>If you don't want to plunk down the money for Microsoft Sharepoint, you can get by with &lt;a href="http://tikiwiki.org/"&gt;TikiWiki&lt;/a&gt; for some quick and easy collaboration among members of a project team. Tiki is an open-source Wiki software that I installed yesterday on my work laptop (A Dell XPS Pentium-M 2.0 GHz machine with 1GB RAM).&lt;br /&gt;&lt;br /&gt;Tiki is powered by PHP4 and needs a web server and a database. I went with IIS 6 and MySQL 5.&lt;br /&gt;&lt;br /&gt;The installation procedure is similar to something like Wordpress--it is possible to buy Tiki hosting space from an ISP, or install it locally.&lt;br /&gt;&lt;br /&gt;First, download and install PHP. You can register PHP with IIS either as an ISAPI extension or as a CGI module. ISAPI is faster and more secure, but I went with CGI (which is simpler to install).&lt;br /&gt;&lt;br /&gt;Next, you need to create a database user and a database schema in MySQL for Tiki. I used MySQL Administrator which comes with MySQL 5. You can use phpMyAdmin also if you like administering your MySQL over the web.&lt;br /&gt;&lt;br /&gt;Next, extract the Tiki software in a directory on the local file system, and create a virtual directory (I called it "tiki") in IIS that points to the location of your Tiki installation.&lt;br /&gt;&lt;br /&gt;Next, point your browser to http://[your web server]/tiki/tiki-install.php and setup of your Wiki will commence.&lt;br /&gt;&lt;br /&gt;I loved the features offered by this software. I hesitate to call it simply "Wiki" software because it offers much more out of the box. I am still exploring, but it offers, in addition to the Wiki capabilities:&lt;br /&gt;&lt;br /&gt;(1) Blogs, which is a nice touch if a particular member wants a soapbox of his/her own.&lt;br /&gt;(2) Articles (by topic)&lt;br /&gt;(3) Quizzes&lt;br /&gt;(4) Forums (They included a complete forum/BB software??)&lt;br /&gt;(5) Surveys (I have yet to toy with this)&lt;br /&gt;(6) A group calendar&lt;br /&gt;(7) Group chat&lt;br /&gt;(8) FAQs&lt;br /&gt;(9) Newsletters&lt;br /&gt;(10) A workflow engine.&lt;br /&gt;&lt;br /&gt;Whew!&lt;br /&gt;&lt;br /&gt;The Wiki software allows your site to be customized with themes and menus. And there is mail notification for changes. As if all this wasn't enough, Tiki is extensible with custom modules written in PHP. For example, there is a calculator mod, a world clock mod, a mod for WebDAV access to your Wiki, a mod that imports some cool avatars, etc.&lt;br /&gt;&lt;br /&gt;I like.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115652134209200922?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115652134209200922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115652134209200922' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115652134209200922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115652134209200922'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/08/cool-collaboration.html' title='Cool Collaboration'/><author><name>Alexis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115643415314883265</id><published>2006-08-24T10:26:00.000-05:00</published><updated>2006-08-24T10:43:46.463-05:00</updated><title type='text'>ViewState, SessionState and Application State 101</title><content type='html'>Here are a few things I learnt about  &lt;i&gt;ViewState, SessionState&lt;/i&gt; and&lt;i&gt; Application&lt;/i&gt;&lt;i&gt;State&lt;/i&gt; today.&lt;br/&gt;&lt;br/&gt;&lt;i&gt;ViewState&lt;/i&gt; property is used to save data in a hidden field on a page. Because, &lt;i&gt;ViewState&lt;/i&gt; stores data on a page, it is limited to items that can be serialized. Complex items have to converted to &amp; from strings.&lt;br/&gt;&lt;br/&gt;&lt;i&gt;ViewState&lt;/i&gt; info from one webform isunreadable to other webforms&lt;br/&gt;Property&lt;br/&gt;        ICollection ViewState.Values&lt;br/&gt;Method:&lt;br/&gt;       ViewState.Add(string key, object value)&lt;br/&gt;&lt;br/&gt;One should limit the access points to &lt;i&gt;Application&lt;/i&gt; &amp;amp; &lt;i&gt;Session&lt;/i&gt; State and basically create page level variables to store data from these and write back to them at the end.&lt;br/&gt;&lt;br/&gt;Maintaining &lt;i&gt;Session&lt;/i&gt; state affects performance.&lt;br/&gt;&lt;br/&gt;&lt;i&gt;Application&lt;/i&gt; state variables are available throughout a current process but not accross processes. If an app is scaled to multiple servers or multiple processors within a server, each process has its own application state.&lt;br/&gt;&lt;br/&gt;In Visual C#, be sure to test whether the state variable is &lt;i&gt;null&lt;/i&gt; or not before using methods like ToString() on it.&lt;br/&gt;&lt;br/&gt;Mechanisms for communication between webforms&lt;br/&gt;&lt;ol&gt;&lt;li&gt;Context.Handler object (Use this object to retrieve public members of one webform's class from a subsequently displayed web form.&lt;br/&gt;&lt;/li&gt;&lt;li&gt;Query strings&lt;/li&gt;&lt;li&gt;Cookies&lt;/li&gt;&lt;li&gt;ViewState&lt;/li&gt;&lt;li&gt;Session state&lt;/li&gt;&lt;li&gt;Application State&lt;/li&gt;&lt;/ol&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115643415314883265?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115643415314883265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115643415314883265' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115643415314883265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115643415314883265'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/08/viewstate-sessionstate-and-application.html' title='ViewState, SessionState and Application State 101'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115642920251461249</id><published>2006-08-24T09:10:00.000-05:00</published><updated>2006-08-24T09:22:53.213-05:00</updated><title type='text'>SqlDataSource Vs ObjectDataSource</title><content type='html'>Here are the arguments&lt;br/&gt;From: http://www.theserverside.net/news/thread.tss?thread_id=29919&lt;br/&gt;&lt;blockquote&gt;&lt;span style="color:#333333;"&gt;&lt;i&gt;Unsuspecting programmers, it is claimed, will use the SqlDataSource control and&lt;/i&gt; &lt;i&gt;unknowingly commit the unforgivable architectural sin of mixing their user interface, business logic, and data access layers.&lt;br/&gt;&lt;br/&gt;The SqlDataSource control enables you to represent a database connection, and common database commands, declaratively. Simply by declaring an instance of the SqlDataSource control in a page, you can represent SELECT, INSERT, UPDATE, and DELETE commands which can be executed against a database.&lt;br/&gt;&lt;br/&gt;SqlDataSource control is considered "really, really bad" is that it encourages programmers to flatten what should be many into one. The SqlDataSource control mixes business logic and data access layers into the user interface layer.&lt;br/&gt; &lt;br/&gt;Mixing the data layer with the UI is a BAD idea, period. Sure there may be times when you can get away with it, but the eventual unmanageability of it will greatly outweigh the short-term productivity gain. Creating logical layers of abstraction doesn't require physical separation of layers. Just moving the DAL into a separate class is a good idea because it gives you a single place to look for code dealing with the database. In the SqlDataSource scenario, if you change a stored procedure that is used on more than one page, you have to track down every page to make the change. This is bad design incarnate.&lt;br/&gt;&lt;br/&gt;Behind the scenes the SqlDataSource control generates the ADO.NET classes (Datasets, SqlCommand, etc.) that is necessary to access the data defined in the control's markup. But what about reuse? If I'm calling a stored procedure with several parameters through a series of page requests, it would be nice to get some reuse from the parameter collection ala Data Access Application Block's parameter caching.&lt;br/&gt;&lt;br/&gt;The ObjectDataSource control however does provide an architecturally sound way to bind web page controls to a middle-tier (logical, not necessarily physical) layer. So, for those web developers out there who want the ease of use that comes with declarative data binding, I recommend they use the ObjectDataSource control and forego the SqlDataSource control altogether.&lt;/i&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br/&gt;I think as a best practice, one should always use ObjectDataSource since it allows us to seperate the business layer logic from the UI and follows the MVC.&lt;br/&gt;&lt;br/&gt;I came accross this because I wanted to sort a GridView. I was assigning a DataTable returned by a method to the GridView's datasource. If we create a explicit DataSource object and bind  the GridView to it then the gridview is able to talk to the datasource and takes care of the sorting/paging.&lt;br/&gt;&lt;br/&gt;The object datasource helped me to grab data from a stored procedure and hence with zero sql code in the UI and kep it clean.&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115642920251461249?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115642920251461249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115642920251461249' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115642920251461249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115642920251461249'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/08/sqldatasource-vs-objectdatasource.html' title='SqlDataSource Vs ObjectDataSource'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115634567541160969</id><published>2006-08-23T09:52:00.000-05:00</published><updated>2006-08-23T10:07:55.420-05:00</updated><title type='text'>HTML::Embperl</title><content type='html'>Perl is a powerful language. And it can be terribly concise. I believe there are competitions that award prizes for the most concise (and most illegible, of course) Perl programs.&lt;br /&gt;&lt;br /&gt;Perl also fits a niche. If you are a sysadmin-type scripting sort of person, it is the tool for you. The core language has powerful text-processing facilities; and packages exist for everything else such as database access, XML parsing, whathaveyou.&lt;br /&gt;&lt;br /&gt;But if you thinking of programming-in-the-large, forget about it. Object oriented support is available from Perl 5, but the syntax is clumsy and looks tacked on as an afterthought. CGI programming? You are probably better off with PHP.&lt;br /&gt;&lt;br /&gt;But I digress.&lt;br /&gt;&lt;br /&gt;I recently saw and played with HTML::Embperl, which is a Perl package that lets you insert Perl code snippets in your HTML. Think JSP, but with Perl instead of Java. On the surface, seems like a good thing. The power of Perl directly from your Web pages, without having to worry about having to explicitly program to a CGI interface. But "the surface" often misleads.&lt;br /&gt;&lt;br /&gt;Quite frankly, the philosophy (not to mention the syntax) of Embperl made me cringe. Over the years, I have come to appreciate the good things that happen when you separate concerns. Embperl--not unlike carelessly programmed JSP--throws seperation of concerns out the window.&lt;br /&gt;&lt;br /&gt;Frameworks are often derided. Frameworks like Struts or Wicket try to separate concerns and this leads to a steep and complex learning curve. Embperl goes in the opposite direction and this makes it tempting for some, especially for smaller projects. But if there is one thing that I have learned, it is this: There *are* no small projects. Even the smallest project has a way of growing and bloating past its original intent.&lt;br /&gt;&lt;br /&gt;I would personally put my money on the frameworks.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115634567541160969?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115634567541160969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115634567541160969' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115634567541160969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115634567541160969'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/08/htmlembperl.html' title='HTML::Embperl'/><author><name>Alexis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115603001200300099</id><published>2006-08-19T18:16:00.000-05:00</published><updated>2006-08-19T18:33:56.620-05:00</updated><title type='text'>Asp.Net Session timeout about to happen Warning?</title><content type='html'>Any idea about how to implement the autoclose Session timeout windows that some bank websites imlement?&lt;br /&gt;&lt;br /&gt;I have been playing with giving the user an alert before a session timeout in a secure website.Here is a basic method that I found.&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;/*************************************************************************/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 127, 64);"&gt; &lt;summary&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt; int&lt;/span&gt; int_MilliSecondsTimeOut = (this.Session.Timeout * 60000) - 120000;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 191);"&gt;string&lt;/span&gt; str_Script = &lt;span style="color: rgb(128, 0, 0);"&gt;@"&lt;/span&gt;       &lt;br /&gt;&lt;span style="color: rgb(0, 127, 64);"&gt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;        function Reconnect()&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(128, 0, 0);"&gt;        {&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(128, 0, 0);"&gt;                alert('Session is about to Timeout in 2 minutes.\n Please complete work and submit');&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(128, 0, 0);"&gt;        }&lt;/span&gt;&lt;br /&gt; &lt;span style="color: rgb(128, 0, 0);"&gt;        window.setInterval('Reconnect()'," + int_MilliSecondsTimeOut.ToString() + @");&lt;br /&gt;        ";&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;Page&lt;/span&gt;.RegisterClientScriptBlock("Reconnect", str_Script);&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;/*************************************************************************/&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;This javascript method gets called 2 minutes before a Session timeout but it needs user attention and doesn't autoclose (render useless after timeout period expires) and log the user out.&lt;br /&gt;&lt;br /&gt;One way could be using Form Authentication in Asp.Net.&lt;br /&gt;&lt;br /&gt;Ideas welcome.&lt;br /&gt;&lt;br /&gt;P.S. &lt;br /&gt;&lt;br /&gt;javascript Script tages seems to be banned in blogger, while yahoo 360 blogs allow it. ;)&lt;br /&gt;&lt;br /&gt;I think applying HtmlEncode()  solves the security and page beaking issue. I think that what nneeds to be done whenever projects which use FCKeditor have to do in order to allow users to create text with html tags in it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115603001200300099?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115603001200300099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115603001200300099' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115603001200300099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115603001200300099'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/08/aspnet-session-timeout-about-to-happen_19.html' title='Asp.Net Session timeout about to happen Warning?'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115602204989435724</id><published>2006-08-19T16:07:00.000-05:00</published><updated>2006-08-19T16:17:40.286-05:00</updated><title type='text'>ASP.NET Custom Error Pages</title><content type='html'>I came across this article about ASP.NET custom error pages while trying to trap exceptions before the user sees them. I needed to implement a global exception handler plus a way to redirect the user to a generic error page in case of uncaught exceptions.&lt;br /&gt;&lt;br /&gt;http://www.aspnetresources.com/articles/CustomErrorPages.aspx&lt;br /&gt;&lt;br /&gt;This helped in trapping uncaught application, Page exceptions&lt;br /&gt;&lt;br /&gt;Point to Note&lt;span style="font-family:monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    ctx.Server.ClearError();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:monospace;"&gt;&lt;br /&gt;&lt;/span&gt;should be commented in&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;    global.asax&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    OnError event of base page&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;in case we want the user to be redirected to a custom error page as set in web.config&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115602204989435724?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115602204989435724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115602204989435724' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115602204989435724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115602204989435724'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/08/aspnet-custom-error-pages.html' title='ASP.NET Custom Error Pages'/><author><name>K</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-32465434.post-115514476666887478</id><published>2006-08-09T12:32:00.000-05:00</published><updated>2006-08-09T12:44:48.810-05:00</updated><title type='text'>Test</title><content type='html'>Test Post. Nothing here to see.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/32465434-115514476666887478?l=codeluck.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeluck.blogspot.com/feeds/115514476666887478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=32465434&amp;postID=115514476666887478' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115514476666887478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/32465434/posts/default/115514476666887478'/><link rel='alternate' type='text/html' href='http://codeluck.blogspot.com/2006/08/test.html' title='Test'/><author><name>Alexis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
