This code ...
1 2 3 4 5 6 7 8 9 | [BindingName( "show_field" )] public string ShowFieldRaw { set { _showFieldRaw = value; ShowFields = _showFieldRaw.Split( ',' ); } } |
...won't get invoked on BindProperty:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | public class PropertyBinder : DefaultModelBinder { protected override void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, System.ComponentModel.PropertyDescriptor propertyDescriptor) { base .BindProperty(controllerContext, bindingContext, propertyDescriptor); /* if (propertyDescriptor.Name == "ShowFieldRaw") throw new Exception(controllerContext.HttpContext.Request["show_field"]); */ foreach (var p in propertyDescriptor.Attributes) { if (p.GetType() == typeof (BindingNameAttribute)) { var b = p as BindingNameAttribute; object value = controllerContext.HttpContext.Request[b.Name]; if (propertyDescriptor.PropertyType == typeof ( int )) propertyDescriptor.SetValue(bindingContext.Model, Convert.ToInt32(value)); else propertyDescriptor.SetValue(bindingContext.Model, value); break ; } } //foreach } } // class PropertyBinder |
So you must modify your model and put a getter on the property to make that property be included on BindProperty method:
1 2 3 4 5 6 7 8 9 10 11 12 | [BindingName( "show_field" )] public string ShowFieldRaw { set { _showFieldRaw = value; ShowFields = _showFieldRaw.Split( ',' ); } get { return _showFieldRaw; } } |
Related to error on jQuery AJAX Combobox I debugged: http://code.google.com/p/asp-net-mvc-backed-jquery-ajax-combobox/downloads/list
No comments:
Post a Comment