Passing field value to @Url.Action or @UrL.RouteUrl in grid field template

2 posts, 1 answers
  1. Bulut
    Bulut avatar
    25 posts
    Member since:
    Dec 2016

    Posted 23 Oct 2018 Link to this post

    How can I pass field value to @Url.Action or @Url.RouteUrl in my razor view? I am going to use it in my template.

    @Url.Action("MyAction", "MyController", new { Id = Id = #=Id# })

    @Url.RouteUrl("MyRouteTemp", new { Id = #=Id# }, webHelper.CurrentRequestProtocol);


    template: "<a href='" + @Url.Action("MyAction", "MyController", new { Id = Id = #=Id# })'>View Details</a >",

  2. Answer
    Georgi avatar
    685 posts

    Posted 25 Oct 2018 Link to this post

    Hello Bulut,

    By default Url.Action url-encodes the output which will replace the # literals with their encoded values. To avoid that use the Server.UrlDecode method.


    template: "<a href='@Server.UrlDecode(Url.Action("MyAction", "MyController", new { Id = "#=Id#" }))'>View Details</a >"

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top