This is a migrated thread and some comments may be shown as answers.

How can I override Role attribute in controls

3 Answers 150 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rajendar
Top achievements
Rank 1
Rajendar asked on 21 Oct 2014, 01:00 PM
Hi Every,

How can I override ' Role ' attribute in Kendo UI controls:

<%= Html.Kendo().Button()
    .Name("iconTextButton")       
    .Tag("a")
    .SpriteCssClass("k-icon k-i-ungroup")
     .HtmlAttributes(new {@Role="buttonwww"})
    .Content("Icon and text")%>

In the above role attribute is not override.

Regards,
Rajendar.

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 22 Oct 2014, 08:44 AM
Hi Rajendar,


In order to set data attributes via HtmlAttributes method, you should use an underscore instead.
E.g.
.HtmlAttributes(new { data_role = "foo" })

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Rajendar
Top achievements
Rank 1
answered on 27 Oct 2014, 08:32 AM
Hi Madjarov,

I tried this but it was not override default data role value why?

Regards,
Rajendar.
0
Dimiter Madjarov
Telerik team
answered on 27 Oct 2014, 08:40 AM
Hello Rajendar,


The following code
Html.Kendo().Button()
    .Name("iconTextButton")      
    .Tag("a")
    .SpriteCssClass("k-icon k-i-ungroup")
    .HtmlAttributes(new { data_role = "foo" })
    .Content("Icon and text")
is overriding the default data-role attribute on my side.

Is this not the behavior on your end?

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Rajendar
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Rajendar
Top achievements
Rank 1
Share this question
or