In my application, I am trying to split the Date and Time from and DateTime field so I can put a jQuery date picker on the date. I found Hanselman\'s code for splitting the
TryGetValue()
is not a member of System.Web.Mvc.IValueProvider
. I suspect he has a custom extension which looks something like:
public static bool TryGetValue(this IValueProvider valueProvider, string key, out ValueProviderResult result) {
try {
result = valueProvider.GetValue(key);
return true;
}
catch {
result = null;
return false;
}
}
Update
TryGetValue()
is not an extension method, but rather it is a method on the type IDictionary
. The type of bindingContext.ValueProvider
has changed since MVC1 as @mootinator indicated. It's possible you can just ignore the call to TryGetValue()
and instead call GetValue()
and check the result for null. I'm not sure if it will throw an exception as I haven't tested it, so try that first.