This is a migrated thread and some comments may be shown as answers.
Kendo templates and T4MVC
1 Answer 13 Views
This is a migrated thread and some comments may be shown as answers.
Andrea
Top achievements
Rank 1
Andrea asked on 04 Oct 2014, 12:47 PM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 08 Oct 2014, 07:20 AM
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.

 
Asked by
Andrea
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or