Arthur Swails
Arthur Swails

Reputation: 179

How to mix Razor with string literals in HTML helpers for asp.net MVC

@Html.ActionLink(
    linkText: "Quote Number: "@item.QuoteNumber,
    actionName: "MyAction",
    controllerName: "Home",
)

I'm trying to do something as above to append the item quote number the literal label. QuoteNumber is a string.

Upvotes: 1

Views: 1139

Answers (2)

Andy T
Andy T

Reputation: 9881

You are in C#, so you can just append the strings. Something like:

@Html.ActionLink(
    linkText: "Quote Number: " + item.QuoteNumber,
    actionName: "MyAction",
    controllerName: "Home"
)

Upvotes: 3

Monah
Monah

Reputation: 6784

you can use the following

@Html.ActionLink( linkText: string.Format("Quote Number: {0}",item.QuoteNumber), actionName: "MyAction", controllerName: "Home")

and if you want to pass values

@Html.ActionLink(string.Format("Quote Number: {0}",item.QuoteNumber), "MyAction","Home", new {id = item.QuoteNumber})

Hope this will help you

Upvotes: 2

Related Questions