How can I override Role attribute in controls

4 posts, 0 answers
  1. Rajendar
    Rajendar avatar
    70 posts
    Member since:
    Jun 2013

    Posted 21 Oct 2014 Link to this post

    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.
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2304 posts

    Posted 22 Oct 2014 Link to this post

    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.

     
  3. Rajendar
    Rajendar avatar
    70 posts
    Member since:
    Jun 2013

    Posted 27 Oct 2014 in reply to Dimiter Madjarov Link to this post

    Hi Madjarov,

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

    Regards,
    Rajendar.
  4. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2304 posts

    Posted 27 Oct 2014 Link to this post

    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.

     
Back to Top