Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > NumericTextBox > EditorTemplate with NumericTextBox

Not answered EditorTemplate with NumericTextBox

Feed from this thread
  • Justin Bigelow avatar

    Posted on Oct 12, 2011 (permalink)

    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.

    Reply

  • Hartmut Kocher avatar

    Posted on Nov 10, 2011 (permalink)

    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > NumericTextBox > EditorTemplate with NumericTextBox
Related resources for "EditorTemplate with NumericTextBox"

ASP.NET MVC NumericTextBox Features  |  Documentation  |  Demos  |  Telerik TV ]