This is a migrated thread and some comments may be shown as answers.

Basic binding to model not working

1 Answer 57 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 31 Mar 2014, 04:54 PM
I am admittedly new to MVC and this may be something very simple that I am missing, but I am at a complete loss as to what else to do other than post here.  I have a model with a basic property called height:

public class BasicInformation
{      
      [Display(Description = "Patient's height", Name = "Height (Inches):")]       
      [Required(AllowEmptyStrings = false, ErrorMessage = "Height requires a value to be entered.")]       
      [Range(12, 96)]       
      public double Height { get; set; }
}


I am creating a new basic information and passing to the view when I call the view:

BasicInformation bi = new BasicInformation(); 
return View("Step2", bi);


Now in my view I am binding to this model using:

@(Html.Kendo().NumericTextBoxFor<double>(model => model.Height).Name("txtHeight").Decimals(0).Format("##")
)


My problem is that when I pass the model object to my next method, the value for height has not been updated.  The min & max seems to be working based on the range attribute from the model so it seems as though that part is connected properly.  Also if I use the basic html controls (see below) then it works fine.

@Html.EditorFor(model => model.Height)

I have tried to use several different Telerik controls and I am having the same problem with all the controls.  Please explain what I am doing wrong or have not set on the Telerik control to have the control save the value on the model.

Thanks in advance,
Lee 

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 01 Apr 2014, 10:53 AM
Hello Lee,

When a strongly-typed extension is used there is no need to set the name manually as the widget sets it automatically based on the expression value. Check this help topic to see how to solve this issue.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
General Discussions
Asked by
Lee
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or