Can anyone help me with some Razor syntax? I have a foreach loop ( shown at the end) and I would like to insert two items of text into a link to produce something like this:
<a href="/PDFFiles/Dummy.pdf#page=123" tar开发者_StackOverflow社区get="_blank">
I hope my question is clear, Many thanks.
@foreach (var item in Model)
{
<a href="/PDFFiles/**item.Filename**.pdf#page=**item.PageNum**" target="_blank">
}
@foreach (var item in Model)
{
<a href="@Html.AttributeEncode(@Url.Content("~/PDFFiles/" + item.Filename + ".pdf#page=" + item.PageNum))" target="_blank">Download</a>
}
Just prefix your variable name with @
@foreach (var item in Model)
{
<a href="/PDFFiles/@(item.Filename).pdf#page=@(item.PageNum)" target="_blank">
}
精彩评论