MvcHtmlString still encoding characters
I'm trying to use MvcHtmlString.Create
to create a JavaScript variable. However the output is still being encoded.
var geocode_jsonresult = @MvcHtmlString.Create(Url.Action("GeoLocation", "Generic", New With {.address = "$(this).val()"}));
creates the following output
var geocode_jsonresult = /generic/GeoLocation?address=%24(this).val();
when really it "SHOULD" be
var geocode_jsonresult = /generic/Ge开发者_JS百科oLocation?address=$(this).val();
How can I prevent this?
note
I'm using VB and not C#
Your javascript seems broken. Shouldn't it be:
var geocode_jsonresult =
'@Url.Action("GeoLocation", "Generic")?address=' +
encodeUriComponent($(this).val());
Are trying to mix server side url helpers with client-side values?
Try
var geocode_jsonresult =
'@Url.Action("GeoLocation", "Generic")?address=' + $(this).val();
精彩评论