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

[Solved] Customizing an elements form name

2 Answers 34 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jack
Top achievements
Rank 1
Jack asked on 04 Jan 2011, 06:24 PM
Our company uses a custom binding-scheme with custom element naming. We don't use the default HtmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName to generate element names, but our own. We are now trying to incorporate the Telerik asp.net mvc controls in our site. But the only way so far to let them work with our custom binding is to set the name of each individual element.
Html.Telerik().DatePickerFor(m => m.Date).Name(Html.GetName(m => m.Date))
(Where Html.GetName() uses our custom naming to generate the name)

This 'solution' is obviously not elegant and not very wrist-friendly. In your ViewComponentFactory there is a method GetName(), but it is private.
And I didn't find a way to override the implementation of TemplateInfo.GetFullHtmlFieldName().

Is there a way to change the naming of form elements globally, other than custom building Telerik.Mvc.dll from source?

Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
w.vos
Top achievements
Rank 1
answered on 12 Jan 2011, 05:43 PM
I solved this issue using a proxy class ( MyOwnViewComponentFactory<TModel> : ViewComponentFactory ).
There is still one problem though. The ComboBox always adds "-input" to its name.
Imho this is not expected behavior, when the name is explicitly set, it should use that name. Or is there some rationale to it?
0
w.vos
Top achievements
Rank 1
answered on 13 Jan 2011, 12:31 PM
> The ComboBox always adds "-input" to its name....

My bad. I wasn't paying attention, it works as expected.
Tags
General Discussions
Asked by
Jack
Top achievements
Rank 1
Answers by
w.vos
Top achievements
Rank 1
Share this question
or