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

[Solved] EditorTemplate with NumericTextBox

1 Answer 71 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Justin Bigelow
Top achievements
Rank 1
Justin Bigelow asked on 12 Oct 2011, 09:45 PM
What is the proper convention for using a NumericTextBox in an Editor Template. I have tried the standard ASP.NET MVC convention with an empty string for the name: 

Html.Telerik().PercentTextBox().Name("").Value(Model)

But I get the following exception:
[ArgumentException: "value" cannot be null or empty.]
   Telerik.Web.Mvc.Infrastructure.Guard.IsNotNullOrEmpty(String parameter, String parameterName) +142
   Telerik.Web.Mvc.UI.ViewComponentBase.set_Name(String value) +21

I can give the control a name like: Html.Telerik().PercentTextBox().Name("RateQuote_QualRate").Value(Model) but then the model binding only works for that particular field and it's not a true template.

I'm using release 2011.2.712

Thank you.

1 Answer, 1 is accepted

Sort by
0
Hartmut Kocher
Top achievements
Rank 1
answered on 10 Nov 2011, 01:56 PM
Use a template similar to this:
@model double
 
@(Html.Telerik().NumericTextBox()
        .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
        .InputHtmlAttributes(new { style = "width:100%" })
        .Value(Model)
)

This gets the control name from ViewData.

Kind regards
Hartmut
Tags
NumericTextBox
Asked by
Justin Bigelow
Top achievements
Rank 1
Answers by
Hartmut Kocher
Top achievements
Rank 1
Share this question
or