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

Returning razor expression from a Controller Action

3 Answers 75 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 29 Jul 2015, 04:46 PM

Hello,

 I have an ASP.NET MVC app using Telerik MVC controls and I need to return a Razor expression from the controller action and have it rendered in the view as razor. For example, I need to return the following in my model to the view:

 "@(Html.Kendo().CheckBox().Name(\"eq1\").Checked(true).Label(\"Rear side airbags\"));";

 

And have it rendered correctly as a checkbox in the view. All I can get it to do is render the text itself. 

 

Thanks,

 

Michael

3 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 31 Jul 2015, 11:20 AM

Hello Mike,

 

Such approach is not supported. The problem is that the expression will not be evaluated and shown as Kendo UI component but will be evaluated as a string. I believe it will be the same behavior with the built-in .net controls as well.

 

Regards,
Kiril Nikolov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mike
Top achievements
Rank 1
answered on 31 Jul 2015, 01:47 PM

Hi Kiril,

 That's what I thought but I was hoping there was some kind of trick or something where I could get the string reevaluated in some way. Kind of like @Html.Raw() where it would be @Razor.Eval(). I figured I'd check here just in case.

 Thanks for the reply.

 

Michael

0
Kiril Nikolov
Telerik team
answered on 03 Aug 2015, 08:18 AM

Hello Mike,

 

I am afraid that we do not have such implementation currently, that works around this issue.

 

Regards,
Kiril Nikolov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Mike
Top achievements
Rank 1
Share this question
or