Thursday 15 January 2015

ASP.NET MVC How to check for Null on bindingContext.ValueProvider.GetValue -


Sorry for this question, but got stuck in IM.

Enhances the dynamic control of my thoughts, maybe there is not a post while saving (save), so I have to check that the key \ value exists before trying to get the value or No. Code breaks down, but it shows what is trying to do

  public class AccountFormBinder: IModelBinder {Public Object BindModel (Controller Contributing Controller Contintbox, ModelBindingContext Binding Containbox) {AccountEdit updateAccount = New AccountEdit (); If (! String.IsNullOrEmpty (bindingContext.ValueProvider ("ConfirmationMessage"). Convertro (as string (typed string)) {updateAccount.EmailSettings.nMessage = (string) bindingContext.ValueProvider.GetValue ("Message"). ConvertTo (typeof (string)); Public Object Bind Models (Controller Contents Controller Contains, ModelBading Contact Binding Contents) {}    

 ValueProviderResult value = bindingContext.ValueProvider.GetValue (" blah "); string a = string; empty; if (value! = Null) a = value, value attempted; return ;}    

No comments:

Post a Comment