Monthly Archives: August 2010

Monthly Archives: August 2010

Using the jQuery UI Datepicker with Fancybox

Posted on by Joe in jQuery | Leave a comment

I just wasted what seems to be far too much of my life (about 30 minutes), trying to figure out why the jQuery UI Datapicker wouldn’t work when it was applied to a text box within a Fancybox. It turns out it was working, but it was being placed behind the Fancybox which had it’s z-index set to 1101. Adding the following CSS worked a treat

ASP.NET MVC authorize attribute using action parameters with the ActionFilterAttribute

Posted on by Joe in C#, MVC | 1 Comment

ASP.NET MVC provides the AuthorizeAttribute which ensures there is a logged in user. You can also provide parameters to restrict actions or controllers to only be accessible to certain roles or users. You can also create your own custom authorization attribute derived from AuthorizeAttribute to provide any custom authorization. In addition to this general authorization you may want to restrict access based on the current user and a parameter from the action. For example, say you have an action method …

Linq lambda expression IEqualityComparer for IEnumerable.Distinct and Except

Posted on by Joe in C#, Linq | 2 Comments

One of the things that annoys me with the IEnumerable.Distinct method is that it has no overload allowing you to give a lambda expression to specify a particular property to perform the distinction, you have to give an IEqualityComparer. I did a quick Google search and found this post. The guy here provides the following LambdaComparer class:

ASP.NET MVC Textbox with characters remaining HtmlHelper extension method

Posted on by Joe in C#, JavaScript, MVC | 3 Comments

Here is a couple of HtmlHelper extension methods, CharactersRemainingTextBoxFor and CharactersRemainingTextAreaFor which render a textbox/textarea with a span tag that displays the number of characters remaining.  They also include the JavaScript to make this work, and to limit the number of characters entered in the textarea. The maximum limit comes from the model by using the StringLengthAttribute. Download source

WordPress automatic upgrade timeout

Posted on by Joe in Personal | Leave a comment

I was just trying to upgrade my wordpress blog to version 3 using the automatic upgrade but it kept stopping after 30 seconds while unpacking the update. I checked on my server and it hadn’t completed the unpacking.  I loaded up the PHP.ini file and after a look around found the max_execution_time setting which was set to 30 seconds. I increased this and the update worked fine.