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">
        <div>
            <a href='/Controller/Action?id=#: currentid#'>#: title #</a>
        </div>
    </script>

    (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">
        <div>
            <a href='@MVC.Controller.Action(??????)>#: title #</a>
        </div>
    </script>

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

  2. Answer
    T. Tsonev
    Admin
    T. Tsonev avatar
    2772 posts

    Posted 08 Oct 2014 Link to this post

    Hello,

    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())%> #
        <div>
            <a actionUrl='#: urlTemplate.replace("{currentid}", currentid); #'>#: title #</a>
        </div>
    </script>


    I hope this helps.

    Regards,
    T. Tsonev
    Telerik
     

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top