custom attribute, how to get value on client side?

2 posts, 0 answers
  1. ldc0618
    ldc0618 avatar
    8 posts
    Member since:
    Jun 2007

    Posted 28 Apr 2010 Link to this post

    I am setting a custom attribute to a slider:
    rs.Attributes["menuAttributeID"] = menuAttributeID.ToString();

    the html output looks correct:
    <div style="height: 22px; width: 200px;" menuattributeid="251" class="RadSlider RadSlider_Default" id="dnn_ctr456_Admin_rtbMenuAdmin_i6_i0_sldHeight">...

    but how do I get the value of menuattributeid on the client side?

    I've tried several things such as:
    var menuAttributeID = sender.get_menuattributeid;

    but its not working.


  2. Svetlina Anati
    Svetlina Anati avatar
    2795 posts

    Posted 04 May 2010 Link to this post

    Hello ldc0618,

    In order to get the attribute you should reference the element in which HTML the attribute is rendered and extract it by using the getAttribute method. In this case, this element is the element of the slider which is rendered by the server and which can be referenced by using the get_element method. Please examine the following code snippet I prepared for you:

    <head runat="server">
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        <script type="text/javascript">
            function GetAttribute()
                var slider = $find("<%=RadSlider1.ClientID %>");
                var attr = slider.get_element().getAttribute("menuattributeid");
                alert("menuattributeid is: " + attr);
        <telerik:RadSlider ID="RadSlider1" runat="server" menuattributeid="251">
        <asp:Button ID="btn" runat="server" Text="Get custom attribute" OnClientClick="GetAttribute();return false;" />

    Please, use the above as a start point for your implementation and let me know how it goes.

    All the best,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top