Geeks With Blogs

News Google

Nick Harrison Blog<Nick>.Next() January 2013 Entries
50 Ways to Avoid, Find and Fix ASP.NET Performance Issues
Red Gate has published a new eBook  50 Ways to Avoid, Find and Fix ASP.NET Performance Issues.

You can download it for free.    They created their list by asking developers to contribute some of their favorite tips.

Check it out.    What is your favorite tip?  What do you think they missed? 

Posted On Wednesday, January 23, 2013 10:58 AM

Extending DateTime adding the good stuff
The DateTime struct in DotNet is well thought out, but they missed a few critical things that I find myself often needing. Fortunately with extension methods, we can easily fill in the gaps . When doing date specific logic, I often need the first day of the month and the last day of the month. You might need this to give the date ranges on a report or individually to set a deadline or well they just come in handy. 1: public static DateTime FirstDayOfMonth(this DateTime value) 2: { 3: return new DateTime(value.Year, ......

Posted On Wednesday, January 23, 2013 9:30 AM

Simple way to bind an Enum to a DropDownList in MVC
I have always been surprised that this was not already baked into the framework, but it turns out it is fairly easy to add. There are just a few steps. In the end, we want a drop down that will list the valid values from the enumeration. We will start by creating a new Editor Template. The template itself is fairly straight forward: <%@ Control Language="C#" Inherits="System.Web.Mvc.Vi... %> <% Func<object, string> GetDisplayName = o => { var result = null ......

Posted On Wednesday, January 16, 2013 1:15 PM

jQuery snippet to make fieldsets collapsible
I often will put stuff like report filters or control break groups inside fieldsets.Its also nice to group related input fields. This snippet will automatically wire up event handlers to allow you to show and hide the contents of the fieldset when the user clicks on the legend.$(document).ready(fu... () { $('legend').click(function () { var $this = $(this); var parent = $this.parent(); var contents = parent.contents().not(this); if (contents.length > 0) { $"contents", contents.remove()); ......

Posted On Tuesday, January 15, 2013 4:04 PM

Have you seen Chosen?
Chosen just may be the definitive jQuery plugin for cleaning up drop downs in your MVC applications.Add this to your document ready event handler: $("select").chosen();and enjoy the magic. Everything else works seamlessly. You don't have to worry about binding. It still works as expected.If you have wired up an onchange event handler, you have a little bit of work to do but not much and the look is quite impressive.As an added bonus for long drop down lists, the default behavior gives you a searchable ......

Posted On Tuesday, January 15, 2013 11:57 AM

Add a drop shadow across the top of your page.
This is a subtle trick to add some depth to your page. By adding a drop shadow across the top of your page, it looks like the page slides up under the toolbar. Subtle affect but nice and easy to achieve. No changes needed to your page, and this can easily be added to any style sheet. Works with any browser with minimal CSS3 compliance. body:before { content:""; position:fixed; top:-10px; left:0; width:100%; height:10px; -webkit-box-shadow:0px 10px 20px rgba(0,0,0,.9); -moz-box-shadow:0px 10px 20px ......

Posted On Friday, January 11, 2013 2:49 PM

Easily Add a Table of Contents to Any Web Page with jQuery
This snippet will add a list of links to every named anchor in your web page. Each link will have an associated click event handler to animate scrolling to that section. I hope you find this useful. First we build up our links. We use a jQury selector to find all of the anchor tags with a name attribute: var toc = ""; $("a[name]").each(function (index, e) { toc += "<li><a href='#' onclick=\"scrollToAnchor('" +$(e).prop("name")+"')\">" + $(e).prop("name") + "</li>"; }); If you are ......

Posted On Friday, January 11, 2013 9:18 AM

Copyright © Nick Harrison | Powered by: