0

Is there an Razor method that will allow to put "object to string" inside html like:

<a href="http://@Model.x.y">Anchor</a>

Or do I have to use something like that and change my model?

c# object to string to display it in text format

Thanks

1
  • Please clarify what your model looks like and what your expected output is. This can be easy or difficult depending on what you are trying to do. Commented Oct 23, 2013 at 15:10

1 Answer 1

2

if the link you are passing from your model is a string the correct syntax would be

 <a href="@Html.Raw(@Model.x.y))">Anchor</a>

or

<a [email protected]("http://www." + @Model.x.y))>Anchor</a>

This way you are correctly parsing any special characters which might occur in the link like & or =

Sign up to request clarification or add additional context in comments.

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.