I am trying to send through multiple parameters through the Url.Action.
$('#dialog').dialog({
autoOpen: false,
width: 850,
height: 420,
resizable: false,
title: 'Vehicle details',
modal: true,
open: function (event, ui) {
$(this).load("@Url.Action("LightStoneRequest", new { registrationNumber = Model.VehicleRegistration, vinNumber = Model.vVinNumber })");
},
buttons: {
"Close": function () {
$(this).dialog("close");
}
}
});
During run time it looks as follows:
$(this).load("/APQuotes/LightStoneRequest?registrationNumber=TE5TGP&vinNumber=VINTEST44889856");
As you can see there is a vin number passed through, but its a null in my controller.
Here is my modal.
public partial class LightStoneRequest
{
public LightStoneRequest()
{
this.LightStoneDataFields = new HashSet<LightStoneDataField>();
}
public int LightStoneRequestId { get; set; }
public string RegistrationNumber { get; set; }
public string VinNumber { get; set; }
public virtual ICollection<LightStoneDataField> LightStoneDataFields { get; set; }
}
if i remove the amp; it works, but the URL.Action adds the amp;.
Url.Action
isn't the problem - it's how you use it.
You're using @
- this is used for inlining the results of a piece of server-side code in a (X)HTML page. In a (X)HTML page, entities must be properly encoded, turning your &
into a &
. This is the exact correct behaviour - that's how it's supposed to be inlined in either text or an attribute, for example (which is why you use it in e.g. <a href="@...">
).
However, you're trying to inline the raw value, rather than the encoded value - because you're not trying to emit HTML, you're emitting raw text. Html.Raw
does just that:
@Html.Raw(Url.Action("Test", new { arg1 = "Hi!", arg2 = "there." }))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With