Kendo templates and T4MVC

2 posts, 1 answers
  1. Andrea
    Andrea avatar
    12 posts
    Member since:
    Jan 2014

    Posted 04 Oct 2014 Link to this post

    You surely are all aware of the T4MVC service, very helpful in avoid 'magic strings'.
    Now, I would like to use it in a kendo template, but I found difficult to understand how parameters must be written.
    Right now, I have this sample template:

    <script id="agenda-event-template" type="text/x-kendo-template">
            <a href='/Controller/Action?id=#: currentid#'>#: title #</a>

    (where I stripped out non relevant code).

    If I want to use T4MVC, I have to rewrite the previous code as in:

    <script id="agenda-event-template" type="text/x-kendo-template">
            <a href='@MVC.Controller.Action(??????)>#: title #</a>

    But how can I pass the 'currentid' parameter in the action?
    Thanks in advance...

  2. Answer
    T. Tsonev
    T. Tsonev avatar
    2794 posts

    Posted 08 Oct 2014 Link to this post


    I think you're looking for the Url.JavaScriptReplacableUrl helper:

    <script id="agenda-event-template" type="text/x-kendo-template">
    # var actionUrl =<%= Url.JavaScriptReplacableUrl(MVC.Controller.Action())%> #
            <a actionUrl='#: urlTemplate.replace("{currentid}", currentid); #'>#: title #</a>

    I hope this helps.

    T. Tsonev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top