tag:blogger.com,1999:blog-66058842009-02-21T00:46:29.603-05:00jedatu: The BlogAnytime I discover an important code tip I will record it here. I have decided that this will be a generic blog and not focus on any particular language or technology, however, most of my development will involve ASP.NET, VB.NET, C#.NET, SQL Server, and Macromedia Flashjedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.comBlogger27125tag:blogger.com,1999:blog-6605884.post-37162272603307839842008-05-07T13:39:00.005-04:002008-05-07T14:15:05.616-04:00RC4 encryption for classic ASP stops workingThis was an interesting gotcha which I'd like to blame on Visual Studio 2008, but it is undeserved.<br /><br />Microsoft <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=290845" title="Bug report">dropped support for Intellisense and color-coding for classic ASP</a> in Visual Studio 2008, but I still use it to maintain some old sites.<br /><br />Well, after some minor changes to an old site, suddenly, the <a href="http://www.4guysfromrolla.com/ASPScripts/PrintPage.asp?REF=%2Fwebtech%2F010100-1.shtml" title="Code by Mike Shaffer">RC4 encryption code, by Mike Shaffer,</a> that I was using didn't work any more. The answer really surprised me.<br /><br />To make a LONG story short, I opened the site in VS08 and created a new include file for a page I was modifying. I included the file into the primary page and that caused the RC4 code to stop producing the correct output.<br /><br />Visual Studio 2008 created the new include file using UTF-8 encoding. Well, for some reason that broke the RC4 encryption code. I guess it's because each character would be 2 bytes instead of 1? I thought that was just Unicode and classic ASP won't even process a Unicode file (<a href="http://support.microsoft.com/kb/245000" title="Knowledge base article">UNICODE ASP files are not supported</a>). I don't know.<br /><br />My resolution was to make sure the classic ASP page and all its includes were saved as ANSI text. Here <a href="http://notepad-plus.sourceforge.net/uk/site.htm" title="Project page">Notepad++</a> (Menu > Format > Encode in ANSI) came in very handy again.<br /><br />Maybe someday I will understand <a href="http://www.joelonsoftware.com/articles/Unicode.html" title="Joel Spolsky Article">The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character</a>. Scott Hanselman also has an interesting post on the <a href="http://www.hanselman.com/blog/InternationalizationAndClassicASP.aspx" title="Blog Post">CodePage versus the CharSet</a> in classic ASP.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-3716227260330783984?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-83805674115066844082008-05-07T12:48:00.011-04:002008-05-12T14:47:51.697-04:00Microsoft Drops Classic ASP Support in Visual Studio 2008I upgraded to Visual Studio 2008 as soon as it came out. I was tempted to get rid of Visual Studio 2005 since VS08 had <a href="http://weblogs.asp.net/scottgu/archive/2007/06/20/vs-2008-multi-targeting-support.aspx" title="Scott Gutherie Post">multi-targeting</a> support and I assumed that the new Visual Studio had all the functionality of previous versions. Well, I was wrong.<br /><br />For better or worse, I still have to support some Classic ASP and VBScript code, well <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=290845" title="Bug report">Microsoft dropped Intellisense and color-coding for classic ASP</a>. Recommended solution: Keep my 2.5 GB install of VS05 around for those days when you need it.<br /><br />I can't believe it myself. How detrimental or hard was it to maintain even just basic syntax highlighting? Even an open source product like <a href="http://notepad-plus.sourceforge.net/uk/site.htm" title="Project page">Notepad++</a> offers that. Wow.<br /><br />I recently found another gotcha which I will include in another post.<br /><br />UDPATE [5/12/2008]: Looks like <a href="http://is.gd/frr" title="Scott Guthrie Post">VS08 SP1</a> will bring back support for classic ASP. Cool!<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-8380567411506684408?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-84729600560054717662008-01-18T13:49:00.000-05:002008-01-18T14:31:47.711-05:00HttpFileCollection Always ZeroI ran into and interesting problem recently trying to get an AJAX style file upload working with an HttpHandler. The HttpFileCollection (Request.Files) was always empty with a count of zero. <br /><pre>(Request.Files == 0) == true</pre><br />I was using the <a href="http://www.phpletter.com/Demo/AjaxFileUpload-Demo/">AjaxFileUpload</a>, a <a href="http://www.jquery.com/">jQuery</a> plug-in intended to be paired with PHP, but compatible with any server side handler. Since I use ASP.NET, I wrote an HttpHandler to receive the form post, save the file on the server, and send a JSON response.<br /><br />Without investigating too closely, it looks like the AjaxFileUpload creates an iframe, moves the html file input into the iframe and submits it to specified handler. I didn't want to user "runat='server'" controls so I just put a plain html input tag in the page like so.<br /><pre name="code" class="html"><br />&lt;input type="file" id="AjaxFileInput" /&gt;<br /></pre><br />I ran my project and everything seemed to be working and submitting, fine, but the HttpFileCollection always had a count of 0. <br /><br />I created a simple page with no ajax that posted back to itself to test the plain HTML inputs, and the Request.Files collection was still empty. I tried adding the "runat='server'" attribute and it suddenly worked, of course. I didn't want to user server controls, because I wanted to add new inputs as needed with client script. <br /><br />It seemed like the Request.Files collection would only be populated if I used the ASP.NET server controls, but I could not think of any reason why. Finally, I looked at the code rendered by the server controls and discovered the answer. <br /><br />Every site I found said there were 2 things you needed to get the HttpFileCollection to populate.<br /><br />1) Make sure the form method is "POST"<br />2) Make sure the form enctype is "multipart/form-data"<br /><br />The AjaxFileUpload code dutifully had this right, however there is one more thing that ASP.NET needs.<br /><br />3) The HTML file input must have a "name" attribute.<br /><br />Here is a final sample of an accurately constructed plain HTML form that will populate the Request.Files collection.<br /><pre name="code" class="html"><br />&lt;form&nbsp;action=&quot;&quot;&nbsp;method=&quot;POST&quot;&nbsp;name=&quot;form1&quot;&nbsp;id=&quot;form1&quot;&nbsp;enctype=&quot;multipart/form-data&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;input&nbsp;type=&quot;file&quot;&nbsp;id=&quot;AjaxFileInput&quot;&nbsp;name=&quot;AjaxFileInput&quot;&nbsp;/&gt;<br />&lt;/form&gt;<br /></pre><br /><br />This seems like a bug, to me, and I don't know if .NET 3.0-5 fixes this. This <a href="http://msdn2.microsoft.com/en-us/library/aa478971.aspx">document</a> does not reflect what I have found to be true.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-8472960056005471766?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-12071965769946186122007-10-31T09:55:00.000-04:002007-11-10T11:08:11.772-05:00Print Page from IE without PromptThis code should send a page straight to the printer without prompting the user. It worked in IE6, but I don't know about IE7. I am sure there are some security concerns with it.<br /><br /><pre name="code" class="html:collapse"><br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;script&nbsp;language="javascript"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;ieExecWB(intOLEcmd,&nbsp;intOLEparam)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;WebBrowser&nbsp;=&nbsp;'&lt;OBJECT&nbsp;ID="PrintBrowser"&nbsp;WIDTH=0&nbsp;HEIGHT=0&nbsp;CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"&gt;&lt;/OBJECT&gt;';<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.body.insertAdjacentHTML('beforeEnd',&nbsp;WebBrowser);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;(&nbsp;!&nbsp;intOLEparam&nbsp;)&nbsp;||&nbsp;(&nbsp;intOLEparam&nbsp;&lt;&nbsp;-1&nbsp;)&nbsp;&nbsp;||&nbsp;(&nbsp;intOLEparam&nbsp;&gt;&nbsp;1&nbsp;)&nbsp;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;intOLEparam&nbsp;=&nbsp;1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PrintBrowser.ExecWB(intOLEcmd,&nbsp;intOLEparam);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PrintBrowser.outerHTML&nbsp;=&nbsp;"";<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&lt;/script&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br /><br />&lt;p&gt;&lt;a&nbsp;href="javascript:ieExecWB(6,&nbsp;-1);"&gt;print&lt;/a&gt;&lt;/p&gt;<br /><br />&lt;/body&gt;<br />&lt;/html&gt;<br /></pre><br />NOTE: I don't know where I found this code so if someone needs attribution or it violates a copyright or something, let me know.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-1207196576994618612?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-3528234460192670502007-08-11T11:48:00.000-04:002007-11-10T11:23:53.823-05:00Optional Radio ButtonsIt has always bugged me that you can't really make radio buttons optional on web form. You can load all the radio buttons in a group as un-checked, but as soon as the user selects one then a value from that check box group will be submitted.<br /><br />You can get around this problem by adding one option to the group and labeling it "N/A" or something. This gives the user an out. Incredibly, I have never been able to convince any of my customers to go that route. In fact, even if the radio group is required they will want the all of the options unchecked initially.<br /><br />Most people get around this by writing their own logic over check boxes, but I decided to take a different approach. I finally wrote some JavaScript which will un-check a radio button if the button you click is already checked, thus allowing the user an escape route.<br /><br /><pre id="A-20070811" name="code" class="javascript"><br />function RadioClick(radio)<br />{<br /> var inputs = document.getElementsByTagName("input");<br /> var checked = (radio.getAttribute("shadow") == "true");<br /> for(var i = 0; i &lt; inputs.length; i++)<br /> {<br /> if (inputs[i].getAttribute("type") == "radio" && inputs[i].name == radio.name)<br /> {<br /> inputs[i].setAttribute("shadow", "false");<br /> }<br /> }<br /> if (checked)<br /> {<br /> radio.checked = false;<br /> }<br /> else<br /> {<br /> radio.setAttribute("shadow", "true");<br /> }<br />}<br /></pre><br /><br />All you have to do is add this script to your page and then just add "RadioClick" to the radio button's onClick event, like so...<br /><br /><pre id="B-20070811" name="code" class="html"><br />&lt;input id="ctl01" type="radio" name="GroupName" value="ctl01" <br /> checked="checked" onclick="javascript:RadioClick(this);" /&gt;<br /></pre><br /><br />You could easily make this script unobtrusive by adding a method that assigns onClick event by group name when the page loads.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-352823446019267050?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1160774127463469832006-10-13T17:03:00.000-04:002006-10-13T17:15:27.503-04:00DataFormatString Doesn't WorkI think this might be old news, but it was new to me. If you are using a GridView (and potentially any DataBoundColumn) and you take advantage of the DataFormatString you will be in for a surprise--it may not work.<br /><br />[<a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101998">Here is the "bug" report</a>]<br /><br />You must also set the HtmlEncode attribute to false. The explanation in the bug report doesn't make sense to me though. So what if the bound value is HTML encoded. Can't the format string still be applied? I guess if the datatype is changed to string then special format strings like "{0:C}" for currency or "{0:MM/dd/YYYY}" for DateTime won't work.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-116077412746346983?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1157571501176907112006-09-06T15:19:00.000-04:002006-09-06T15:38:21.206-04:00Generic HttpContext Singleton<p>Joel Ross has an interesting <a href="http://www.rosscode.com/blog/index.php?title=the_singleton_pattern_asp_net_and_more&more=1&amp;c=1&tb=1&amp;pb=1">post</a> about implementing the <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a> for objects used during the lifecycle of a web request.</p><p>This got me thinking about the <a href="http://www.codeproject.com/csharp/GenericSingleton.asp">Generic</a> singleton implementation that I have used before. I wondered if you could combine the two to make a Generic HttpContext singleton. Here is my first attempt. I think it should work, but I have not tried it.</p><p>I guess the key is the "key". It may be better to use the fully qualified class name for the key instead of just using the generic type's name. It may also make sense to add a "Singleton_" prefix to the name to give it a namespace within the HttpContext.</p><br /><div style="font-family: Courier New; font-size: 8pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;1</span>&nbsp;<span style="color: blue;">using</span> System;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;<span style="color: blue;">using</span> System.Collections.Generic;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;<span style="color: blue;">using</span> System.Web;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;<span style="color: blue;">using</span> System.Runtime.Serialization;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;<span style="color: blue;">namespace</span> jedatu</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;{</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">class</span> ContextSingleton&lt;T&gt; where T : ISerializable, <span style="color: blue;">new</span>()</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;&nbsp;&nbsp;&nbsp; {</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;10</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">protected</span> ContextSingleton() { }</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;11</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;12</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">static</span> T Instance</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;13</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;14</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">get</span> { <span style="color: blue;">return</span> Factory.Current.Instance; }</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;15</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;16</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;17</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">private</span> <span style="color: blue;">class</span> Factory</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;18</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;19</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">static</span> Factory() { }</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;20</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;21</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">internal</span> <span style="color: blue;">static</span> Factory Current = <span style="color: blue;">new</span> Factory();</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;22</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;23</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">internal</span> <span style="color: blue;">static</span> <span style="color: blue;">readonly</span> T _instance = <span style="color: blue;">new</span> T();</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;24</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;25</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">internal</span> T Instance</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;26</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;27</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">get</span></p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;28</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;29</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">if</span> (HttpContext.Current == <span style="color: blue;">null</span>) { <span style="color: blue;">return</span> <span style="color: blue;">null</span>; }</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;30</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">if</span> (HttpContext.Current.Items[_instance.GetType().Name] == <span style="color: blue;">null</span>)</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;31</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;32</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; HttpContext.Current.Items[_instance.GetType().Name] = _instance;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;33</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;34</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> (T)HttpContext.Current.Items[_instance.GetType().Name];</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;35</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;36</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;37</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;38</span>&nbsp;&nbsp;&nbsp;&nbsp; }</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;39</span>&nbsp;}</p></div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-115757150117690711?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1154551648127006002006-08-02T16:33:00.000-04:002006-08-03T00:54:04.266-04:00PowerShell Baby Step: Change File AttributesI really think there is a lot of potential wrapped up in <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=2B0BBFCD-0797-4083-A817-5E6A054A85C9&displaylang=en">PowerShell</a>, but since I have rarely used Linux and rarely write batch files, I have hard time getting my head around how to use PowerShell.<br /><br />I do know that I hate the limitations of batch files and have thought about using <a href="http://tryruby.hobix.com/">Ruby</a> and now PowerShell instead. I installed <a href="http://secretgeek.net/shinypower.asp">ShinyPower</a> to help me navigate the PowerShell help. I read some <a href="http://del.icio.us/powershell">tutorials</a>. Gradually, I was getting ready to do something.<br /><br />Well, today I finally wrote my first PowerShell code and this is why.<br /><br />I use a fantastic program called <a href="http://timesnapper.com/">TimeSnapper</a>. It saves an image of my screen at a pre-determined interval--in my case every 5 minutes. This helps me keep track of what I have been working on. Well, I copied the image files to a new location and the CreateDate changed. This meant that TimeSnapper thought all the images were captured at the same time each day. Ugh. Then I thought, "this sounds like a job for PowerShell"<br /><br />After a little exploration I came up with a script to fix the problem with the files.<br /><br /><span style="color: rgb(255, 0, 0);font-family:courier new;" > ls | foreach { $_.CreationTime = $_.LastWriteTime }</span><br /><br />Breakdown:<br />Step1 [ <span style="color: rgb(255, 0, 0);">ls </span>] Call the ls alias to list the files in a given directory.<br />Step2 [ <span style="color: rgb(255, 0, 0);">|</span> ] Pipe the resulting list of FileObjectInfo objects to a for each statement<br />Step3 [ <span style="color: rgb(255, 0, 0);">foreach {</span> ] Begin the for each<br />Step4 [ <span style="color: rgb(255, 0, 0);">$_</span> ] Reference the current object in the collection<br />Step5 [ <span style="color: rgb(255, 0, 0);">.CreationTime = $_.LastWriteTime</span> ] Set the CreationTime equal to the LastWriteTime<br />Step6 [ <span style="color: rgb(255, 0, 0);">}</span> ] End the for each<br /><br />In the end, it's a pretty simple one-line script, but it helped me make some progress understanding the PowerShell syntax.<br /><br />Here's some other cool PowerShell tricks. <a href="http://blogs.msdn.com/powershell/archive/2006/08/02/JoelOnSoftware_on_the_power_of_a_good_language.aspx">"Can your programming language do this?"</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-115455164812700600?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1143171950431342572006-03-23T22:22:00.000-05:002006-03-25T01:15:55.020-05:00For site maintenance consider app_offline.htmIf you are making updates to your site and want to keep the users at bay with a polite notice then look no futher than the app_offline.htm file.<br /><br />Create an HTML file called app_offline.htm, drop it in the root directory of your web, and your site will be offline with style.<br /><br />Very early in the request cycle, ASP.NET 2.0 looks for the app_offline.htm file. If the file exists, ASP.NET stop processing requests for that application, unload it, and route all incoming requests to the app_offline.htm where your custom message awaits.<br /><br />One handy side effect is the fact that this releases any locked resources such as databases in the app_data directory.<br /><br />When finished, delete or even rename the app_offline.htm file to return users to their regularly scheduled browsing.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-114317195043134257?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1142081904263729262006-03-11T07:56:00.000-05:002006-03-11T08:21:26.860-05:00ASP.NET 2.0 Page Lifecycle<p>It seems like I am always looking this up so here it is.</p><p><b>Table 1. Page Lifecycle methods</b></p><table style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; WIDTH: 400px; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid" cellspacing="0" cellpadding="3" border="1"><tbody><tr valign="top"><th align="left">Method</th><th align="left">Active</th></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>Constructor</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>Construct</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>TestDeviceFilter</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>AddParsedSubObject</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>DeterminePostBackMode</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>OnPreInit</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>LoadPersonalizationData</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>InitializeThemes</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>OnInit</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>ApplyControlSkin</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>ApplyPersonalization</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>OnInitComplete</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>LoadPageStateFromPersistenceMedium</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">PostBack</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>LoadControlState</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">PostBack</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>LoadViewState</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">PostBack</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>ProcessPostData1</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">PostBack</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>OnPreLoad</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>OnLoad</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>ProcessPostData2</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">PostBack</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>RaiseChangedEvents</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">PostBack</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>RaisePostBackEvent</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">PostBack</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>OnLoadComplete</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>OnPreRender</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>OnPreRenderComplete</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>SavePersonalizationData</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>SaveControlState</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>SaveViewState</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>SavePageStateToPersistenceMedium</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>Render</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr><tr valign="top"><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid"><b>OnUnload</b></td><td style="BORDER-RIGHT: #cfcfcf 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #cfcfcf 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 10px; PADDING-BOTTOM: 3px; BORDER-LEFT: #cfcfcf 1px solid; PADDING-TOP: 3px; BORDER-BOTTOM: #cfcfcf 1px solid">Always</td></tr></tbody></table><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-114208190426372926?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1141164177221916372006-02-28T16:43:00.000-05:002006-03-10T03:20:06.466-05:00Full Text Index Required for Some FunctionsIf you use SQL scripts to create and modify your SQL Server 2000 databases, you may at some point run into a problem. Full-text search functions are only available when a full text catalog exists for the table you are querying.<br /><br />Since my install scripts are automated I wanted a way to conditionally install one of two versions of the same function. The solution was to use a special metadata function along with the EXEC command to create the function.<br /><br /><code><br /><div style="font-family: Courier New; font-size: 8pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;1</span>&nbsp;<span style="color: blue;">IF </span>(<span style="color: blue;">SELECT </span>fulltextcatalogproperty('MyFullTextCatalog', 'ItemCount')) <span style="color: blue;">IS NULL</span></p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;<span style="color: blue;">BEGIN</span></p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;<span style="color: blue;">EXEC</span>('</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;&nbsp;&nbsp;&nbsp; CREATE FUNCTION [dbo].[udf_MySearchFunction]</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;&nbsp;&nbsp;&nbsp; (</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; @criteria AS VARCHAR(200)</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;&nbsp;&nbsp;&nbsp; )</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;&nbsp;&nbsp;&nbsp; RETURNS @retTable</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;10</span>&nbsp;&nbsp;&nbsp;&nbsp; TABLE</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;11</span>&nbsp;&nbsp;&nbsp;&nbsp; (</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;12</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [seqid] [int] IDENTITY (1, 1) NOT NULL</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;13</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ,[resultid] [int] NOT NULL</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;14</span>&nbsp;&nbsp;&nbsp;&nbsp; )</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;15</span>&nbsp;&nbsp;&nbsp;&nbsp; AS</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;16</span>&nbsp;&nbsp;&nbsp;&nbsp; BEGIN</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;17</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;18</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; INSERT INTO @retTable</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;19</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SELECT [resultid]</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;20</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FROM [MyTable]</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;21</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHERE</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;22</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [Description] LIKE '%' + @criteria + '%'</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;23</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; OR [Keywords] LIKE '%' + @criteria + '%'</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;24</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;25</span>&nbsp;&nbsp;&nbsp;&nbsp; END</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;26</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;27</span>&nbsp;&nbsp;&nbsp;&nbsp; RETURN')</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;28</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;29</span>&nbsp;<span style="color: blue;">END</span></p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;30</span>&nbsp;<span style="color: blue;">ELSE</span></p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;31</span>&nbsp;<span style="color: blue;">BEGIN</span></p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;32</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;33</span>&nbsp;<span style="color: blue;">EXEC</span>('</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;34</span>&nbsp;&nbsp;&nbsp;&nbsp; CREATE FUNCTION [dbo].[udf_MySearchFunction]</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;35</span>&nbsp;&nbsp;&nbsp;&nbsp; (</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;36</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; @criteria AS VARCHAR(200)</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;37</span>&nbsp;&nbsp;&nbsp;&nbsp; )</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;38</span>&nbsp;&nbsp;&nbsp;&nbsp; RETURNS @retTable</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;39</span>&nbsp;&nbsp;&nbsp;&nbsp; TABLE</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;40</span>&nbsp;&nbsp;&nbsp;&nbsp; (</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;41</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [seqid] [int] IDENTITY (1, 1) NOT NULL ,</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;42</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [resultid] [int] NOT NULL</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;43</span>&nbsp;&nbsp;&nbsp;&nbsp; )</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;44</span>&nbsp;&nbsp;&nbsp;&nbsp; AS</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;45</span>&nbsp;&nbsp;&nbsp;&nbsp; BEGIN</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;46</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;47</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; INSERT INTO @retTable</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;48</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SELECT [resultid]</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;49</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; FROM [MyTable]</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;50</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHERE FREETEXT([MyTable].*, @criteria)</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;51</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;52</span>&nbsp;&nbsp;&nbsp;&nbsp; END</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;53</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;54</span>&nbsp;&nbsp;&nbsp;&nbsp; RETURN')</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;55</span>&nbsp;</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;56</span>&nbsp;<span style="color: blue;">END</span></p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;57</span>&nbsp;GO</p></div><br /></code><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-114116417722191637?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1133982128176652442005-12-07T13:58:00.000-05:002006-03-04T00:54:33.206-05:00Default AspNetSqlMembershipProvider Connection StringIn case you are wondering how your ASP.NET 2.0 web application connects to the default membership data store, it uses the following default connection string.<br /><code><br />data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true<br /></code><br />In the ASP.NET configuration under the IIS properties, the AspNetSqlMembershipProvider points to the LocalSqlServer connection string which is italicized under connection strings, which means it is inherited.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-113398212817665244?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1133981897659602412005-12-07T13:30:00.000-05:002006-03-04T00:58:11.770-05:00Enable ASP.NETWebAdminFiles Outside Visual StudioUsing the default ASP.NET 2.0 Membership (AspNetSqlMembershipProvider) you can modify config settings and add/remove users from the Visual Studio IDE if you are running it locally or FrontPage Server Extensions are installed and you are connected remotely to the site.<br /><br />If you want to use the ASP.NetWebAdminFiles web interface without Visual Studio, as I recently did, then here is what you do.<br /><br />FYI: Only do this if you are careful and for the right purposes, since you are exposing some administration capability.<br /><br />1. Create a virtual directory that points to the web admin files.<br /><br />This is what I did:<br />VirtualDirectory: ASP.NetWebAdminFiles<br />MappedTo: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles<br /><br />2. Modify the properties of the virtual directory so that it is running under ASP.NET 2.0. (Properties > ASP.NET)<br /><br />NOTE: if you are running 1.1 and 2.0 applications on the same server or site, you may have to set up a separate application pool for the 2.0 sites. If you get the notice, "Application Unavailable" then that is why.<br /><br />3. While you are there, remove anonymous access to that virtual directory.<br /><br />4. After that, you will be able to connect to the web admin tools using the following url syntax<br /><br />http://localhost/ASP.NETWebAdminFiles/default.aspx?applicationPhysicalPath=XXX&applicationUrl=/YYY<br /><br />in my case, it is:<br />http://localhost/ASP.NETWebAdminFiles/default.aspx?applicationPhysicalPath=C:\inetpub\wwwroot\myapp\&applicationUrl=/myapp<br /><br />NOTE: Although it isn't recommended, if you want to access web admin tool from a different/remote computer, then open the WebAdminPage.cs file from the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles\App_Code directory and comment the following code block:<br /><br /><div style="font-family: Courier New; font-size: 8pt; color: black; background: white; border-top: windowtext 1pt solid; padding-top: 0pt; border-left: windowtext 1pt solid; padding-left: 0pt; border-right: windowtext 1pt solid; padding-right: 0pt; border-bottom: windowtext 1pt solid; padding-bottom: 0pt;"><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;1</span>&nbsp;<span style="color: blue;">if</span> (!application.Context.Request.IsLocal) </p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;2</span>&nbsp;{</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;3</span>&nbsp;&nbsp;&nbsp;&nbsp; SecurityException securityException = </p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;4</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="color: blue;">new</span> SecurityException((<span style="color: blue;">string</span>)HttpContext.GetGlobalResourceObject(</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;5</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "GlobalResources", </p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;6</span>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; "WebAdmin_ConfigurationIsLocalOnly"));</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;7</span>&nbsp;&nbsp;&nbsp;&nbsp; WebAdminPage.SetCurrentException(application.Context, securityException);</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;8</span>&nbsp;&nbsp;&nbsp;&nbsp; application.Server.Transfer("~/error.aspx");</p><p style="margin: 0px;"><span style="color: teal;">&nbsp;&nbsp;&nbsp;&nbsp;9</span>&nbsp;}</p></div><br />The web admin tool will still be protected to some degree by the Integrated Windows Authentication.<br /><br />NOTE: If while trying to update user information you get the following error:<br /><br />Failed to update database "C:\inetpub\wwwroot\myapp\App_Data\ASPNETDB.MDF" because the database is read-only. <br /><br />Then the NETWORK_SERVICE account does not have read/write access to the MDF file that is being used to store the user information.<br /><br />http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=dd6d161b-df08-40bc-b9ed-fbca71949ddc<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-113398189765960241?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1101749905453995232004-11-29T12:38:00.000-05:002004-11-29T12:38:25.453-05:00Implementing Group By in XSLTIn order to group nodes in XSLT you need to create a key that will represent a common attribute for the nodes in a group. <br /> <br />Here is the code to do that. I always put this code in the root stylesheet node. This, may or may not be manadatory. <br /> <br /><code> <br />&lt;xsl:key name="newgroupkey" <br /> match="//nodeToGroup" <br /> use="@groupingAttribute"/&gt; <br /></code> <br /> <br />Next, you simply select a node group by using the generate-id() function and comparing it to the group key. Notice the reference to the first member of the array of nodes returned "[1]". The key comparison returns all members of each group so you need to select the first member of each node group in order to achieve the desired result. <br /> <br /><code> <br />&lt;xsl:for-each select="//nodeToGroup[generate-id()=generate-id(key('newgroupkey',@groupingAttribute)<strong>[1]</strong>)]"&gt; <br /> &lt;xsl:sort data-type="number" order="ascending" select="@groupingAttribute" /&gt; <br /> &lt;xsl:apply-templates select="." /&gt; <br />&lt;/xsl:for-each&gt; <br /></code> <br /> <br />When you "apply-templates" to the selected node, you can use the @groupingAttribute to collect all the corresponding nodes in the same group for processing. <br /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-110174990545399523?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1100881305999548822004-11-19T11:21:00.000-05:002004-11-19T11:21:46.000-05:00Fairly Precise HTML LayoutIn order to get my page layouts as close to my desired dimensions on the first try as possible I ran an experiment using IE and an HP printer, which is my typical environment, to find out what the ratio of Pixels to Inches is in this case. <br /> <br />I came up with approximately 95px per inch; 23px per .25 (1/4) inch; or a ratio of 5.9px per .0625 (1/16th) inches. This is good enough to get me close. <br /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-110088130599954882?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1095861489914131762004-09-22T09:58:00.000-04:002004-09-22T10:44:41.333-04:00Defining Entities in XsltI am always forgetting how to define entities in xslt stylesheets. Here is a simple sample. <br /><code> <br />&lt;!DOCTYPE xsl:stylesheet [ <br />&lt;!ENTITY nbsp '&amp;#160;'&gt; <br />]&gt; <br /></code> <br />This is particularly relevant when trying to insert a non-breaking space with xslt--a particularly esoteric task. I have heard that setting the output to ASCII instead of UTF-8 will ensure that the above non-breaking space is included in the output. I believe &amp;#A0; is the unicode character. <br /><code> <br />&lt;xsl:output method="html" encoding="ASCII" omit-xml-declaration="no" version="4.0" /&gt; <br /></code> <br />Another option is this apparently, though I have heard it is not predictable. <br /><code> <br />&lt;xsl:text&gt;&amp;amp;#160;&lt;/xsl:text&gt; <br /></code> <br /> <br /> <br /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-109586148991413176?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1095275317980824032004-09-15T15:08:00.000-04:002004-09-15T15:31:01.860-04:00Comparing and Replacing Strings with XslI found a nice function for replacing strings in Xml using Xsl. <br /> <br />As I am sure you know, the Translate function in Xsl does not replace full strings instead it replaces characters. <br /> <br />The following recursive template provides the "missing" functionality. <br /><code> <br />&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt; <br /> &lt;xsl:output method="xml" omit-xml-declaration="yes" /&gt; <br /> &lt;xsl:template name="globalReplace"&gt; <br /> &lt;xsl:param name="outputString" /&gt; <br /> &lt;xsl:param name="target" /&gt; <br /> &lt;xsl:param name="replacement" /&gt; <br /> &lt;xsl:choose&gt; <br /> &lt;xsl:when test="contains($outputString,$target)"&gt; <br /> &lt;xsl:value-of select="concat(substring-before($outputString,$target),$replacement)" /&gt; <br /> &lt;xsl:call-template name="globalReplace"&gt; <br /> &lt;xsl:with-param name="outputString" select="substring-after($outputString,$target)" /&gt; <br /> &lt;xsl:with-param name="target" select="$target" /&gt; <br /> &lt;xsl:with-param name="replacement" select="$replacement" /&gt; <br /> &lt;/xsl:call-template&gt; <br /> &lt;/xsl:when&gt; <br /> &lt;xsl:otherwise&gt; <br /> &lt;xsl:value-of select="$outputString" /&gt; <br /> &lt;/xsl:otherwise&gt; <br /> &lt;/xsl:choose&gt; <br /> &lt;/xsl:template&gt; <br /> &lt;xsl:template match="text()"&gt; <br /> &lt;xsl:call-template name="globalReplace"&gt; <br /> &lt;xsl:with-param name="outputString" select="." /&gt; <br /> &lt;xsl:with-param name="target" select="'finish'" /&gt; <br /> &lt;xsl:with-param name="replacement" select="'FINISH'" /&gt; <br /> &lt;/xsl:call-template&gt; <br /> &lt;/xsl:template&gt; <br /> &lt;xsl:template match="@*|*"&gt; <br /> &lt;xsl:copy&gt; <br /> &lt;xsl:apply-templates select="@*|node()" /&gt; <br /> &lt;/xsl:copy&gt; <br /> &lt;/xsl:template&gt; <br />&lt;/xsl:stylesheet&gt; <br /></code> <br /> <br />See link for more information. <br /><a href="http://www.xml.com/pub/a/2002/06/05/transforming.html">xml.com</a> <br /> <br /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-109527531798082403?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1093525971547639492004-08-26T09:12:00.000-04:002004-08-26T09:12:51.546-04:00Backup and Restore WindowsXP Activation FilesHave you ever wanted to reformat the hard disk and reinstall Windows XP <br />on a system but you didn't want to mess around with Microsoft's Product <br />Activation after the reinstall? Fortunately, you don't have to. <br /> <br />As long as you aren't making any hardware alterations, you can back up <br />the activation status files before you reformat the hard drive and then <br />restore them after you reinstall the operating system. <br /> <br />To perform the backup, follow these steps: <br /> <br />1. Use Windows Explorer to open the C:\Windows\System32 folder. <br />2. Copy the Wpa.dbl and Wpa.bak files to a floppy disk or CD. <br /> <br />To perform the restore, follow these steps: <br /> <br />1. Decline the activation request at the end of the installation <br />procedure, and restart Windows XP. <br />2. During bootup, press [F8] to access the Windows Advanced Options <br />menu. <br />3. Choose the Safe Mode (SAFEBOOT_OPTION=Minimal) option. <br />4. Use Windows Explorer to open the C:\Windows\System32 folder. <br />5. If they exist, rename the new Wpa.dbl and Wpa.bak files to <br />Wpadbl.new and Wpabak.new. <br />6. Copy the original Wpa.dbl and Wpa.bak files from the floppy disk or <br />CD to the C:\Windows\System32 folder. <br />7. Restart the system. <br /> <br />I found this tip at <a href="http://www.techrepublic.com">Tech Republic</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-109352597154763949?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1091727067026199072004-08-05T13:31:00.000-04:002004-08-05T13:57:08.270-04:00ASP.NET FormsAuthenticationTicket and PersistenceIn order to persist an authentication ticket across browser sessions when using FormsAuthentication, you must set the Expires value in the authentication cookie to the Expiration value from the authentication ticket. Otherwise, the cookie will expire as soon as the browser is closed. <br /> <br />Here is the relevant line of code: <br /><code> <br />authenticationCookie.Expires = ticket.Expiration; <br /></code> <br />For more explanation see: <a href="http://blogs.msdn.com/tmeston/archive/2003/07/24/10505.aspx" target="_blank">FormsAuthenticationTicket and Persistence</a> <br /> <br /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-109172706702619907?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1091714856153554862004-08-05T10:07:00.000-04:002004-08-05T13:58:24.596-04:00Comparing Type Information in C#I am not sure this is the best way to do this, but it works for now. <br /><code> <br />Boolean result = MyObject.GetType().Equals(typeof(System.Web.UI.HtmlControls.HtmlForm)) <br /></code> <br />Basically you use the GetType method of an object and compare it to the another class using the typeof function which does not require an instatiated object, but simple the name of the class in question.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-109171485615355486?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1084203019807250592004-05-10T11:30:00.000-04:002004-05-10T11:33:06.013-04:00ASP.NET Validation in GroupsI thought this was a well-written <a href="http://www.codeproject.com/aspnet/groupvalidator.asp">article</a> on the subject and it contains a nice sequence of events for page validation. <br /><ul> <br /><li>Create page and control objects according to the aspx file </li> <br /><li>Recover state of the objects from viewstate </li> <br /><li>Update objects based on user input </li> <br /><li>Fire Page_Load event </li> <br /><li>Fire change notification events </li> <br /><li>Save object state in viewstate </li> <br /><li>Render HTML </li> <br /></ul> <br /><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-108420301980725059?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1080762032621393952004-03-31T14:40:00.000-05:002004-03-31T14:51:20.360-05:00Event handling in Flash ActionScriptUnderstanding the scope of variables, clips, etc. in Flash can be daunting. One instance that is particularly problematic is inside functions that are assigned as event handlers. It is problematic because inside the function you can't access external variables without using their absolute path. This is not convenient when build ActionScript classes. <br /> <br />To get around this you can create properties on the event handler which point to existing objects whose properties and methods may be useful within the handling function. <br /> <br />For instance, here is a function that calls a web service. The web service has an onResult event which fires when the response is received and parsed. However, the class which contains this function is not scoped inside the function that handles the onResult from the web service! In order to get around this, a parent property is assigned a reference to the instance of the class that contains the web service function. <br /><code> <br />//############################################################################ <br />//A class contains this method which calls a web service <br /> private function initSourceContext():Void { <br /> var wsc:WebService = new WebService(_webServiceUrl); <br />//Call the method on the WebService <br /> var res = wsc.getLocalID(); <br />//Assign this instance of the class to a new property on res result object <br />//so it is accessible in the onResult event <br /> res.parent = this; <br />//The onResult event fires when the WebService response data is <br />//received and parsed <br /> res.onResult = function(result) { <br />//Assign the result to a variable defined in the "parent" class <br /> res.parent._sourceContext = result; <br />//Broadcast an event on the "parent" class <br /> res.parent.raiseEvent("onWebServiceCalled"); <br /> }; <br />//The onFault fires if there was any trouble with the web service <br /> res.onFault = function(fault) { <br /> trace(fault.faultCode + "," + fault.faultstring); <br /> } <br /> } <br /></code><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-108076203262139395?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1080760843592984082004-03-31T14:20:00.000-05:002004-03-31T14:25:17.246-05:00Using the Tilde in URLsOne great feature about ASP.NET over classic ASP is the introduction of the Tilde for specifying directory paths. Instead of being limited to <br /> <br />absolute <br />"/mydir/includes/include.asp" <br />PROS: Same link works everywhere in the site. <br /> <br />and relative <br />"../../includes/include.asp" <br />PROS: Supports relative placement so sections of site can be moved across subdirectories without breaking the code. <br /> <br />Now there is the tilde which refers to the root of the current virtual directory. <br />"~/includes/include.asp" <br />PROS: Same link works everywhere in the virtual directory <br />AND: The application can be moved to a different virtual directory without breaking the code.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-108076084359298408?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1079469028455439762004-03-16T15:30:00.000-05:002004-03-16T15:33:45.326-05:00Generate a dot net key pairUse the following command to generate a key pair for signing assemblies and miscellaneous other things like assigning assembly permissions in the Microsoft .NET Framework Configuration. <br /> <br />sn -k MyFullKey.snk <br /> <br />This is where the Strong Name Tool was located on my computer: <br />C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\sn.exe <br /> <br />The Strong Name Tool has long list of options for extracting public keys, comparing assemblies, verifying signatures, etc. sn -h or sn -? will display the help.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-107946902845543976?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0tag:blogger.com,1999:blog-6605884.post-1079027599625849572004-03-11T12:53:00.000-05:002004-03-11T12:56:29.856-05:00ADO.NET performance tuningI was debugging a long-running page and thought the SQL was too complex. I checked the SP run time, and it seemed OK. I then started getting some error messages about timeouts and the connection pool being exhausted. The problem was that I was not closing the DataReader. I usually wouldn't even notice the problem (the reader is eventually closed anyway), but the statement was in a loop, so it was evident quite quickly. <br /> <br />I went through the code and made sure every ".Read()" was either in a using() statement or followed by a .Close. The page performance improved quite a bit (from timing out to less than 2 sec!), and the other pages are faster, too.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6605884-107902759962584957?l=www.jedatu.com%2Ftechblog'/></div>jedatuhttp://www.blogger.com/profile/06846193181122914812noreply@blogger.com0