Using the jQuery UI Datepicker with Fancybox

0

Posted by Joe | Posted in jQuery | Posted on 25-08-2010

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

#ui-datepicker-div
{
    z-index: 1102 !important;
}

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

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

1

Posted by Joe | Posted in C#, MVC | Posted on 19-08-2010

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 to edit the details of a product.  You would pass the ID of the product to the action method, and you may only want certain users to be able to edit this particular product.  The AuthorizeAttribute doesn’t allow you to do this but you can create your own attribute derived from ActionFilterAttribute which gives you the desired result.

Read the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

Linq lambda expression IEqualityComparer for IEnumerable.Distinct and Except

2

Posted by Joe | Posted in C#, Linq | Posted on 17-08-2010

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:

Read the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

ASP.NET MVC Textbox with characters remaining HtmlHelper extension method

3

Posted by Joe | Posted in C#, JavaScript, MVC | Posted on 14-08-2010

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

Read the rest of this entry »

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

WordPress automatic upgrade timeout

0

Posted by Joe | Posted in Personal | Posted on 14-08-2010

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.

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit