<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='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' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-11321702</atom:id><lastBuildDate>Sun, 20 May 2012 06:07:14 +0000</lastBuildDate><category>C#</category><category>JQuery</category><category>Visual Studio</category><category>HttpHandler</category><category>SQL</category><category>Chrome</category><category>CSS</category><category>Technology</category><category>Javascript</category><category>TFS</category><category>FormsAuthentication</category><category>JQGrid</category><category>Software</category><category>AJAX</category><category>IE</category><category>JQuery UI</category><category>Routing</category><category>Windows</category><category>JSON</category><category>Macros</category><category>Android</category><category>ASP.net</category><title>Instance of an Object()</title><description>Instantiate your Solution</description><link>http://www.instanceofanobject.com/</link><managingEditor>noreply@blogger.com (Alexandre Simoes)</managingEditor><generator>Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-3109676015912765973</guid><pubDate>Sat, 24 Mar 2012 00:09:00 +0000</pubDate><atom:updated>2012-03-24T00:41:40.998Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Javascript</category><category domain='http://www.blogger.com/atom/ns#'>JSON</category><category domain='http://www.blogger.com/atom/ns#'>JQuery</category><category domain='http://www.blogger.com/atom/ns#'>ASP.net</category><category domain='http://www.blogger.com/atom/ns#'>AJAX</category><category domain='http://www.blogger.com/atom/ns#'>C#</category><title>Advanced Generic Handler ASHX</title><description>&lt;h2&gt;Introduction&lt;/h2&gt; &lt;p&gt;In ASP.net we have something that is usually overlloked that is called Generic Handlers.&lt;br /&gt;I see a lot o f people using pages to process AJAX requests when we can use this much less expensive endpont.&lt;br /&gt;This is an completelly worked out Generic Handler that trully knows how to handle your http (AJAX and not) requests. &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.alexcode.com/blogfiles/AdvancedGenericHandler/SampleCode.zip"&gt;Sample code&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Background&lt;/h2&gt; &lt;p&gt;For a long time I used plain Generic Handlers (ASHX files) to handle my AJAX requests but it felt stupid and painful.&lt;br /&gt;I mean, the functionality was there but the whole process of handling the requests wasn't straight forward.&lt;br /&gt;So I made a list of the things I would like to have on and handler: &lt;/p&gt;&lt;ul&gt; &lt;li&gt;Standard way to parse the query string&lt;/li&gt; &lt;li&gt;Transparently handle multiple methods within the same handler&lt;/li&gt; &lt;li&gt;Support methods with multiple typed arguments, not just strings&lt;/li&gt; &lt;li&gt;Support Methods that receive lists as an argument&lt;/li&gt; &lt;li&gt;Support passing less arguments than the method is expecting (like optional parameters)&lt;/li&gt; &lt;li&gt;Transparently reply eather POSTs or GETs&lt;/li&gt; &lt;li&gt;Support default object serialization to JSON but still let me override it on each method&lt;/li&gt; &lt;li&gt;Return application/json by default but still let me override it on each method&lt;/li&gt; &lt;li&gt;Support JQuery $.ajax request&lt;/li&gt; &lt;li&gt;Support request by query string (url right on the browser)&lt;/li&gt; &lt;li&gt;A way to visualize the methods the hadler supports (like webservices do)&lt;/li&gt; &lt;li&gt;Extensible&lt;/li&gt;&lt;/ul&gt;And that's it... &lt;br /&gt;I can tell you in advance that it already does all this and maybe more. &lt;p /&gt;  &lt;h2&gt;Using the code&lt;/h2&gt; &lt;h3&gt;List the Handler methods&lt;/h3&gt;&lt;p&gt;I've provided a very basic way of listing the methods the Handler exposes.&lt;br /&gt;This is specially useful to test if the handler is working correctly (like on webservices)&lt;br /&gt;Do do so just append &lt;em&gt;?help&lt;/em&gt; at the end of the handler URL: &lt;/p&gt;&lt;pre&gt;http://localhost/mydemohandler.ashx?help&lt;br /&gt;&lt;/pre&gt;  &lt;p /&gt;  &lt;h3&gt;Calling the Handler from the browser URL&lt;/h3&gt;&lt;p&gt;Using this handles is very simple: &lt;/p&gt;&lt;ol&gt; &lt;li&gt;Create a new Generic Handler&lt;/li&gt; &lt;li&gt;Clear everything inside the handler class&lt;/li&gt; &lt;li&gt;Inherit from my Handler class&lt;/li&gt; &lt;li&gt;DONE! Now you only need to add your methods.&lt;/li&gt;&lt;/ol&gt;&lt;p /&gt;  &lt;p&gt;Lets create a very simple example that receives a name and returns a string (see on the project).&lt;/p&gt; &lt;pre class="brush:csharp"&gt;   &lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Web;&lt;br /&gt;using App.Utilities.Web.Handlers;&lt;br /&gt;&lt;br /&gt;namespace CodeProject.GenericHandler&lt;br /&gt;{&lt;br /&gt; public class MyFirstHandler : BaseHandler&lt;br /&gt; {&lt;br /&gt;  // I don't bother specifying the return type, it'll be serialized anyway&lt;br /&gt;  public object GreetMe(string name) &lt;br /&gt;  {&lt;br /&gt;   return string.Format(&amp;quot;Hello {0}!&amp;quot;, name);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt; &lt;/pre&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;To call this method through a URL use:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;MyFirstHandler.ashx?method=GreetMe&amp;amp;name=AlexCode&lt;/pre&gt;&lt;p /&gt;  &lt;h3&gt;AJAX Request using JQuery&lt;/h3&gt;&lt;p&gt;If you want to use JQuery AJAX method you just need to know the object the handler is expecting to get.&lt;br /&gt;On the &lt;em&gt;data&lt;/em&gt; property of the $.ajax request you must pass something like: &lt;/p&gt;&lt;pre&gt;{ method: 'The method you want to call', args: { the arguments to pass } }&lt;/pre&gt;Be aware that everything is case sensitive! &lt;pre class="brush:javascript"&gt;$.ajax({&lt;br /&gt; url: 'MyFirstHandler.ashx',&lt;br /&gt; type: 'GET',&lt;br /&gt; data: { method: 'GreetMe', args: { name: 'AlexCode'} },&lt;br /&gt; success: function (data) {&lt;br /&gt;  alert(data);&lt;br /&gt; }&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;p /&gt;  &lt;h3&gt;Writing a method that returns HTML&lt;/h3&gt;&lt;p&gt;Like I said on my intention points above, I need to have some methods that return whatever I want like HTML, XML, images, files, etc...&lt;br /&gt;The default behavior of the handler is to return JSON so, by method, we need to explicitly say that we want to handle things our way.&lt;br /&gt;For that just use these lines anywhere within the method: &lt;/p&gt; &lt;pre class="brush:csharp"&gt;&lt;br /&gt;SkipContentTypeEvaluation = true; &lt;br /&gt;SkipDefaultSerialization = true;&lt;br /&gt;&lt;br /&gt;// you can specify the response content type as follows&lt;br /&gt;context.Response.ContentType = &amp;quot;text/html&amp;quot;;&lt;br /&gt;&lt;/pre&gt; Lets see an example on how we could write a method on the handler that returns HTML: &lt;pre class="brush:csharp"&gt;public object GiveMeSomeHTML(string text)&lt;br /&gt;{&lt;br /&gt; StringBuilder sb = new StringBuilder();&lt;br /&gt; sb.Append(&amp;quot;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;My Handler!&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&amp;quot;);&lt;br /&gt; sb.Append(&amp;quot;&amp;lt;body&amp;gt;&amp;quot;);&lt;br /&gt; sb.Append(&amp;quot;&lt;br /&gt;This is a HTML page returned from the Handler&lt;br /&gt;&amp;quot;);&lt;br /&gt; sb.Append(&amp;quot;&lt;br /&gt;The text passed was: &amp;quot; + text + &amp;quot;&lt;br /&gt;&amp;quot;);&lt;br /&gt; sb.Append(&amp;quot;&amp;lt;/body&amp;gt;&amp;quot;);&lt;br /&gt;&lt;br /&gt; context.Response.ContentType = &amp;quot;text/html&amp;quot;;&lt;br /&gt; SkipContentTypeEvaluation = true;&lt;br /&gt; SkipDefaultSerialization = true;&lt;br /&gt;&lt;br /&gt; return sb.ToString();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;p /&gt;  &lt;h3&gt;Optional Parameters and nullable types&lt;/h3&gt;&lt;p&gt;All parameters in the methods are optional. If they're not passed their default value is assigned.&lt;br /&gt;Also all parameters can be nullable. In this case the default value will be &lt;em&gt;null&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Please have a look at the attached code sample for more examples.&lt;/p&gt; &lt;h2&gt;Points of Interest&lt;/h2&gt; &lt;p&gt;I can say that this handler already saved me a good amount of development and maintenance hours.&lt;br /&gt;Currently all my AJAX requests point to a method on an handler like this. &lt;/p&gt; &lt;h2&gt;History&amp;nbsp;&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;v1.0 - The first wide open version&amp;nbsp;&lt;/li&gt; &lt;li&gt;This is a work in progress, I keep improving it regularly.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I have no doubt that you'll try to use this in scenarios I haven't predicted.&lt;br/&gt;Please send me your requests and desires, I'll do my best to implement them. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-3109676015912765973?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2012/03/advanced-generic-handler-ashx.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-8307848423998862561</guid><pubDate>Sun, 22 Jan 2012 14:57:00 +0000</pubDate><atom:updated>2012-01-22T14:57:04.500Z</atom:updated><title>ASP.net Routing vs ScriptManager</title><description>Recently I had a problem with ScriptManager on a WebForms site where I was also using the ScriptManager.&lt;br /&gt;&lt;br /&gt;Suddenly my ASP.net validators stopped working client-side and on Firebug I could read this error:&lt;br /&gt;&lt;h2 style="color: red;"&gt;ASP.NET Ajax client-side framework failed to load.&lt;/h2&gt;Crap... what am I doing wrong here!?&lt;/br&gt;&lt;/br&gt;It seems that Rounting messes with the .axd files script manager generates so we only need to tell the routing to ignore those:  &lt;pre class="brush:csharp"&gt;&lt;br /&gt;routes.Ignore("{resource}.axd/{*pathInfo}");&lt;br /&gt;&lt;/pre&gt;&lt;/br&gt;Done!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-8307848423998862561?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2012/01/aspnet-routing-vs-scriptmanager.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-428411204887279733</guid><pubDate>Thu, 10 Nov 2011 08:33:00 +0000</pubDate><atom:updated>2011-11-10T08:33:36.231Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>SQL</category><title>SQL Server 2008 Transactions Usage Template</title><description>I must admit I don't use Transactions that much, but the fact is that most of my stored procedures are atomic, i.e. although they may have a lot of code, only one data changing operation (INSERT | UPDATE | DELETE) is done, so there's no need to wrap it on a transaction.  &lt;p&gt;Because I don't use them much, its not always clear to me what's the "best way" of using a transaction. Sure we all know the basics but: &lt;ul&gt;&lt;li&gt;Is the transaction always closed?&lt;/li&gt;&lt;li&gt;Are we handling the error that caused the transaction to rollback?&lt;/li&gt;&lt;li&gt;Are we accurately reporting the error to the caller?&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;To be able to always answer YES to all these questions without thinking much about it, my friend &lt;a href="http://www.linkedin.com/in/ruiinacio"&gt;Rui&amp;nbsp;Inacio&lt;/a&gt; dove into Google and came up with a template that can be used as a start point of all your transaction scripts.  &lt;pre class="brush:sql"&gt;&lt;br /&gt; BEGIN TRY&lt;br /&gt;  BEGIN TRANSACTION&lt;br /&gt;  &lt;br /&gt;   -- ADD YOUR CODE HERE --&lt;br /&gt;  &lt;br /&gt;  IF @@TRANCOUNT &gt; 0&lt;br /&gt;  BEGIN&lt;br /&gt;   COMMIT TRANSACTION;&lt;br /&gt;  END&lt;br /&gt; END TRY&lt;br /&gt; BEGIN CATCH&lt;br /&gt;  DECLARE @ErrorMessage VARCHAR(4000)&lt;br /&gt;  &lt;br /&gt;  SET @ErrorMessage = 'ErrorProcedure: ' + ISNULL(ERROR_PROCEDURE(), '') + ' Line: ' + CAST(ERROR_LINE() AS VARCHAR(10)) + ' Message: ' + ERROR_MESSAGE()&lt;br /&gt;  &lt;br /&gt;  IF @@TRANCOUNT &gt; 0&lt;br /&gt;  BEGIN&lt;br /&gt;   ROLLBACK TRANSACTION;&lt;br /&gt;  END&lt;br /&gt;  &lt;br /&gt;  RAISERROR (@ErrorMessage, 16, 1)  &lt;br /&gt; END CATCH&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;You may change the way you report the error inside the CATCH but for most cases this is what you need.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-428411204887279733?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/11/sql-server-2008-transactions-usage.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-1545112797262095424</guid><pubDate>Sun, 30 Oct 2011 19:19:00 +0000</pubDate><atom:updated>2011-10-30T19:25:25.801Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Routing</category><category domain='http://www.blogger.com/atom/ns#'>ASP.net</category><category domain='http://www.blogger.com/atom/ns#'>FormsAuthentication</category><category domain='http://www.blogger.com/atom/ns#'>HttpHandler</category><title>Overriding FormsAuthentication for some URLs</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;h3&gt;Is this for you?&lt;/h3&gt;&lt;p&gt;How many times do you need you're website to have both public and private pages?&lt;/p&gt;&lt;p&gt;How many times did you thought that creating virtual directories with specific web.config files was lame?&lt;/p&gt;&lt;p&gt;If you feel the pain and want it to go away, read on!&lt;/br&gt;Also note that although I'll refer a lot to HttpHandlers on this post, everything here (except the route registration) is also true for common web pages. &lt;/p&gt; &lt;h3&gt;Be sure to have a look at this&lt;/h3&gt;A few days ago I wrote about &lt;a href="http://www.instanceofanobject.com/2011/10/aspnet-40-httphandler-routing-support.html"&gt;handling HttpHandlers with ASP.net routing&lt;/a&gt;.&lt;/br&gt;I'll refer to those extension methods to register my test handler route, so have a look on that post before continuing.&lt;/br&gt;&lt;p&gt;Now what I need is a way to override the default FormsAuthentication configuration for a specific set of HttpHandlers.&lt;/p&gt; &lt;h3&gt;Virtual Folder, web.config and the ASHX files&lt;/h3&gt;FormsAuthentication support this out-of-the-box by simply putting the resources with special security concerns on a separated folder with its own web.config file.  &lt;p&gt;So if you want a virtual directory to allow access to anonymous users just add a web.config file with nothing but this in it:&lt;/p&gt;&lt;pre class="brush:xml"&gt;&lt;br /&gt;&lt;configuration&gt;&lt;br /&gt; &lt;system.web&gt;&lt;br /&gt;  &lt;authorization&gt;&lt;br /&gt;   &lt;allow users="?"/&gt;&lt;br /&gt;  &lt;/authorization&gt;&lt;br /&gt; &lt;/system.web&gt;&lt;br /&gt;&lt;/configuration&gt;&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;This will work for any resource can can be accessed through an URL but this isn't always the case with HttpHandlers.&lt;/p&gt; &lt;h3&gt;FormsAuthentication and HttpHandlers &lt;b&gt;&lt;u&gt;without&lt;/u&gt;&lt;/b&gt; ASHX file&lt;/h3&gt;Using the extension methods I wrote on the &lt;a href="http://www.instanceofanobject.com/2011/10/aspnet-40-httphandler-routing-support.html"&gt;said previous post&lt;/a&gt; you can create an HttpHandler by simply creating a new class and implementing the IHttpHandler interface and point a route to it, just like this: &lt;pre class="brush:csharp"&gt;&lt;br /&gt;RouteTable.Routes.MapHttpHandlerRoute("Test", "Unsecured/Controllers/Test", new MyApplication.UnsecuredHandlers.MyUnsecuredHandler());&lt;br /&gt;&lt;/pre&gt;This means that, whenever you call ht**://mydomain/Unsecured/Controllers/Test the request will be routed to MyUnsecuredHandler instance, not to a physical uri location as usual.&lt;/br&gt;Now have a look at the route. It begins with &lt;i&gt;Unsecured&lt;/i&gt; right? Keep reading and you'll understand why.  &lt;p&gt;But we're not there yet, what I really want is to say that some of my handlers allow anonymous requests, and for that I'll edit my website web.config and add the following: &lt;pre class="brush:xml"&gt;&lt;br /&gt;&lt;configuration&gt;&lt;br /&gt; &lt;location path="unsecured"&gt;&lt;br /&gt;  &lt;system.web&gt;&lt;br /&gt;   &lt;authorization&gt;&lt;br /&gt;    &lt;allow users="*" /&gt;&lt;br /&gt;   &lt;/authorization&gt;&lt;br /&gt;  &lt;/system.web&gt;&lt;br /&gt; &lt;/location&gt;  &lt;br /&gt;&lt;/configuration&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/p&gt; &lt;p&gt;Now its done!&lt;/br&gt;Notice that on the location path I only have &lt;i&gt;unsecured&lt;/i&gt;. This will grant request permissions to all routes that begin with &lt;i&gt;unsecured&lt;/i&gt;!&lt;/br&gt;This is great because now I don't have to bother about structuring the resources on virtual directories and possibly duplicating the code for different scenarios.&lt;/br&gt;Whenever I need a Page or and HttpHandler to be available to anonymous users I just need to create a route to it that begins with &lt;i&gt;unsecured&lt;/i&gt;. &lt;/p&gt; &lt;p&gt;If you don't like this approach (specially for pages where the url is visible for the users) you can always add as much &lt;i&gt;location&lt;/i&gt; entries on the web.config as you like. &lt;/p&gt;&lt;p&gt;If you're &lt;b&gt;not using Routing&lt;/b&gt; you can still specify a location to your resources putting the uri of the Page or HttpHandler on the &lt;i&gt;path&lt;/i&gt; attribute: &lt;pre class="brush:xml"&gt;&lt;br /&gt;&lt;configuration&gt;&lt;br /&gt; &lt;location path="MyUnsecuredPage.aspx"&gt;&lt;br /&gt;  &lt;system.web&gt;&lt;br /&gt;   &lt;authorization&gt;&lt;br /&gt;    &lt;allow users="*" /&gt;&lt;br /&gt;   &lt;/authorization&gt;&lt;br /&gt;  &lt;/system.web&gt;&lt;br /&gt; &lt;/location&gt;  &lt;br /&gt;&lt;/configuration&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-1545112797262095424?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/10/overriding-formsauthentication-for-some.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-6887863256187809724</guid><pubDate>Fri, 21 Oct 2011 23:58:00 +0000</pubDate><atom:updated>2011-11-10T08:53:31.683Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>JQuery</category><title>PubSub with JQuery (Events)</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;h2&gt;What is PubSub?&lt;/h2&gt;PubSub stands short for Publish/Subscriber and is a technique based on events that lets you decouple the logic of an application.&lt;br /&gt;The basic concept is to have something that triggers an event (the publisher) and have one or more listeners (the subscribers) that are waiting for that event to be fired to act appon.  &lt;h2&gt;When to use this?&lt;/h2&gt;The short answer is: UI Decoupling. Sometimes sections of a webpage must communicate with each other, react on each other activities. To do this we usually have to make the sections aware of each other, making it much harder to maintain.&lt;/br&gt;Using Pub/Subs we just publish the events and forget about it, "someone" else on the page may make some use out of it.   &lt;h2&gt;How does it work?&lt;/h2&gt;&lt;p&gt;The concept is pretty easy to understand and the implementation follows the simplicity.&lt;br/&gt;&lt;/p&gt; &lt;h3&gt;The Publisher&lt;/h3&gt;This guy here usually reacts on an action and screams out loud:  &lt;p&gt;&lt;b&gt;&lt;i&gt;"I got something here, it's called [myevent] and comes along with this extra information. &lt;/br&gt;Anyone interested?"&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;&lt;pre class="brush:javascript"&gt;&lt;br /&gt;$(document).trigger(&amp;#39;myevent&amp;#39;, [age]);&lt;br /&gt;&lt;/pre&gt; &lt;h3&gt;The Subscriber&lt;/h3&gt;This guy meaning of life is to wait for someone says he got a [myevent].&lt;/br&gt;There can be as many guys as you want waiting for the same event, and each can react differently. &lt;pre class="brush:javascript"&gt;&lt;br /&gt; $(document).bind(&amp;#39;myevent&amp;#39;, function(e, age){ });&lt;br /&gt;&lt;/pre&gt; &lt;h3&gt;Sample Code&lt;/h3&gt;&lt;p&gt;Bellow you find a piece of code that shows the functionality in action on a very simple scenario.&lt;/br&gt;Basically you have a textbox where you can enter numbers, meaning ages for the case.&lt;/br&gt;Every time you click on the publish button, an event is triggered, publishing a message that contains the typed age.&lt;/br&gt;Listening are two subscribers that want to be notified whenever that event is triggered.&lt;/br&gt;One of the subscribers only cares about ages bellow 18, the other one cares about everything else. &lt;/p&gt;&lt;p&gt;Create a new html file and paste this code there and show it on a browser. You'll need internet connection as I'm using Google's CDN to get JQuery.&lt;/p&gt;&lt;pre class="brush:javascript"&gt;&lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; xml:lang=&amp;quot;en&amp;quot; lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt; &amp;lt;title&amp;gt;JQuery PubSub Demo&amp;lt;/title&amp;gt;&lt;br /&gt; &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt; &lt;br /&gt; &amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;br /&gt;  .Subscriber{ display:block; list-style-type: none; float: left; width: 200px; border: solid 1px #dcdcdc; margin: 5px; padding: 5px; }&lt;br /&gt; &amp;lt;/style&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;h2&amp;gt;Publisher&amp;lt;/h2&amp;gt;&lt;br /&gt;&amp;lt;p&amp;gt;&lt;br /&gt; Publish: &lt;br /&gt; &amp;lt;input id=&amp;quot;txtPublisherAge&amp;quot; type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt; &amp;lt;input type=&amp;quot;button&amp;quot; value=&amp;quot;publish&amp;quot; onclick=&amp;#39;Publish($(&amp;quot;#txtPublisherAge&amp;quot;).val())&amp;#39; /&amp;gt;&lt;br /&gt;&amp;lt;/p&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;h2&amp;gt;Subscriber&amp;lt;/h2&amp;gt;&lt;br /&gt;&amp;lt;ul id=&amp;quot;ulLessThan18&amp;quot; class=&amp;quot;Subscriber&amp;quot;&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;&amp;lt;ul id=&amp;quot;ul18Plus&amp;quot; class=&amp;quot;Subscriber&amp;quot;&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt; $(document).ready(function(){&lt;br /&gt;  &lt;br /&gt;  // handle ages &amp;lt; 18&lt;br /&gt;  $(document).bind(&amp;#39;myevent&amp;#39;, &lt;br /&gt;   function(e, age){&lt;br /&gt;    if(age &amp;lt; 18) {&lt;br /&gt;     $(&amp;#39;#ulLessThan18&amp;#39;).append(&amp;#39;&amp;lt;li&amp;gt;Handled age: &amp;#39; + age + &amp;#39;&amp;lt;/li&amp;gt;&amp;#39;); &lt;br /&gt;    }&lt;br /&gt;   });&lt;br /&gt;   &lt;br /&gt;  // handle ages &amp;gt;= 18&lt;br /&gt;  $(document).bind(&amp;#39;myevent&amp;#39;, &lt;br /&gt;   function(e, age){&lt;br /&gt;    if(age &amp;gt;= 18) {&lt;br /&gt;     $(&amp;#39;#ul18Plus&amp;#39;).append(&amp;#39;&amp;lt;li&amp;gt;Handled age: &amp;#39; + age + &amp;#39;&amp;lt;/li&amp;gt;&amp;#39;); &lt;br /&gt;    }&lt;br /&gt;   });&lt;br /&gt;   &lt;br /&gt; });&lt;br /&gt;&lt;br /&gt; // Everytime this method is called, the &amp;#39;myevent&amp;#39; event is published with the passed age value&lt;br /&gt; function Publish(age){&lt;br /&gt;  $(document).trigger(&amp;#39;myevent&amp;#39;, [age]);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;Cheers&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-6887863256187809724?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/10/pubsub-with-jquery.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-7075623135042426631</guid><pubDate>Thu, 20 Oct 2011 23:53:00 +0000</pubDate><atom:updated>2011-11-04T00:24:11.811Z</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Routing</category><category domain='http://www.blogger.com/atom/ns#'>ASP.net</category><category domain='http://www.blogger.com/atom/ns#'>HttpHandler</category><title>ASP.net 4.0 HttpHandler Routing Support</title><description>&lt;p&gt;I'm a big fan of ASP.net Routing and I use it a lot on my ASP.net Webforms applications.&lt;/p&gt;&lt;p&gt;If you're just getting started with Routing on ASP.net Webforms I recommend reading &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx"&gt;this post&lt;/a&gt; from Scott Guthrie.&lt;/p&gt;&lt;p&gt;Ok now, back to the subject, one thing about Routing is that it doesn't support routes that point to HttpHandlers (common .ASHX files).&lt;/p&gt; The code bellow comes just to overcome this limitation by adding a new method (and one overload) to the RoutesCollection object that will let you map a route to an *.ashx url or directly to the handler object.  &lt;p style="border: dashed 1px #000; padding: 4px; background-color: #f1e69f;"&gt;&lt;b&gt;Edit (2011/11/03):&lt;/b&gt; I just updated this due some problems when reusing the same handler for different requests. Now each request gets its own handler like it should.&lt;/p&gt;&lt;h2&gt;The Code&lt;/h2&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;namespace System.Web.Routing&lt;br /&gt;{&lt;br /&gt; public class HttpHandlerRoute&amp;lt;T&amp;gt; : IRouteHandler where T: IHttpHandler&lt;br /&gt; {&lt;br /&gt;  private String _virtualPath = null;&lt;br /&gt;&lt;br /&gt;  public HttpHandlerRoute(String virtualPath)&lt;br /&gt;  {&lt;br /&gt;   _virtualPath = virtualPath;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public HttpHandlerRoute() { }&lt;br /&gt;&lt;br /&gt;  public IHttpHandler GetHttpHandler(RequestContext requestContext)&lt;br /&gt;  {&lt;br /&gt;   return Activator.CreateInstance&amp;lt;T&amp;gt;();&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public class HttpHandlerRoute : IRouteHandler&lt;br /&gt; {&lt;br /&gt;  private String _virtualPath = null;&lt;br /&gt;&lt;br /&gt;  public HttpHandlerRoute(String virtualPath)&lt;br /&gt;  {&lt;br /&gt;   _virtualPath = virtualPath;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public IHttpHandler GetHttpHandler(RequestContext requestContext)&lt;br /&gt;  {&lt;br /&gt;   if (!string.IsNullOrEmpty(_virtualPath))&lt;br /&gt;   {&lt;br /&gt;    return (IHttpHandler)System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(_virtualPath, typeof(IHttpHandler));&lt;br /&gt;   }&lt;br /&gt;   else&lt;br /&gt;   {&lt;br /&gt;    throw new InvalidOperationException("HttpHandlerRoute threw an error because the virtual path to the HttpHandler is null or empty.");&lt;br /&gt;   }&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public static class RoutingExtension&lt;br /&gt; {&lt;br /&gt;  public static void MapHttpHandlerRoute(this RouteCollection routes, string routeName, string routeUrl, string physicalFile, RouteValueDictionary defaults = null, RouteValueDictionary constraints = null)&lt;br /&gt;  {&lt;br /&gt;   var route = new Route(routeUrl, defaults, constraints, new HttpHandlerRoute(physicalFile));&lt;br /&gt;   routes.Add(routeName, route);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public static void MapHttpHandlerRoute&amp;lt;T&amp;gt;(this RouteCollection routes, string routeName, string routeUrl, RouteValueDictionary defaults = null, RouteValueDictionary constraints = null) where T : IHttpHandler&lt;br /&gt;  {&lt;br /&gt;   var route = new Route(routeUrl, defaults, constraints, new HttpHandlerRoute&amp;lt;T&amp;gt;());&lt;br /&gt;   routes.Add(routeName, route);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; &lt;h2&gt;How to use it&lt;/h2&gt;&lt;pre class="brush:csharp"&gt;&lt;br /&gt;// using the handler url&lt;br /&gt;routes.MapHttpHandlerRoute("DoSomething", "Handlers/DoSomething", "~/DoSomething.ashx");&lt;br /&gt;&lt;br /&gt;// using the type of the handler&lt;br /&gt;routes.MapHttpHandlerRoute&amp;lt;MyHttpHanler&amp;gt;("DoSomething", "Handlers/DoSomething");&lt;br /&gt;&lt;/pre&gt; &lt;p&gt;And that's it! :)&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-7075623135042426631?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/10/aspnet-40-httphandler-routing-support.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>3</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-7390171246255945762</guid><pubDate>Tue, 23 Aug 2011 09:44:00 +0000</pubDate><atom:updated>2011-08-27T21:56:22.029+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>TFS</category><category domain='http://www.blogger.com/atom/ns#'>Visual Studio</category><category domain='http://www.blogger.com/atom/ns#'>Macros</category><title>VS 2010 TFS Solution CheckIn Hotkey</title><description>&lt;h2&gt;Intoduction&lt;/h2&gt;This is a nice implementation of a keyboard shortcut to checkin your Solution that makes use of the Macro engine of visual studo.&lt;br /&gt;This implementation will prompt the exact same modal window that shows when we choose "Check In..." from the solution context menu.&lt;br /&gt;&lt;br /&gt;This is particulary useful not only on big solution where you have to scroll a lot to see the solution node but also when the solution context menu gets so big that finding the "Check In..." option is not that easy.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Creating the Macro&lt;/h2&gt;There isn't any out-of-the-box way of doing this, so we have to write a macro.&lt;br /&gt;On Visual Studio go to: Tools &gt; Macros &gt; Macro Explorer&lt;br /&gt;&lt;br /&gt;On the right side a new pane appeared showing the Macros you have.&lt;br /&gt;By default you have two child nodes under Macros: MyMacros and Sample.&lt;br /&gt;Lets use MyMacros. &lt;br /&gt;&lt;ol&gt;&lt;li&gt;Right-click it and choose "New Module".&lt;/li&gt; &lt;li&gt;Name it TFS and ckick Add.&lt;/li&gt; &lt;li&gt;Open the created module and replace the entire file content with the code bellow&lt;/li&gt; &lt;li&gt;I don't take the credit of the code bellow, it was taken from &lt;a href="http://stackoverflow.com/questions/3994906/hotkey-for-tfs-checkin"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;Imports System&lt;br /&gt;Imports EnvDTE&lt;br /&gt;Imports EnvDTE80&lt;br /&gt;Imports EnvDTE90&lt;br /&gt;Imports EnvDTE90a&lt;br /&gt;Imports EnvDTE100&lt;br /&gt;Imports System.Diagnostics&lt;br /&gt;&lt;br /&gt;Public Module TFS&lt;br /&gt;&lt;br /&gt;    Sub CheckInSolution()&lt;br /&gt;        DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()&lt;br /&gt;&lt;br /&gt;        Dim fi As System.IO.FileInfo = New System.IO.FileInfo(DTE.Solution.FullName)&lt;br /&gt;        Dim name As String = fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length)&lt;br /&gt;&lt;br /&gt;        DTE.ActiveWindow.Object.GetItem(name).Select(vsUISelectionType.vsUISelectionTypeSelect)&lt;br /&gt;        DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.TfsContextCheckIn")&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;End Module&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt; &lt;li&gt;Save the Macro and close it.&lt;/li&gt; &lt;/ol&gt;&lt;br /&gt;&lt;h2&gt;Creating the Keyboard Shortcut&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;Go to Tools &gt; Options &gt; Environment &gt; Keyboard&lt;/li&gt; &lt;li&gt;On the listbox searck for Macros.MyMacros.TFS.ChackInSolution and select it&lt;/li&gt; &lt;li&gt;On the Shortcut keys textbox I used: Ctrl+Shift+K, Ctrl+Shift+I&lt;br /&gt;&lt;ul&gt;&lt;li&gt;This combination is accomplished by pressing &lt;i&gt;K&lt;/i&gt; &lt;b&gt;and then&lt;/b&gt; &lt;i&gt;I&lt;/i&gt; while holding (without releasing) the &lt;i&gt;Control and Shift&lt;/i&gt; keys&lt;/li&gt; &lt;li&gt;The above combination was available on my environment, don't use a combination that is already in use on your environment.&lt;/li&gt; &lt;li&gt;&lt;b&gt;EDIT: &lt;/b&gt;I previously had a Ctrl+C, Ctrl-I combination but using Ctrl+C will mess the default clipboard Copy shortcut. If you find that your shortcut messed up anything you must reset the key assignments ckicking the Reset button.&lt;/li&gt; &lt;/ul&gt;&lt;/li&gt; &lt;li&gt;Click OK, and you're done.&lt;/li&gt; &lt;/ol&gt;&lt;br /&gt;Now, when you use Ctrl+C, Ctrl+I anywhere on Visual Studio the checkin modal form will appear just like it would if you choose "Check In..." from the Solution context menu.&lt;br /&gt;&lt;br /&gt;Have fun!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-7390171246255945762?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/08/vs-2010-tfs-solution-checkin-hotkey.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-656977020905600692</guid><pubDate>Thu, 11 Aug 2011 16:58:00 +0000</pubDate><atom:updated>2011-09-15T17:33:53.088+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>ASP.net</category><category domain='http://www.blogger.com/atom/ns#'>C#</category><title>How to strip down or parse an Url using C#</title><description>Many times I need to get the segments of an Url, and I'm not only talking about the query string.&lt;br /&gt;&lt;br /&gt;If we search around the web we can see a lot of ideas for parsing URLs, most using regular expressions.&lt;br /&gt;The fact is that .net Framework gives us a much better tool: &lt;a href="http://msdn.microsoft.com/en-us/library/system.uri.aspx"&gt;System.Uri&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;So if we have an Url that we need to strip down we can write:&lt;br /&gt;&lt;pre class="brush:csharp"&gt;public void MyMethod(string url)&lt;br /&gt;{&lt;br /&gt;	System.Uri path = new Uri(url);&lt;br /&gt;	var protocol = path.Scheme;&lt;br /&gt;	var host = path.Host;&lt;br /&gt;	// See the System.Uri documentation for the available methods&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note that this object is the same that you may be familiar with and is used when we get the current HttpContext url:&lt;br /&gt;&lt;pre class="brush:csharp"&gt;System.Web.HttpContext.Current.Request.Url&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-656977020905600692?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/08/how-strip-down-or-parse-url.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-2361651228961242062</guid><pubDate>Mon, 18 Jul 2011 13:01:00 +0000</pubDate><atom:updated>2011-08-27T21:58:42.350+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>SQL</category><title>Quick compare the columns of two tables in SQL Server</title><description>This is a quick tip on how to compare the columns of two tables in the same database.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:sql"&gt;-- Replace Table1Name and Table2Name&lt;br /&gt;-- with the name of the tables you want to compare&lt;br /&gt;DECLARE @tbl1 varchar(200) = 'Table1Name'; &lt;br /&gt;DECLARE @tbl2 varchar(200) = 'Table2Name';&lt;br /&gt;&lt;br /&gt;SELECT * FROM &lt;br /&gt;(&lt;br /&gt; select &lt;br /&gt; tbl1.COLUMN_NAME AS tbl1Column_Name,&lt;br /&gt; tbl1.DATA_TYPE AS tbl1Data_Type,&lt;br /&gt; tbl2.COLUMN_NAME AS tbl2Column_Name,&lt;br /&gt; tbl2.DATA_TYPE AS tbl2Data_Type&lt;br /&gt; FROM &lt;br /&gt;  (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE @tbl1) AS tbl1&lt;br /&gt;  FULL OUTER JOIN (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE @tbl2) AS tbl2 ON tbl2.COLUMN_NAME LIKE tbl1.COLUMN_NAME) AS compare&lt;br /&gt;-- uncomment the line bellow to show only the columns that don't match by name&lt;br /&gt;--WHERE tbl1Column_Name IS NULL OR tbl2Column_Name IS NULL&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Remarks&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;This will only work with tables on the same SQL Database&lt;br /&gt;&lt;ul&gt;&lt;li&gt;This can be extended to support comparisons between databases within the same instance without much trouble&lt;/li&gt; &lt;/ul&gt;&lt;/li&gt; &lt;li&gt;It doesn't matter which table is Table1 or Table2&lt;/li&gt; &lt;li&gt;You can add more columns to the result, &lt;a href="http://msdn.microsoft.com/en-us/library/ms188348.aspx"&gt;INFORMATION_SCHEMA.Columns&lt;/a&gt; returns a lot more information&lt;/li&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-2361651228961242062?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/07/quick-compare-columns-of-two-tables-in.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-1592518454779260968</guid><pubDate>Mon, 11 Jul 2011 02:14:00 +0000</pubDate><atom:updated>2011-08-27T21:59:28.738+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>JQuery</category><category domain='http://www.blogger.com/atom/ns#'>AJAX</category><category domain='http://www.blogger.com/atom/ns#'>IE</category><title>JQuery Ajax Cache Problems on IE</title><description>Internet Explorer (IE) have this huge need to be different.&lt;br /&gt;In my opinion this have no explanation other than the need to screw some development time.&lt;br /&gt;Here I'll talk about another plain simple example: ajax cache.&lt;br /&gt;&lt;br /&gt;No other browser, by default, caches ajax requests... but IE does.&lt;br /&gt;So, when you make a second ajax call with the exact same parameters IE thinks it's smarter than others and returns the result it have in cache from the first request, and there's no way to make him refresh that cache, not F5, not Ctrl+F5 not even asking politely... nothing!&lt;br /&gt;&lt;br /&gt;What we have to do is tell, right on the request, that we don't want the result to be cached.&lt;br /&gt;So on a JQuery AJAX request we would do:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:javascript"&gt;$.ajax(&lt;br /&gt;cache: false,&lt;br /&gt;url: 'http://myurl',&lt;br /&gt;data: {}&lt;br /&gt;);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This will work for this particular request.&lt;br /&gt;If you want to expand the scope of this setting to all ajax request you can set it on the global ajax configuration:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:javascript"&gt;$.ajaxSetup({ cache: false });&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;From now on I'll be making this cache setting a "must" on every ajax call.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Be aware of the insights...&lt;/h2&gt;The theory behind this is that IE uses cache for requests with the exact same signature. So if you change something on the request the cache won't be used.&lt;br /&gt;&lt;br /&gt;In web there's no magic, and this thing here is no exception. When a $.ajax have the cache set to false what it does is append a dummy parameter to the query string.&lt;br /&gt;The name of the parameter is a single _ (underscore) and the value is a timestamp.&lt;br /&gt;This way they are quite sure there's no parameter name collision and that the querystring is always unique.&lt;br /&gt;&lt;br /&gt;This usually isn't a problem unless you actually already use a parameter _ on your application querystring or if you perform some kind of URL parameters validation uppon request and find an unexpected parameter sitting at the end&lt;br /&gt;&lt;br /&gt;Cheers!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-1592518454779260968?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/07/jquery-ajax-cache-problems-on-ie.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-341256407634047968</guid><pubDate>Mon, 04 Jul 2011 23:13:00 +0000</pubDate><atom:updated>2011-08-27T22:00:19.858+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>ASP.net</category><title>Best way to put your ASP.net site offline</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://sa-nco.com/under%20maintenance.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="200" src="http://sa-nco.com/under%20maintenance.png" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Ok, "Best way" can be arguable but sure is a clean, fast and stand-alone solution.&lt;br /&gt;&lt;br /&gt;On a perfect world we would never ever need to put our site offline... never!... but we're all grown up now and there's no such thing as a perfect world and we need to put our sites into a comma stage so we can begin surgery without thinking about outside factors.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;&lt;br /&gt;&lt;/h2&gt;&lt;h2&gt;The trick: app_offline.htm&lt;/h2&gt;There are many ways of putting your ASP.net website offline but the fastest way is to just drop a file named &lt;i&gt;app_offline.htm&lt;/i&gt; on the site's root. Tcharan! That's it folks, good night! :)&lt;br /&gt;&lt;br /&gt;Ok, not so fast, I have one more trick on the sleave.&lt;br /&gt;&lt;br /&gt;As you can imagine, this &lt;i&gt;app_offline.htm&lt;/i&gt; file can contain HTML markup which will be returned to the user. So you can build you Offline page all in there in plain HTML for your users to see.&lt;br /&gt;As long as you have this file on the website root, all requests to anything on that website will be redirected to this offline page... an this leads us to a problem...&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Showing images on app_offline.htm&lt;/h2&gt;This is nice 'till the point you try to show an image on that page.&lt;br /&gt;Like I said above, all requests to anything on this website will be redirected to the app_offline.htm file, and that includes any image file you mas want to show on you cute offline page.&lt;br /&gt;&lt;br /&gt;To overcome this you have two options:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;reference an external image file with an URL that point to another site&lt;/li&gt; &lt;li&gt;Embed the image file right on the markup&lt;/li&gt; &lt;/ol&gt;&lt;br /&gt;&lt;h2&gt;Embedding images inside the app_offline.htm&lt;/h2&gt;&amp;lt;img&amp;gt; tags have the ability to consume more than direct pointers to image files, they can read Base64.&lt;br /&gt;So the idea is to convert our images into Base64 and inject that code on our page:&lt;br /&gt;&lt;pre class="brush:html"&gt;&amp;lt;img class="undermaintenanceimage" src="data:image/png;base64,[BASE64 DATA]" /&amp;gt;&lt;br /&gt;&lt;/pre&gt;Just replace [BASE64 DATA] with your image in Base64 format.&lt;br /&gt;&lt;br /&gt;If you don't know how to convert an image into it Base64 representation you may use one of the services online that do that for you, &lt;a href="http://www.motobit.com/util/base64-decoder-encoder.asp"&gt;try this one for example&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Conclusion&lt;/h2&gt;This way you can create a simple and stand-alone offline file without having to worry about external references or much harder to maintain techniques.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-341256407634047968?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/07/best-way-to-put-your-aspnet-site.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-118953443844188900</guid><pubDate>Sun, 03 Jul 2011 11:44:00 +0000</pubDate><atom:updated>2011-08-27T22:01:07.226+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>JQuery UI</category><category domain='http://www.blogger.com/atom/ns#'>JQuery</category><title>jQuery button dropdown</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;h2&gt;Introduction&lt;/h2&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-PcD3SzWeVVE/ThBIpldEtLI/AAAAAAAAAIA/t3roR5AXK4s/s1600/DropdownJqueryButton.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-PcD3SzWeVVE/ThBIpldEtLI/AAAAAAAAAIA/t3roR5AXK4s/s1600/DropdownJqueryButton.png" /&gt;&lt;/a&gt;&lt;/div&gt;On the jQueryUI documentation for the .button() widget we have an example illustrates the split button functionality &lt;a href="http://jqueryui.com/demos/button/#splitbutton"&gt;See here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The problem is that the example isn't finished and clicking on the small button will only fire an alert.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;My requirements&lt;/h2&gt;I had few requirements but they were very important to me:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Dropdown shold perfectly integrate with the selected theme&lt;/li&gt; &lt;li&gt;Only the small '+' button should interact with the dropdown&lt;/li&gt; &lt;li&gt;Consider both buttons as a single block so that the dropdown would show beneath that block and not only bellow the '+' button&lt;/li&gt; &lt;li&gt;All the buttons should be able to be hidden and shown on demand to reflect different form display modes&lt;/li&gt; &lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;Limitations and work to be done&lt;/h2&gt;&lt;i&gt;Code reuse&lt;/i&gt;&lt;br /&gt;Right now I don't have the time to make this a JQueryUI widget but sure it would be nicer to handle. Anyway, what I did was writing all this inside a user control (ASP.ne ASCX) and reuse it on every Item Edit page. To do this just create a new ASCX and drop all the code I have on the bottom of this post (CSS, HTML and Javascript) and you're done.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Multiple instances on the page&lt;/i&gt;&lt;br /&gt;A true limitation it that &lt;b&gt;there can only be one of these per page&lt;/b&gt;.&lt;br /&gt;So if you need this behavior more than once on the page you need to abstract it inside a JQuery UI widget.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Getting it done&lt;/h2&gt;The code I'm posting here will render like the picture above and behaves like this:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Click '+'&lt;/b&gt;: Toggles open/close the dropdown menu&lt;/li&gt; &lt;li&gt;&lt;b&gt;Click dropdown item&lt;/b&gt;: Closes dropdown and performs action&lt;/li&gt; &lt;li&gt;&lt;b&gt;Mouse leave dropdown&lt;/b&gt;: Closes dropdown&lt;/li&gt; &lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;The code&lt;/h2&gt;Dropping all the code bellow into a page will do the trick.&lt;br /&gt;After that, all you have to do is override the click events callbacks:&lt;br /&gt;&lt;pre class="brush:javascript"&gt;ItemActionButtons.onSaveClick = function(){ alert('Save button have been clicked'); };&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;We can also hide/show a button this way:&lt;br /&gt;&lt;pre class="brush:javascript"&gt;ItemActionButtons.AllowCancel(false);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;See the ItemActionButtons object for more.&lt;br /&gt;Feel free to add your own actions and events to customise it as you need.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;HTML&lt;/h3&gt;&lt;pre class="brush:html"&gt;&lt;div class="ItemActionButtons"&gt;&lt;div class="buttonset" style="float: right;"&gt;&lt;input id="btnDelete" type="button" value="Delete" class="button" onclick="ItemActionButtons.onDeleteClick.apply(this)" /&gt;&lt;br /&gt;  &lt;input id="btnCancel" type="button" value="Cancel" class="button"onclick="ItemActionButtons.onCancelClick.apply(this)" /&gt;&lt;br /&gt; &lt;/div&gt;&lt;div id="divSaveButton" class="buttonset" style="float: right;"&gt;&lt;input id="btnSave" type="button" value="Save" class="button" onclick="ItemActionButtons.onSaveClick.apply(this)" /&gt;&lt;br /&gt;  &lt;input id="btnSaveExtra" type="button" class="button" value="+" onclick="ItemActionButtons.onSaveExtraClick.apply(this)" /&gt;&lt;br /&gt;&lt;br /&gt;  &lt;ul class="SaveExtraOptions ui-corner-bottom" id="btnSaveExtraOptions"&gt;&lt;li onclick="$('#btnSaveExtraOptions').toggle(); ItemActionButtons.SaveAndNewClick.apply(this)"&gt;Save and New&lt;/li&gt;&lt;br /&gt;&lt;li onclick="$('#btnSaveExtraOptions').toggle(); ItemActionButtons.SaveAndCopyClick.apply(this)"&gt;Save and Copy&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h3&gt;CSS&lt;/h3&gt;&lt;pre class="brush:css"&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt; .ItemActionButtons{}&lt;br /&gt; .ItemActionButtons .SaveExtraOptions&lt;br /&gt; {&lt;br /&gt;  display: none; list-style-type: none; padding: 5px; margin: 0; border: 1px solid #DCDCDC; background-color: #fff; z-index: 999; position: absolute;&lt;br /&gt; }&lt;br /&gt; .ItemActionButtons .SaveExtraOptions li&lt;br /&gt; {&lt;br /&gt;  padding: 5px 3px 5px 3px; margin: 0; width: 150px; border: 1px solid #fff;&lt;br /&gt; }&lt;br /&gt; .ItemActionButtons .SaveExtraOptions li:hover&lt;br /&gt; {&lt;br /&gt;  cursor: pointer;&lt;br /&gt;  background-color: #DCDCDC;&lt;br /&gt; }&lt;br /&gt; .ItemActionButtons .SaveExtraOptions li a&lt;br /&gt; {&lt;br /&gt;  text-transform: none;&lt;br /&gt; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h3&gt;Javascript&lt;/h3&gt;&lt;pre class="brush:javascript"&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;&lt;br /&gt; $(document).delegate('#btnSaveExtra', 'mouseleave', function () { setTimeout(function(){ if (!ItemActionButtons.isHoverMenu) { $('#btnSaveExtraOptions').hide(); }}, 100, 1) });&lt;br /&gt; $(document).delegate('#btnSaveExtraOptions', 'mouseenter', function () { ItemActionButtons.isHoverMenu = true; });&lt;br /&gt; $(document).delegate('#btnSaveExtraOptions', 'mouseleave', function () { $('#btnSaveExtraOptions').hide(); ItemActionButtons.isHoverMenu = false; });&lt;br /&gt;&lt;br /&gt; var $IsHoverExtraOptionsFlag = 0;&lt;br /&gt; $(document).ready(function () {&lt;br /&gt;  $(".button").button();&lt;br /&gt;  $(".buttonset").buttonset();&lt;br /&gt;&lt;br /&gt;  $('#btnSaveExtra').button({ icons: { primary: "ui-icon-plusthick" } });&lt;br /&gt;  $('#btnSaveExtraOptions li').addClass('ui-corner-all ui-widget');&lt;br /&gt;  $('#btnSaveExtraOptions li').hover(&lt;br /&gt;   function () { $(this).addClass('ui-state-default'); },&lt;br /&gt;   function () { $(this).removeClass('ui-state-default'); }&lt;br /&gt;  );&lt;br /&gt;  $('#btnSaveExtraOptions li').mousedown(function () { $(this).addClass('ui-state-active'); });&lt;br /&gt;  $('#btnSaveExtraOptions li').mouseup(function () { $(this).removeClass('ui-state-active'); });&lt;br /&gt; });&lt;br /&gt;&lt;br /&gt; var ItemActionButtons = {&lt;br /&gt;  isHoverMenu: false,&lt;br /&gt;&lt;br /&gt;  AllowDelete: function (value) { value ? $("#btnDelete").show() : $("#btnDelete").hide() },&lt;br /&gt;  AllowCancel: function (value) { value ? $("#btnCancel").show() : $("#btnCancel").hide() },&lt;br /&gt;  AllowSave: function (value) { value ? $("#btnSave").show() : $("#btnSave").hide() },&lt;br /&gt;  AllowSaveExtra: function (value) { value ? $("#btnSaveExtra").show() : $("#btnSaveExtra").hide() },&lt;br /&gt;&lt;br /&gt;  onDeleteClick: function () { },&lt;br /&gt;  onCancelClick: function () { },&lt;br /&gt;  onSaveClick: function () { },&lt;br /&gt;  onSaveExtraClick: function () {&lt;br /&gt;   $('#btnSaveExtraOptions').toggle();&lt;br /&gt;&lt;br /&gt;   var btnLeft = $('#divSaveButton').offset().left;&lt;br /&gt;   var btnTop = $('#divSaveButton').offset().top + $('#divSaveButton').outerHeight(); // +$('#divSaveButton').css('padding');&lt;br /&gt;   var btnWidth = $('#divSaveButton').outerWidth();&lt;br /&gt;   $('#btnSaveExtraOptions').css('left', btnLeft).css('top', btnTop);&lt;br /&gt;  },&lt;br /&gt;  SaveAndNewClick: function () { },&lt;br /&gt;  SaveAndCopyClick: function () { }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-118953443844188900?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/07/jquery-button-dropdown.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-PcD3SzWeVVE/ThBIpldEtLI/AAAAAAAAAIA/t3roR5AXK4s/s72-c/DropdownJqueryButton.png' height='72' width='72'/><thr:total>3</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-4940436873546722213</guid><pubDate>Mon, 13 Jun 2011 11:53:00 +0000</pubDate><atom:updated>2011-08-27T22:01:39.065+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>SQL</category><title>INT to BINARY string in SQL Server</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;SQL Server doesn't have a native way of converting INTs to BINARY.&lt;br /&gt;&lt;br /&gt;Executing &lt;pre class="brush:sql"&gt;SELECT CAST(25 AS BINARY)&lt;/pre&gt;infact returns &lt;i&gt;19&lt;/i&gt; which is the Hexadecimal equivalent, not the binary.&lt;br /&gt;&lt;br /&gt;Bellow you can see the differences between the 3 numeric representations:&lt;br /&gt;&lt;b&gt;Integer&lt;/b&gt;: 25&lt;br /&gt;&lt;b&gt;Binary&lt;/b&gt;: 11001&lt;br /&gt;&lt;b&gt;Hexadecimal&lt;/b&gt;: 19&lt;br /&gt;&lt;br /&gt;So I had 2 requirements:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Have the BIN representation of 25 as a string: '11001'&lt;/li&gt; &lt;li&gt;Be able to set a fixed minimum result size&lt;br /&gt;&lt;ul&gt;&lt;li&gt;fixedSize=2 : '11001'&lt;/li&gt; &lt;li&gt;fixedSize=5 : '11001'&lt;/li&gt; &lt;li&gt;fixedSize=10 : '0000011001'&lt;/li&gt; &lt;/ul&gt;&lt;/li&gt; &lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;Best Solution&lt;/h2&gt;After posting this article I triggered the genious inside my big friend &lt;a href="http://www.facebook.com/tiagofilipeguedes"&gt;Tiago Guedes&lt;/a&gt; that came up with a much cleaner solution:&lt;br /&gt;&lt;pre class="brush:sql"&gt;ALTER FUNCTION INT2BIN&lt;br /&gt;(&lt;br /&gt; @value INT,&lt;br /&gt; @fixedSize INT = 10&lt;br /&gt;)&lt;br /&gt;RETURNS VARCHAR(1000)&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt; DECLARE @result VARCHAR(MAX) = '';&lt;br /&gt;&lt;br /&gt; WHILE @value &gt;= 1&lt;br /&gt; BEGIN&lt;br /&gt; SELECT @result = CAST(@value % 2 AS VARCHAR) + @result, @value = @value / 2&lt;br /&gt; END;&lt;br /&gt;&lt;br /&gt; IF(@fixedSize &gt; LEN(@result))&lt;br /&gt; BEGIN&lt;br /&gt; SELECT @result = REPLICATE('0', @fixedSize - LEN(@result)) + @result&lt;br /&gt; END;&lt;br /&gt;&lt;br /&gt; RETURN @result;&lt;br /&gt;END&lt;br /&gt;GO&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;My Initial solution&lt;/h2&gt;For historical purposes I leave here my original two ways of doing the same thing.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:sql"&gt;CREATE FUNCTION INT2BIN&lt;br /&gt;(&lt;br /&gt; @value INT,&lt;br /&gt; @fixedSize INT = 10&lt;br /&gt;)&lt;br /&gt;RETURNS VARCHAR(1000)&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt; DECLARE @result VARCHAR(1000) = '';&lt;br /&gt;&lt;br /&gt; WHILE (@value != 0)&lt;br /&gt; BEGIN&lt;br /&gt;  IF(@value%2 = 0) &lt;br /&gt;   SET @Result = '0' + @Result;&lt;br /&gt;  ELSE&lt;br /&gt;   SET @Result = '1' + @Result;&lt;br /&gt;   &lt;br /&gt;  SET @value = @value / 2;&lt;br /&gt; END;&lt;br /&gt;&lt;br /&gt; IF(@FixedSize &gt; 0 AND LEN(@Result) &lt; @FixedSize)&lt;br /&gt;  SET @result = RIGHT('00000000000000000000' + @Result, @FixedSize);&lt;br /&gt;&lt;br /&gt; RETURN @Result;&lt;br /&gt;END&lt;br /&gt;GO&lt;br /&gt;&lt;/pre&gt; Caution: The above code only supports @FixedSize values equal or bellow 20. If you need support for higher values just add more zeros to the 'RIGHT' statement. Another option is to make this padding dynamic introducing another loop.  &lt;pre class="brush:sql"&gt;CREATE FUNCTION INT2BIN&lt;br /&gt;(&lt;br /&gt; @value INT,&lt;br /&gt; @fixedSize INT = 10&lt;br /&gt;)&lt;br /&gt;RETURNS VARCHAR(1000)&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt; DECLARE @result VARCHAR(1000) = '';&lt;br /&gt;&lt;br /&gt; WHILE (@value != 0)&lt;br /&gt; BEGIN&lt;br /&gt;  IF(@value%2 = 0) &lt;br /&gt;   SET @Result = '0' + @Result;&lt;br /&gt;  ELSE&lt;br /&gt;   SET @Result = '1' + @Result;&lt;br /&gt;   &lt;br /&gt;  SET @value = @value / 2;&lt;br /&gt; END;&lt;br /&gt;&lt;br /&gt; IF(@fixedSize IS NOT NULL AND @fixedSize &gt; 0 AND LEN(@Result) &lt; @fixedSize)&lt;br /&gt; BEGIN&lt;br /&gt;  DECLARE @len INT = @fixedSize;&lt;br /&gt;  DECLARE @padding VARCHAR(1000) = '';&lt;br /&gt; &lt;br /&gt;  WHILE @len &gt; 0&lt;br /&gt;  BEGIN&lt;br /&gt;   SET @padding = @padding + '0';&lt;br /&gt;   SET @len = @len-1;&lt;br /&gt;  END; &lt;br /&gt;  SET @result = RIGHT(@padding + @result, @fixedSize);&lt;br /&gt; END;&lt;br /&gt; &lt;br /&gt; RETURN @result;&lt;br /&gt;END&lt;br /&gt;GO&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-4940436873546722213?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/06/int-to-binary-string-in-sql-server.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-2842340135674641034</guid><pubDate>Wed, 01 Jun 2011 18:27:00 +0000</pubDate><atom:updated>2011-08-27T22:02:14.829+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>ASP.net</category><title>ASP.net ResolveUrl without Page</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;h2&gt;The quick answer&lt;/h2&gt;&lt;pre class="brush:csharp"&gt;System.Web.VirtualPathUtility.ToAbsolute("~/default.aspx");&lt;br /&gt;&lt;/pre&gt;Don't forget the ~/ (tilde) before the page name.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;The lengthy explanation&lt;/h2&gt;&lt;br /&gt;Assume that we want to redirect to the default.aspx that's on the site root:&lt;br /&gt;&lt;pre class="brush:csharp"&gt;Response.Redirect("default.aspx");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If we're on a page that's also on the root, it will map to: http://www.mysite.com/default.aspx and work correctly.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;The problem&lt;/h3&gt;The problem comes when we're not on the site root but insite a child folder.&lt;br /&gt;Lets say we're on a page that's insite the /Administration  folder, the same line will map to http://www.mysite.com/Administration/default.aspx that ofcourse won't resolve and return a glorious 404: Page Not Found.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;The solution&lt;/h3&gt;Solving this is easy using the ResolveUrl method:&lt;br /&gt;&lt;pre class="brush:csharp"&gt;Response.Redirect(ResolveUrl("~/default.aspx"));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h3&gt;Where this won't work&lt;/h3&gt;ResolveUrl is only available withing the context of a Page or a UserControl, if you're, for instance, inside an ASHX this method isn't available.&lt;br /&gt;In these cases you have to use the followinf line to do the job:&lt;br /&gt;&lt;pre class="brush:csharp"&gt;System.Web.VirtualPathUtility.ToAbsolute("~/default.aspx");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;We must include the tilde before the page name to make it a relative path, otherwise this method will throw an exception.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-2842340135674641034?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/06/aspnet-resolveurl-without-page.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-5531300516341184738</guid><pubDate>Wed, 25 May 2011 01:16:00 +0000</pubDate><atom:updated>2011-08-27T22:02:32.970+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>JQuery UI</category><category domain='http://www.blogger.com/atom/ns#'>JQuery</category><title>Making a JQuery UI Datepicker Read Only</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;To make this post clear, by ReadOnly I mean really READ ONLY, no input allowed whatsoever. &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Datepicker default behavior&lt;/h2&gt;This one seemed easy at first but it isn't just because by design, setting the input textbox to readonly the widget will understand it as if we just wanted to limit the user to choose a date from the popup, disallowing any input text.&lt;br /&gt;&lt;br /&gt;What I want here is to block any way of the user to change the textbox value, either from the calendar popup or by direct input on the textbox.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Option 1: Disable Textbox&lt;/h2&gt;&lt;table width="100%" style="text-align:center"&gt;&lt;tr&gt;&lt;td width="50%" style="background-color: #DCDCDC;"&gt;&lt;b&gt;The good&lt;/b&gt;&lt;/td&gt;&lt;td width="50%" style="background-color: #DCDCDC;"&gt;&lt;b&gt;The bad&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Works!&lt;/td&gt;&lt;td&gt;Grays out the control to make it look disabled&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt;&lt;br /&gt;This would be a quick solution by just disable the textbox but it kind of shades the control and I want it to display its value with the same appearance as the other textboxes. Not aproved!&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Option 2: Bend the control&lt;/h2&gt;This datepicker widget has a lot of options, we just have to find a way to use them in our favor to achieve this "unsupported" behavior.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:js"&gt;&lt;input type="text" id="txtDate" readonly="readonly" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;&lt;br /&gt;$(document).ready(function () {&lt;br /&gt;   $('#txtDate').datepicker(&lt;br /&gt;     {&lt;br /&gt;        beforeShow: function (input, inst) &lt;br /&gt;        { inst.dpDiv = $('&lt;div style="display: none;"&gt;&lt;br /&gt;&lt;/div&gt;'); }&lt;br /&gt;     });&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;What did I do?&lt;br /&gt;On the Textbox you can see that I made it ReadOnly, but as I said, this alone still lets the user change the date from the calendar popup.&lt;br /&gt;To block the calendar popup I'm replacing it it an empty DIV element and to avoid unhandled complications I'm styling it as display: none.&lt;br /&gt;&lt;br /&gt;With this workaround the datepicker still thinks is showing the popup but infact nothing happens.&lt;br /&gt;&lt;br /&gt;This is kind of tricky but is pretty easy to do and works very well on all browsers.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;My recomendation to JQuery UI Team&lt;/h2&gt;This would be so much easier if we could only pass something like:&lt;br /&gt;showOn: "never"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-5531300516341184738?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/05/making-jquery-ui-datepicker-read-only.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-9121046324757970316</guid><pubDate>Mon, 23 May 2011 00:21:00 +0000</pubDate><atom:updated>2011-08-27T22:03:36.996+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Software</category><title>Free Video Editor for Cutting, Filtering and Encoding tasks</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://avidemux.razorbyte.com.au/avidemux_main.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;/a&gt;&lt;a href="http://avidemux.razorbyte.com.au/avidemux_logo.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://avidemux.razorbyte.com.au/avidemux_logo.png" /&gt;&lt;/a&gt;&lt;a href="http://avidemux.razorbyte.com.au/avidemux_main.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://avidemux.razorbyte.com.au/avidemux_main.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&amp;nbsp;&lt;a href="http://avidemux.razorbyte.com.au/"&gt;&lt;span style="font-size: x-large;"&gt;AVIDEMUX&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Today I had the need to change the audio encoding format of a video file without loosing any image quality and I didn't have a clue how to do it...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What I wanted to do was made without any effort but I had a peek on their &lt;a href="http://www.avidemux.org/admWiki/doku.php"&gt;wiki &lt;/a&gt;and it looks pretty huge.&lt;br /&gt;&lt;br /&gt;At the time of this post the current "stable" version is &lt;a href="http://avidemux.razorbyte.com.au/binaries/2.5/Milestone/2.5.4_%286714%29/avidemux_2.5.4_win32.exe"&gt;2.5.4 (32bit only)&lt;/a&gt;. I installed the latest beta version, &lt;a href="http://avidemux.razorbyte.com.au/binaries/2.5/SVN/7200/avidemux_2.5_r7200_win64.exe"&gt;7000 (64bit)&lt;/a&gt; and gave me zero problems.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Changing audio format maintaining video untouched&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-bfp7sDtfUuY/Tdmn9BLus9I/AAAAAAAAAH8/KgylsuUtF1Q/s1600/AVIDEMUX_Demo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="291" src="http://1.bp.blogspot.com/-bfp7sDtfUuY/Tdmn9BLus9I/AAAAAAAAAH8/KgylsuUtF1Q/s400/AVIDEMUX_Demo.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-9121046324757970316?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/05/free-video-editor-for-cutting-filtering.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-bfp7sDtfUuY/Tdmn9BLus9I/AAAAAAAAAH8/KgylsuUtF1Q/s72-c/AVIDEMUX_Demo.png' height='72' width='72'/><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-7668485660858718524</guid><pubDate>Wed, 18 May 2011 23:39:00 +0000</pubDate><atom:updated>2011-08-27T22:04:06.827+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>JQuery</category><category domain='http://www.blogger.com/atom/ns#'>JQGrid</category><title>jqGrid Quick Tips</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;table cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt; &lt;tr&gt;&lt;td colspan="2&amp;quot;"&gt;I'll use this post as a repository of quick tips so I'll be updating it on a regular basis... keep posted!&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt;&lt;h2&gt;Get it!&lt;/h2&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style="vertical-align: top;"&gt;&lt;br /&gt;&lt;a href="http://www.trirand.com/blog/"&gt;The blog&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:features"&gt;Features&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.trirand.com/blog/?page_id=6"&gt;Download&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jqgriddocs"&gt;Documentation&lt;/a&gt;&lt;br /&gt;&lt;a href="http://stackoverflow.com/questions/tagged/jqgrid"&gt;On StackOverflow&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="http://www.trirand.com/jqgridwiki/lib/exe/fetch.php?cache=&amp;amp;media=wiki:celledit.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="147" src="http://www.trirand.com/jqgridwiki/lib/exe/fetch.php?cache=&amp;amp;media=wiki:celledit.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;h2&gt;Licensing and Flavours&lt;/h2&gt;jqGrid is an open-source control registed under the GPL and MIT lincenses.&lt;br /&gt;Basically this means that it's FREE! and you can do quite anything with it.&lt;br /&gt;Read more about this &lt;a href="http://www.trirand.com/blog/?page_id=154"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;If you want to use the "side" versions of this control, specially wrapped and packaged for PHP, ASP.net Webforms and ASP.net MVC then you have to pay for them... but rust me when I say that all you need is on the Free package!!&lt;br /&gt;See the price list &lt;a href="http://www.trirand.net/licensing.aspx"&gt;here&lt;/a&gt;&lt;br /&gt;You can also access the payed versions website &lt;a href="http://www.trirand.net/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The feature set is a huge list and has a &lt;a href="http://stackoverflow.com/questions/tagged/jqgrid"&gt;awsome comunity on Stackoverflow&lt;/a&gt; that reply to your questions in no time.&lt;br /&gt;&lt;br /&gt;&lt;h2 style="background-color: darkgrey; border-bottom: 1px dashed #000; margin-bottom: 15px; width: 100%;"&gt;Columns&lt;/h2&gt;&lt;h3&gt;1. Hide a column&lt;/h3&gt;&lt;div style="border: dashed 1px #000; padding: 5px;"&gt;I'm putting this on here just because it's not the instinctive visible, it's called hidden!&lt;br /&gt;&lt;pre class="brush:js"&gt;colModel: [{ name: 'colName', hidden: true }]&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style="background-color: darkgrey; border-bottom: 1px dashed #000; margin-bottom: 15px; width: 100%;"&gt;Data&lt;/h2&gt;&lt;h3&gt;1. Refresh grid&lt;/h3&gt;&lt;div style="border: dashed 1px #000; padding: 5px;"&gt;If you need to refresh the grid from code just call:&lt;br /&gt;&lt;pre class="brush:js"&gt;$("#grid1").trigger("reloadGrid");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The tricky, and not to well documented part is if you want to refresh and select the disired page:&lt;br /&gt;&lt;pre class="brush:js"&gt;$("#grid1").trigger("reloadGrid", [{page:3}]);&lt;/pre&gt;This will refresh the frid and show it on page 3.&lt;br /&gt;&lt;br /&gt;With this you can refresh the current page:&lt;br /&gt;&lt;pre class="brush:js"&gt;var currentPage = $('#grid1').getGridParam('page');&lt;br /&gt;$("#grid1").trigger("reloadGrid", [{page: currentPage }]);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can also keep the current selection:&lt;br /&gt;&lt;pre class="brush:js"&gt;$("#grid1").trigger("reloadGrid", [{current:true}]);&lt;/pre&gt;&lt;br /&gt;Note that both page and selection settings can be used together.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style="background-color: darkgrey; border-bottom: 1px dashed #000; margin-bottom: 15px; width: 100%;"&gt;NavBar&lt;/h2&gt;&lt;h3&gt;1. Add custom buttons to the NavBar&lt;/h3&gt;&lt;div style="border: dashed 1px #000; padding: 5px;"&gt;&lt;pre class="brush:js"&gt;/* Add this line to allow advanced search using the toolbar button */&lt;br /&gt;$('#grid1').navGrid('#grid1pager', { search: true, edit: true, add: true, del: true }, {}, {}, {}, { closeOnEscape: true, multipleSearch: true, closeAfterSearch: true });&lt;br /&gt;&lt;br /&gt;/* Add this line to include a separator between buttons */&lt;br /&gt;$('#grid1').navSeparatorAdd("#grid1pager", { sepclass: 'ui-separator', sepcontent: '' });&lt;br /&gt;&lt;br /&gt;/* Add this line to include custom buttons on the toolbar */&lt;br /&gt;$('#grid1').jqGrid('navButtonAdd', "#grid1pager", { caption: "", buttonicon: "ui-icon-plusthick", onClickButton: function () { alert('Exporting!!!!!'); }, position: "last", title: "Export to Excel", cursor: "pointer" })&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style="background-color: darkgrey; border-bottom: 1px dashed #000; margin-bottom: 15px; width: 100%;"&gt;Search&lt;/h2&gt;&lt;h3&gt;1. Show the Advanced Search dialog from an external button&lt;/h3&gt;&lt;div style="border: dashed 1px #000; padding: 5px;"&gt;&lt;pre class="brush:js"&gt;function OpenSearchDialog() {&lt;br /&gt;     $("#grid1").jqGrid(&lt;br /&gt;          'searchGrid', { multipleSearch: true, overlay: false });&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3&gt;2. Show the filter toolbar&lt;/h3&gt;&lt;div style="border: dashed 1px #000; padding: 5px;"&gt;The filter toolbar is a bar that appears right bellow the column captions that allow filtering by each column. To make this toolbar visible use the following:&lt;br /&gt;&lt;pre class="brush:js"&gt;$('#grid1').jqGrid('filterToolbar', &lt;br /&gt;            { stringResult: true, searchOnEnter: false });&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2 style="background-color: darkgrey; border-bottom: 1px dashed #000; margin-bottom: 15px; width: 100%;"&gt;Selection&lt;/h2&gt;&lt;h3&gt;1. Get the ID of the selected row&lt;/h3&gt;&lt;div style="border: dashed 1px #000; padding: 5px;"&gt;&lt;pre class="brush:js"&gt;$('#grid1').jqGrid('getGridParam', 'selrow')&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3&gt;2. Get the row data&lt;/h3&gt;&lt;div style="border: dashed 1px #000; padding: 5px;"&gt;&lt;pre class="brush:js"&gt;var rowData = $("#grid1").jqGrid('getRowData', rowid);&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;rowid&lt;/b&gt;: is the id value set on the data source, &lt;b&gt;NOT&lt;/b&gt; the index of the row.&lt;br /&gt;&lt;br /&gt;This returns an object with the column names and value like:&lt;br /&gt;&lt;pre class="brush:js"&gt;{name="alex", address="here and there", age=34}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;so its easy then the get a value using:&lt;br /&gt;&lt;pre class="brush:js"&gt;var myName = rowData.name;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Be aware that&lt;/b&gt; the object will only have the columns configured on the colModel.Everything that may come on the datasource won't appear here.&lt;br /&gt;If you want to have values here that you don't want to show on the grid you must add the column to the colModel collection and set it to hidden: true&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/11321702-7668485660858718524?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/05/jqgrid-quick-tips.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-5372129453115759223</guid><pubDate>Mon, 02 May 2011 17:45:00 +0000</pubDate><atom:updated>2011-08-27T22:04:31.426+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Windows</category><title>Where's the Control Panel Mail Icon?!</title><description>This is for Windows Vista, 7 and 2008 Server where the Control Panel layout was redesigned. &lt;br /&gt;&lt;br /&gt;This is one think I barelly need but when I do I need a awfull lot of time to figure out.&lt;br /&gt;The last time I needed this was because I had a misconficured Exchange account on Outlook 2007 and the application just wouldn't start.&lt;br /&gt;&lt;br /&gt;If, for this or other reason, you need to access your mail account setting from the Control Panel just follow these simple but hidden steps.&lt;br /&gt;&lt;table&gt;&lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-hDRiyTf3LbY/Tb6-PT0JEwI/AAAAAAAAAHw/Csx-m2jgu0w/s1600/Open+Control+Panel.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="200" src="http://1.bp.blogspot.com/-hDRiyTf3LbY/Tb6-PT0JEwI/AAAAAAAAAHw/Csx-m2jgu0w/s200/Open+Control+Panel.png" width="163" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/td&gt; &lt;td&gt;1. Open Control Panel (duh!)&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-OkBRZr-rO1o/Tb7KJvlwr6I/AAAAAAAAAH4/Ir_ys8EynNo/s1600/Change+CP+View.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="200" src="http://1.bp.blogspot.com/-OkBRZr-rO1o/Tb7KJvlwr6I/AAAAAAAAAH4/Ir_ys8EynNo/s320/Change+CP+View.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;ol&gt;&lt;li&gt;Change the "View By" setting to &lt;b&gt;Large Icons&lt;/b&gt;&amp;nbsp;&lt;/li&gt; &lt;ul&gt;&lt;li&gt;This Action will reveal hidden icons on the Control Panel.&lt;/li&gt; &lt;/ul&gt;&lt;li&gt;One of them is the one you want: &lt;b&gt;Mail (32-bit)&lt;/b&gt;.&lt;/li&gt; &lt;/ol&gt;&lt;ul&gt;&lt;/ul&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;  &lt;/table&gt;&lt;br /&gt;Cheers!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-5372129453115759223?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/05/wheres-control-panel-mail-icon.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-hDRiyTf3LbY/Tb6-PT0JEwI/AAAAAAAAAHw/Csx-m2jgu0w/s72-c/Open+Control+Panel.png' height='72' width='72'/><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-67611653439131712</guid><pubDate>Mon, 18 Apr 2011 10:40:00 +0000</pubDate><atom:updated>2011-08-27T22:04:48.633+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>C#</category><title>Identify if type is Nullable and get its undelying type</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;Identifying if a type is nullable and getting its underlying (not nullable) type is something no one needs constantly but when we do it's not trivial to get just from intellisense.&lt;br /&gt;&lt;br /&gt;There is no IsNullable property in System.Type so we need to understand a bit how thing work.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: csharp"&gt;Type myType = (Guid?).GetType(); // dummy type for this example&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;For short:&lt;/h2&gt;&lt;pre class="brush: csharp"&gt;Type myBaseType = Nullable.GetUnderlyingType(myType) ?? myType;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;If you need a bit more information:&lt;/h2&gt;&lt;pre class="brush: csharp"&gt;myType.IsGenericType();&lt;br /&gt;myType.GetGenericTypeDefinition() == typeof(Nullable&lt;&gt;)  &lt;br /&gt;myType.GetGenericArguments()[0]&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;The Long story:&lt;/h2&gt;The basic idea of a nullable type is that it is a type wrapped in the generic type NULLABLE&lt;&gt;.&lt;br /&gt;So to know if a type is nullable we need to:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Evaluate if the type is generic&lt;/li&gt; &lt;li&gt;Being generic, lets check if it's Nullable&amp;lt;&amp;gt;&lt;/li&gt; &lt;li&gt;If so, get its first generic argument that holds the base type.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If you run a QuickWatch on a nullable Guid? type you'll get something like: &lt;/br&gt;&lt;br /&gt;System.Nullable`1[System.Guid] &lt;/br&gt;&lt;br /&gt;System.Nullable`1[] is the way .net serializes NULLABLE&amp;lt;&amp;gt; &lt;/br&gt;&lt;br /&gt;The value within [] is its undelying type we're looking for.&lt;/li&gt; &lt;/ul&gt;&lt;/li&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-67611653439131712?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/04/identity-if-type-is-nullable-and-get.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-4513091015605986386</guid><pubDate>Sat, 12 Mar 2011 02:20:00 +0000</pubDate><atom:updated>2011-08-27T22:05:00.131+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Windows</category><title>Windows Server 2008 more like a Windows 7 workstation</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.distility.com/Portals/62026/images/Mouse%20Pointer.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="112" src="http://www.distility.com/Portals/62026/images/Mouse%20Pointer.png" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I don't like to write this kind of ponter blog posts but here's one.&lt;br /&gt;&lt;br /&gt;What I've found was a website that pretty much diggs the whole thing down when it comes to making a Windows Server 2008 look and feel like a Windows 7 workstation.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I found this through Google when I was searching for a way to enable image thumbnails to appear on the Explorer of my Windows 2008 R2 box.&lt;br /&gt;&lt;br /&gt;On the website you'll not only find the explanation of how to enable "that" feature but also an application that does the job for you by simply pressing a button.&lt;br /&gt;&lt;br /&gt;I'll leave it here for further reference because I know I'll need it again sooner or later.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Website:&lt;/b&gt; &lt;a href="http://www.win2008workstation.com/"&gt;www.win2008workstation.com&lt;/a&gt;&lt;br /&gt;&lt;b&gt;Tool:&lt;/b&gt; &lt;a href="http://www.win2008workstation.com/win2008/windows-server-2008-workstation-converter"&gt;windows-server-2008-workstation-converter&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-4513091015605986386?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/03/windows-server-2008-more-like-windows-7.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-3389452677677052027</guid><pubDate>Mon, 28 Feb 2011 16:01:00 +0000</pubDate><atom:updated>2011-08-27T22:05:47.214+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>JSON</category><category domain='http://www.blogger.com/atom/ns#'>C#</category><title>DateTime, .net JavaScriptSerializer, JSON and Javascript</title><description>If you're using JavaScriptSerializer and are having trouble handling the way it serialized DateTime types to JSON then read on, this might help.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Scenario&lt;/h2&gt;On a page I have:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;an html textbox element set as a JQuery datepicker&lt;/li&gt; &lt;li&gt;a button that makes an AJAX call and returns a date and populates the above control&lt;/li&gt; &lt;li&gt;The method I call on that ajax request is using the .net JavaScriptSerializer that serializes dates the following way:&lt;br /&gt;&lt;pre class="brush: js"&gt;/Date(628318530718)/&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt; &lt;li&gt;Im using the following to populate the textbox:&lt;br /&gt;&lt;pre class="brush: js"&gt;$('#txtDate').datepicker('setDate', item.Date);&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt; &lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;Problem&lt;/h2&gt;On IE the textbox displays the the following: NaN/NaN/NaN&lt;br /&gt;Somehow FF is able to unwrap this and show the correct value on the textbox.&lt;br /&gt;Nice! :(&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Solution&lt;/h2&gt;We must unwrap that value our-selfs like shown bellow:&lt;br /&gt;&lt;pre class="brush: js"&gt;myDate =  new Date(parseFloat(item.Date.slice(6, 19)));&lt;br /&gt;$('#txtDate').datepicker('setDate', myDate);&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-3389452677677052027?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/02/datetime-net-javascriptserializer-json.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-4258158504385735227</guid><pubDate>Tue, 22 Feb 2011 20:49:00 +0000</pubDate><atom:updated>2011-08-27T22:06:16.195+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>ASP.net</category><title>Accessing the Session object from within an HttpHandler (ASHX)</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;By default if you try to use the line above you'll get an impressive null&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:csharp"&gt;var mySession = System.Web.HttpContext.Current.Session;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To make this work, the only thing you have to do is implement the &lt;br /&gt;System.Web.SessionState.IReadOnlySessionState on your handler.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush:csharp"&gt;using System.Web.SessionState;&lt;br /&gt;&lt;br /&gt;public abstract class BaseHandler : IHttpHandler, IReadOnlySessionState {&lt;br /&gt;   public void ProcessRequest(HttpContext context)&lt;br /&gt;   {&lt;br /&gt;       var mySession = System.Web.HttpContext.Current.Session;&lt;br /&gt;       // your code here //&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And that's it!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-4258158504385735227?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/02/accessing-session-object-from-within.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-4210758835220077547</guid><pubDate>Tue, 22 Feb 2011 09:48:00 +0000</pubDate><atom:updated>2011-08-27T22:06:26.807+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Software</category><title>Open Source vector graphics editor</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://inkscape.org/images/header-logo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://inkscape.org/images/header-logo.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;a href="http://inkscape.org/screenshots/gallery/thumbs/inkscape-0.48-ferrari_thumb.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" src="http://inkscape.org/screenshots/gallery/thumbs/inkscape-0.48-ferrari_thumb.png" /&gt;&lt;/a&gt;Have you ever needed to create or edit a vector image file and didn't have an application to do so?&lt;br /&gt;Now you have! :)&lt;br /&gt;&lt;br /&gt;The coolest thing about this application is that opens Corel Draw *.cdr files.&lt;br /&gt;&lt;br /&gt;Download it &lt;a href="http://inkscape.org/"&gt;here&lt;/a&gt;!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-4210758835220077547?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/02/open-source-vector-graphics-editor.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-621530851493173556</guid><pubDate>Thu, 27 Jan 2011 19:26:00 +0000</pubDate><atom:updated>2011-08-27T22:06:47.067+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>JQuery UI</category><category domain='http://www.blogger.com/atom/ns#'>JQuery</category><title>JQuery UI Autocomplete with ID</title><description>&lt;a href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=361529" rel="tag" style="display:none;"&gt;CodeProject&lt;/a&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://jquery.org/wp-content/uploads/2010/01/JQuery_UI_logo_color_onwhite-300x72.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="47" src="http://jquery.org/wp-content/uploads/2010/01/JQuery_UI_logo_color_onwhite-300x72.png" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;JQuery UI &lt;a href="http://jqueryui.com/demos/autocomplete/"&gt;auto-complete widget&lt;/a&gt; is great.&lt;br /&gt;Basically it just works and is very easy to customize.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;The Problem&lt;/h2&gt;By default this control supports the retrieval of Text and Value for the selected item but still needs one tweek or two.&lt;br /&gt;&lt;br /&gt;What I'm about to show here is how to:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Use the basics of the control&lt;/li&gt; &lt;li&gt;Use and store the item ID&lt;/li&gt; &lt;li&gt;Don't show the ID on the textbox while selecting an item&lt;/li&gt; &lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;The Basics&lt;/h2&gt;The basic idea is to pass a json array of strings and it will do the rest.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: js" name="code"&gt;var req = ["item 1", "item 2", "item 3"];&lt;br /&gt;$('#txtRequestor').autocomplete({ source: req });&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h2&gt;Storing the selected item ID&lt;/h2&gt;In real world nothing is this simple and we usually have an ID for each item on the list. We may use this ID in several ways but the more obvious is to store the selected ID on the database.&lt;br /&gt;This is still very simple, just feed the control some json objects instead of simple strings. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note that each item must, &lt;u&gt;at least&lt;/u&gt; have the following structure:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;label&lt;/b&gt; - Represents the display text&lt;/li&gt; &lt;li&gt;&lt;b&gt;value&lt;/b&gt; - Represents the item value (the ID in our case)&lt;/li&gt; &lt;/ul&gt;&lt;pre class="brush: js" name="code"&gt;var req = [&lt;br /&gt;  {"label":"item 1", "value":1}, &lt;br /&gt;  {"label":"item 2", "value":2}, &lt;br /&gt;  {"label":"item 3", "value":3}];&lt;br /&gt;&lt;br /&gt;$('#txtRequestor').autocomplete({ &lt;br /&gt;     source: req,&lt;br /&gt;     change: function (event, ui) { alert(ui.item.value); } });&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Using the &lt;i&gt;change&lt;/i&gt; event we can handle the ID selected item ID and store it on a variable for later use.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Not showing the value (ID) on the textbox&lt;/h2&gt;If you tried the code above you got anoyed with the fact that the our ID is being shown on the rextbox while we select an item from the list. Didn't you?! :)&lt;br /&gt;&lt;br /&gt;To avoid this is very simple, we must only change our json object a little as follows.&lt;br /&gt;&lt;pre class="brush: js" name="code"&gt;var req = [&lt;br /&gt;  {"label":"item 1", "value":"item 1", "id": 1}, &lt;br /&gt;  {"label":"item 2", "value":"item 2", "id": 2}, &lt;br /&gt;  {"label":"item 3", "value":"item 1", "id": 3}];&lt;br /&gt;&lt;br /&gt;$('#txtRequestor').autocomplete({ &lt;br /&gt;     source: req,&lt;br /&gt;     change: function (event, ui) { alert(ui.item.id); } });&lt;br /&gt;&lt;/pre&gt;As you can see I just added a new property to each item for our id value. This will foul the control passing the same value as both display and value and have a "backup" property that holds the actual id value.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-621530851493173556?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/01/jquery-ui-autocomplete-with-id.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-11321702.post-5912955370137581124</guid><pubDate>Sun, 16 Jan 2011 21:15:00 +0000</pubDate><atom:updated>2011-08-27T22:06:59.045+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>Software</category><title>Resizing your images from Windows explorer</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=ImageResizer&amp;amp;DownloadId=81993" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="278" src="http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=ImageResizer&amp;amp;DownloadId=81993" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;a href="http://imageresizer.codeplex.com/"&gt;Image Resizer for Windows&lt;/a&gt; is a Free and Open Source quick-win addin for windows.&lt;br /&gt;Just right-click one or more pictures and select "Resize Pictures".&lt;br /&gt;&lt;br /&gt;You have some predefined options on "Basic UI Mode" but hitting the "Advanced" button you can define a custom size.&lt;br /&gt;&lt;br /&gt;The result is great and you won't have to use &lt;a href="http://www.getpaint.net/"&gt;Paint.net&lt;/a&gt; or such tools to do such trivial task.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://imageresizer.codeplex.com/"&gt;Get it here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/11321702-5912955370137581124?l=www.instanceofanobject.com' alt='' /&gt;&lt;/div&gt;</description><link>http://www.instanceofanobject.com/2011/01/resizing-your-images-from-windows.html</link><author>noreply@blogger.com (Alexandre Simoes)</author><thr:total>0</thr:total></item></channel></rss>
