init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
15
KretaWeb/ModelBinder/Mvc/StringTrimModelBinder.cs
Normal file
15
KretaWeb/ModelBinder/Mvc/StringTrimModelBinder.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System.Web.Mvc;
|
||||
|
||||
namespace Kreta.Web.ModelBinder.Mvc
|
||||
{
|
||||
public class StringTrimModelBinder : IModelBinder
|
||||
{
|
||||
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
|
||||
{
|
||||
var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
|
||||
var attemptedValue = value?.AttemptedValue;
|
||||
|
||||
return string.IsNullOrWhiteSpace(attemptedValue) ? null : attemptedValue.Trim();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue