How to add id attribute to tag in orchard alternates

I use Orchard CMS 1.10.1. I created an alternative for the menu, I know how to add class attributeto the tag

var tag = Tag(Model, "ul");
tag.AddCssClass("class-custom");

I need to add id attrubiteto this tag ul. How can i do this?

+4
source share
1 answer

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");
  1. Add attributes after creating the tag:
var tag = Tag(Model, "ul");
tag.MergeAttribute("id", "blah");
  1. Add the "Id" attribute to the form (applicable only for the id attribute):
Model.Id = "blah";
var tag = Tag(Model, "ul");
+4
source

Source: https://habr.com/ru/post/1653523/


All Articles