This is a migrated thread and some comments may be shown as answers.

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

1 Answer 3307 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bulut
Top achievements
Rank 1
Bulut asked on 24 Oct 2018, 04:19 AM

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 >",

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi
Telerik team
answered on 25 Oct 2018, 02:36 PM
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.

e.g.

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


Regards,
Georgi
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.
Tags
Grid
Asked by
Bulut
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or