Using Razor Expressions with or without String Quotes

As for the use cases of the Razor expression (ASP.Net), there are two cases:

<div title="@MyClass.Test"></div>

and

<div title=@MyClass.Test></div>

Since they both work the same on Razor 2.0, I would like to know if there are any differences, especially in the case of corners (null / malfored values, etc.).

In the end, I would also like to know what is best for practice. Thank you in advance.

+6
source share
1 answer

Rules for HTML attributes can be found here . Quotation marks are usually optional, but if MyClass.Testthere is a space in the value , then you will need to.

, , , , .

+7

All Articles