We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to prevent the default behavior of MVC converting String.Empty to null values?

The default behavior of MVC to convert String.Empty to null values while binding model values from the client to server-end. Because of this, Empty String (“ ”) values formed in the filtered query will be changed to the null values while receiving them in the server-end.

To overcome this problem, DefaultModelBinder can be inherited and prevent the conversion of String.Empty to the null values.

Razor:

 

 

 

Check the result after and before applying the Model binder.

Figure 1. Values before applying Model Binder

Figure 2. Values after applying Model binder

Article ID: Published Date: Last Revised Date: Platform: Control:
8932 07/10/2018 07/10/2018 ASP.NET MVC Grid
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon