views:

166

answers:

0

I am extending the DefaultModelBinder class in order to do some custom model binding. I am overriding the BindProperty method like so:

protected override void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, System.ComponentModel.PropertyDescriptor propertyDescriptor)
        {
            if (propertyDescriptor.PropertyType == typeof(DateTime?))
            {
                ValueProviderResult valueResult;
                bindingContext.ValueProvider.TryGetValue(bindingContext.ModelName + "." + propertyDescriptor.Name, out valueResult);
                if (valueResult == null && bindingContext.FallbackToEmptyPrefix == true)
                {
                    bindingContext.ValueProvider.TryGetValue(propertyDescriptor.Name, out valueResult);
                }

My models are not defined with a prefix, IE: Not like <%= Html.TextBox("ModelName.ProjectName") %> But like <%= Html.TextBox("ProjectName") %>

However the bindingContext.FallbackToEmptyPrefix is set to false above, so that the value of the field won't be grabbed. Should i just ignore/set the FallbackToEmptyPrefix property somewhere?