0

In the following HtmlHelper:

@Html.TextBoxFor(model=>model.Username, new { id = "username", @class = "textbox"})

Some attributes like class have an @ before it while others don't. what does at sign mean there?

Ashkan Mobayen Khiabani
  • 32,319
  • 30
  • 98
  • 161

2 Answers2

2

Some attributes like class have an @ before it while others don't

that is because the C# language has a keyword class already. Only to negate its meaning you use @ . The same thing goes for the C# keyword type and html input element attribute type

Rajshekar Reddy
  • 18,019
  • 3
  • 36
  • 56
2

class is a reserved word in c#, so it cannot be used as a variable name, for making it valid variable name we need to add @ sign in start of it, it can be used for making a reserved word a valid variable whenever needed.

Ehsan Sajjad
  • 60,736
  • 15
  • 100
  • 154