Jack Jack - 3 months ago 11
HTML Question

how to concatenate an int parameter in an href in a MVC view

I have the following

div
in a
MVC
view

<div>
<span style="min-width: 105px; max-width: 120px; display: inline-block;">Images Available:</span>
<span><b></b></span>
</div>


In the second
span
I would like to add an reference to an
aspx
page that requires an
i
d passed to in (which is an int data type)

I thought of doing something like this:

<span><b><a href="~/pages/inventory/_inventory_image.aspx?qinventory_id=" + Model.InventoryId</a></b></span>


That half works by giving me the page url but no InventoryId.

I also tried ampersand (which I know is for string values) also to no avail

Could someone help a brother out? :-)

Answer

You need to pass Model.InventoryId with the quotes.

<span><b><a href="~/pages/inventory/_inventory_image.aspx?qinventory_id=@Model.InventoryId"></a></b></span>