0

When I user this targ on a page like:

@Html.TextBoxFor(model => model.JobName, new { @class = "form-control" })

It can work, But when I use like this:

@Html.TextBoxFor(model => model.JobName, new { @data-provide="typeahead", })

then it can't work, because this attribute: data-provide, it have a symbol which is '-', how I can solve this problem?

1 Answer 1

2

Use @data_provide. This falls under C# nomenclature, so you have to work with what is allowed (within the language confines).

MVC builds in a work-around allowing you to supplement hyphens with underscores (which will be replaced when built as HTML).

This is the same reason you must use @class over simply class (keyword collision).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.