Thursday, October 4, 2012

tkglaser.net: Waiting spinner for long-running form submits in A...

tkglaser.net: Waiting spinner for long-running form submits in A...: In the application I'm currently working on, I have a search form, where you can specify a number of parameters, press the search button, an...

Wednesday, September 5, 2012

Configure log4net to read config from web.config


// Tell log4net to watch the following file for modifications:

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Web.config", Watch = true)]


For App.Config:
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
Add above code inside AssemblyInfo.cs!!

Tuesday, March 27, 2012

Preserve Telerik MVC Grid Checkboxes When Paging

var selectedIds = [];

$(document).ready(function () {
//wire up checkboxes.
$('#YOUR_GRID_ID :checkbox').live('change', function (e) {
var $check = $(this);
//console.log($check);
if ($check.is(':checked')) {
//add id to selectedIds.
selectedIds.push($check.val());
}
else {
//remove id from selectedIds.
selectedIds = $.grep(selectedIds, function (item, index) {
return item != $check.val();
});
}
});
});

function onDataBound(e) {
//restore selected checkboxes.
$('#YOUR_GRID_ID :checkbox').each(function () {
//set checked based on if current checkbox's value is in selectedIds.
$(this).attr('checked', jQuery.inArray($(this).val(), selectedIds) > -1);
});
}

Source

Monday, February 27, 2012

LINQ to Object - Distinct()

Have a read through K. Scott Allen's excellent post here:

And Equality for All ... Anonymous Types

The short answer:

Turns out the C# compiler overrides Equals and GetHashCode for anonymous types. The implementation of the two overridden methods uses all the public properties on the type to compute an object's hash code and test for equality. If two objects of the same anonymous type have all the same values for their properties – the objects are equal.

So it's totally safe to use the Distinct() method on a query that returns anonymous types.