Chris Holmes
Chris Holmes

Reputation: 11584

How do I pass correct Url.Action to a JQuery method without extra ampersand trouble?

I am trying to make an ajax call like so:

$('#Grid').load('@Url.Action("_AgentStatesGrid", "AgentStates", new { projectId = Model.SelectedProject, siteId = Model.SelectedSite })', null, refreshComplete);

Unfortunately, it gets interpreted as this:

$('#Grid').load('/AgentStates/_AgentStatesGrid?projectId=179&siteId=0', null, refreshComplete);

As you can see, the &.a.m.p.; is there instead of the ampersand for the querystring (I put dots in because, duh, the web interprets it as an ampersand.., you get the idea)

I tried Url.Decode and that did nothing. I'm not sure I understand the problem so I have no clue how to fix it.

Upvotes: 31

Views: 12224

Answers (1)

Steve
Steve

Reputation: 2997

Try

 @Html.Raw(Url.Action("_AgentStatesGrid", "AgentStates", new { projectId = Model.SelectedProject, siteId = Model.SelectedSite })) 

Thanks

Upvotes: 60

Related Questions