Returning razor expression from a Controller Action

4 posts, 0 answers
  1. Mike
    Mike avatar
    4 posts
    Member since:
    Apr 2015

    Posted 29 Jul 2015 Link to this post

    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

  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 31 Jul 2015 Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Mike
    Mike avatar
    4 posts
    Member since:
    Apr 2015

    Posted 31 Jul 2015 in reply to Kiril Nikolov Link to this post

    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

  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2565 posts

    Posted 03 Aug 2015 Link to this post

    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready