Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ToolBar > RadToolbarButton attributes in html

Not answered RadToolbarButton attributes in html

Feed from this thread
  • cheburek avatar

    Posted on Dec 28, 2011 (permalink)

    Hi!

    I am looking for a way to add custom attributes to RadToolbarButton to be rendered in html

    When I use following snippet

    RadToolBarButton button = new RadToolBarButton();
    button.Attributes["data-attr"] = "CustomText";
    button.CssClass += "tipsylink";


    I expect to see

    But unfortunately I can see only
    <a class="tipsylnk rtbWrap"...>
    I do use jquery to read such attributes from web controls for my custom needs.
    And that works for all standard asp.net controls but unfortunately
    radtoolbar implementation is different - as I understand it stores
    custom attributes in another place.

    I know that it is possible to read such attributes on client side using
    var toolBar = $find("<%=RadToolBar1.ClientID %>");
    var button = toolBar.findItemByText("Button 1");
    alert(button.get_attributes().getAttribute("DisplayName"));

    but actually I'd like to use standard jquery $(''). selector
    and process all items in the same way.
    So is it possible to render custom attributes to html element attribute
    for RadToolbarButtons?

    Reply

  • jumpstart Master avatar

    Posted on Dec 28, 2011 (permalink)

    cheburek:

    I am able to add the custom attribute to a toolbar button added in server side script. And, then, I can access the newly added attribute in order to immediately display the new value on a label. But, as you note, it does not get added to the HTML markup. See the attached image ("RadToolBarIssue.png") of the updated page in Firefox using Firebug.
       protected void btnAddButton_Click(object sender, EventArgs e)
       {
           RadToolBarButton newButton = new RadToolBarButton("Added Server-Side");
           //newButton.Attributes["data-attr"] = "CustomText";
           newButton.Attributes.Add("data-attr", "CustomText");
           lblInfo.Text = newButton.Attributes["data-attr"].ToString();
    ...

    Does it have to be added in the rendered markup for your purposes? Or, can you access it server-side after adding it? I have not been able to locate the newly added attribute in the DOM of the rendered page. But, there should be a way to add it programmically. I'm investigating further.

    Cheers!
    Attached files

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ToolBar > RadToolbarButton attributes in html
Related resources for "RadToolbarButton attributes in html"

[   ASP.NET ToolBar Features  |  Documentation  |  Demos  |  Telerik TV   |   Self-Paced Trainer   |  Step-by-step Tutorial  ]