I have a issue with symbols in account code which I am trying to create the URL using a href
as below. In my view I am trying to pass an id to my controller using Telerik grid.
.Template(x => Html.ActionLink("Month Ends", "MonthEndDates", new { id = x.Account, group = x.Group }))
.ClientTemplate("<a href=\"MonthEndDates?id=<#= Account #>&group=<#= Group #>\">" + "Month Ends" + "</a>")
The problem arises when I have a account code like APPLA&D
: the id is passed as APPLA
(missing the &D
).
How would one go about solving this issue? I assume you cannot do this in a href
as &
cannot be a value in a URL?
Encode the URL parameters. Untested (since I don't have Telerik available these days):
.Template(x => Html.ActionLink("Month Ends", "MonthEndDates", new {
id = Net.WebUtility.UrlEncode(x.Account),
group = x.Group
}))
.ClientTemplate("<a href=\"MonthEndDates?id=<#= id #>&group=<#= group #>\">" + "Month Ends" + "</a>")
This assumes ClientTemplate
is substituting in the id
and group
properties from the anonymous object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.