Special characters after syntax

67 views Asked by At

I would like to know how to and is it posible to add special charaters after Razor syntax.

Example:

@Html.Raw(Model.Text)()

The problem is with () at the end. I'd like to add it just after generated content.

2

There are 2 answers

0
Tommy On BEST ANSWER

As an alternative to the <text></text> markup, you can simply wrap your Html.Raw statement in parenthesis. Example:

@(Html.Raw(Model.Text))()

This will prevent razor from trying to parse the extra set of parenthesis as they help razor determine when to stop parsing the markup.

0
John H On

Try this:

@Html.Raw(Model.Text)<text>()</text>

<text></text> is special razor markup, not to be confused with actual HTML.

The <text> tag is an element that is treated specially by Razor. It causes Razor to interpret the inner contents of the <text> block as content, and to not render the containing <text> tag element (meaning only the inner contents of the <text> element will be rendered – the tag itself will not). This makes it convenient when you want to render multi-line content blocks that are not wrapped by an HTML element.

Quoted from ASP.NET MVC 3: Razor’s @: and <text> syntax.