Thanks Sarathy , your solution may also work but I ended with following solution:
1)Creating custom model binder like following
public class EmptyStringModelBinder : System.Web.Mvc.IModelBinder
{
public object BindModel(System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ModelBindingContext bindingContext)
{
string key = bindingContext.ModelName;
ValueProviderResult val = bindingContext.ValueProvider.GetValue(key);
if (val != null)
{
var s = val.AttemptedValue as string;
if (s != null && (s.IsEmpty() || s.Trim().IsEmpty()))
{
return null;
}
return val.AttemptedValue;
}
return null;
}
}
2)Mark action method parameter with ModelBinder attribute
public ActionResult UpdateAttribute(int id,
int AttributeTypeId,
int? Number_Value,
decimal? Money_Value,
[ModelBinder(typeof(EmptyStringModelBinder))]string Text_Value)
or you could add this model binder at configuration. it will inspect all string parameters and replace empty string with null(maybe not desired)