0

Here's may Html helper:

 @Html.ActionLink("CONTACT THE USER ABOUT THIS LISTING", "create", "contactform", new { recipientID = Model.User.Id, productid = Model.Product.ID }, null)

What I would like to do is:

 @Html.ActionLink("CONTACT " Model.UserName " ABOUT THIS LISTING", "create", "contactform", new { recipientID = Model.User.Id, productid = Model.Product.ID }, null)

Can it be done?

3 Answers 3

1

You can use the + operator to concatenate string values in C#:

"CONTACT " + Model.UserName + " ABOUT THIS LISTING"

Or something like string.Format() instead:

string.Format("CONTACT {0} ABOUT THIS LISTING", Model.UserName)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so much. I could not get any result just because Model.UserName in this case does not take any value. so I kept thinking I was doing something wrong.. how silly of me. Thanks again.
0

Yes, just use standard string concantenation.

@Html.ActionLink("CONTACT " + Model.UserName + " ABOUT THIS LISTING", "create", "contactform", new { recipientID = Model.User.Id, productid = Model.Product.ID }, null)

Comments

0
@Html.ActionLink($"CONTACT {Model.UserName} ABOUT THIS LISTING", "create", "contactform", new { recipientID = Model.User.Id, productid = Model.Product.ID }, null)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.