You can use one of the following methods to add custom attributes:
- Add an attribute to the form before creating the tag:
Model.Attributes.Add("id", "blah");
var tag = Tag(Model, "ul");
- Add attributes after creating the tag:
var tag = Tag(Model, "ul");
tag.MergeAttribute("id", "blah");
- Add the "Id" attribute to the form (applicable only for the id attribute):
Model.Id = "blah";
var tag = Tag(Model, "ul");
source
share