Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 181131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:42:27+00:00 2026-05-11T14:42:27+00:00

I am working with asp.net mvc and creating a form. I want to add

  • 0

I am working with asp.net mvc and creating a form. I want to add a class attribute to the form tag.

I found an example here of adding a enctype attribute and tried to swap out with class. I got a compile error when accessing the view.

I then found an example of someone adding a @ symbol to the beginning of the property name and that worked. Great that it works, but I am one that needs to know why and a quick Google search was not helpful. I understand that C# allows one to prepend the @ to a string to ignore escaping chars. Why does it work in this case? What does the @ tell the compiler?

Code that produces a compile error?

 <% Html.BeginForm('Results', 'Search',      FormMethod.Get, new{class='search_form'}); %> 

Code that does work:

 <% Html.BeginForm('Results', 'Search',      FormMethod.Get, new{@class='search_form'}); %> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:42:28+00:00Added an answer on May 11, 2026 at 2:42 pm

    In C#, ‘class’ is a reserved keyword – adding an ‘@’ symbol to the front of a reserved keyword allows you to use the keyword as an identifier.

    Here’s an example straight out of the C# spec:

    class @class {     public static void @static(bool @bool) {         if (@bool) System.Console.WriteLine('true');         else System.Console.WriteLine('false');     } } 

    Note: this is of course an example, and not recommended practice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on creating a blog with ASP.Net 4, MVC 3, Razor and
I'm working on an ASP.NET MVC project which uses the MarkdownDeep Editor to add
I'm working on creating a new base class for an asp.net app in order
I am working on rendering a dynamic form in an ASP.NET MVC view that
I am creating an ASP.NET MVC 3 e-commerce website and I am currently working
I am creating a REST API in ASP.NET MVC. I want the format of
I'm working with asp.net MVC. Now I don't know how to send data form
After working with ASP.Net MVC, it has me thinking about Rails. I worked with
i've started working with ASP.NET MVC and using Entity Framework, concretely with SQLite db,
I've been working with asp.net MVC and am still not very good at it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.