You can customize the Menu items using properties like “url”, “htmlAttribute”, “imageUrl”, “linkAttribute”. These properties are defined inside the field object of the Menu control. To know more about field object and its members, refer the following link:
The uses of these properties are shown in the following table.
Table 1: Properties
You can see the details in setting the above mentioned properties with data source as follows.
Setting htmlAttribute for each Menu item
Using “htmlAttribute” property, you can add HTML attributes, like styles, title to the <li> tag of the corresponding Menu item. To define the “htmlAttribute” in the data source, refer the following code.
In above code, “htmlAttribute” gets the object of “HtmlAttribute”, the custom class. Inside “HtmlAttribute” class, you can declare any properties like style, title or whatever you used as an attribute in the <li> tag.
Passing URL for Menu and setting attributes for Anchor tag using linkAttribute
The URL property is used to set the URL for the anchor tag, in the <li> tag of Menu item. This URL property can receive any value, in string type and the “linkAttribute” property is used to set the attributes of anchor tag element. It receives the object of “LinkAttribute” class, that is, the custom class. Inside “LinkAttribute” class you can declare any properties, like target, href, whatever is used as an attribute in the anchor tag.
Setting imageUrl for Menu item
The “imageURL” property specifies the URL of the image, and the corresponding image is added to the relevant Menu item. Here the “imageURL” property can receive any value, of string type.
In the “fields” property, you have to map the name of all the attributes that are specified in the data source. For example, the attribute “htmlAttribute”, specified in the data source, is mapped like ‘HtmlAttribute("htmlAttribute")’.
Based on this, a sample was prepared and you can find the sample under the following location.
|Article ID:||Published Date:||Last Revised Date:||Platform:||Control:|
or the page will be automatically redirected to sign-in page in 10 seconds.