Use an underscore in the data attribute name, and it’ll magically handle it for you, converting it to a hyphen. It knows you want a hyphen rather than an underscore as underscores aren’t valid in html attribute names.
<%= Html.TextBox("name", value, new { @data_foo = "bar"}) %>
More Related Contents:
- Prevent Caching in ASP.NET MVC for specific actions using an attribute
- Restarting (Recycling) an Application Pool
- ASP.NET MVC Binding to a dictionary
- ASP.NET MVC: No parameterless constructor defined for this object
- Dependency Injection in attributes
- Correct, idiomatic way to use custom editor templates with IEnumerable models in ASP.NET MVC
- Custom validation attribute that compares the value of my property with another property’s value in my model class
- What is an MvcHtmlString and when should I use it?
- How to override an existing extension method
- MVCBuildViews not working correctly
- Displaying standard DataTables in MVC
- I want to understand the lambda expression in @Html.DisplayFor(modelItem => item.FirstName)
- How to create roles in ASP.NET Core and assign them to users?
- ASP.NET Web API : Correct way to return a 401/unauthorised response
- Determine Client’s Computer Name
- MVC 5 BeginCollectionItem with Partial CRUD
- How to manually validate a model with attributes?
- how to add querystring values with RedirectToAction method?
- Need an ASP.NET MVC long running process with user feedback
- How to retain spaces in DropDownList – ASP.net MVC Razor views
- Redirect to another page when user is not authorized in asp.net mvc3
- Model binding with nested child models and PartialViews in ASP.NET MVC
- log4net with DI Simple Injector
- How do I transform appsettings.json in a .NET Core MVC project?
- WCF Service or Web API [closed]
- How can I force a log out of all users for a website?
- MVC 4 – Many-to-Many relation and checkboxes
- Database injection into a validation attribute with ASP MVC and Castle Windsor
- Unable to resolve service for type ‘Microsoft.AspNetCore.Identity.UserManager` while attempting to activate ‘AuthController’
- Display string as html in asp.net mvc view