Skip to content

Instantly share code, notes, and snippets.

View timhobbs's full-sized avatar

Tim Hobbs timhobbs

View GitHub Profile
@timhobbs
timhobbs / MaximumWeightAttribute.cs
Created October 22, 2011 19:29
MaximumWeightAttribute custom attribute - usage [MaximumWeight("PropertyName", "PropertyValue", MaxWeightInt)]
public class MaximumWeightAttribute : ValidationAttribute, IClientValidatable {
private const string ERRORMSG = "Weight must not exceed {0} lbs.";
public string DependentProperty { get; set; }
public string DependentValue { get; set; }
public int MaximumWeight { get; set; }
public MaximumWeightAttribute(string dependentProperty, string dependentValue, int maximumWeight) {
this.DependentProperty = dependentProperty;
@timhobbs
timhobbs / DynamicDropDownsHelper.cshtml
Created October 22, 2011 10:56
Razor dynamic drop down helper
@helper DynamicDropDowns() {
<script type="text/javascript">
function listChanged($list, $target, url) {
var listId = $list.val();
if (listId == "") { // User selected first option, so clear and disable the list
$target.empty();
enableList($target, false);
return;
}
$.getJSON(url, { id: listId }, function (data) {