ViewComponent with Nested Kendo Control
1 Answer 7 Views
Top achievements
Rank 1
A asked on 05 May 2021, 05:40 PM

I have created a ViewComponet that contains a Kendo textbox.

		public async Task<IViewComponentResult> InvokeAsync(ModelExpression aspFor)
			return View("MyView", new MyModel(){AspFor = aspFor ... });

My AspFor when it gets to the view is an instance of a ModelExpression, but the Kendo controls are expecting a string for the "Expression()" method.

How do I bind this Kendo control to the instance of the ModelExpression?

The TextBoxFor isn't happy and attempting to convert the ModelExpression instance back to its string doesn't result in HTML that contains all of the proper attributes on it.



1 Answer, 1 is accepted

Sort by
Telerik team
answered on 10 May 2021, 03:53 PM


Thank you for the provided code snippet.

The method "Expression()" waits for a String because it expects only the Name of the ModelExpression to be passed. Actually, the .Expression() would be only setting the Name of the TextBox rather than applying the view context and the model explorer. It is actually left due to legacy reasons and we do recommend using the TextBoxFor instead.

You could pass a lambda expression to the widget and it would do everything that you would expect an editor to do (use the view context and create all the needed attributes for the input element):

@Html.Kendo().TextBoxFor(m => m.myField)

Would you please give a try to this example and let me know if it works properly at your end?


Best, Mihaela Lukanova Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at

Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question