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

custom attribute, how to get value on client side?

3 Answers 768 Views
Slider
This is a migrated thread and some comments may be shown as answers.
ldc0618
Top achievements
Rank 1
ldc0618 asked on 28 Apr 2010, 09:16 PM

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;
        alert(menuAttributeID);

but its not working.

Thanks!







3 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 04 May 2010, 08:43 AM
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">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <script type="text/javascript">
  
        function GetAttribute()
        {
            var slider = $find("<%=RadSlider1.ClientID %>");
            var attr = slider.get_element().getAttribute("menuattributeid");
            alert("menuattributeid is: " + attr);
        }
      
    </script>
    <telerik:RadSlider ID="RadSlider1" runat="server" menuattributeid="251">
    </telerik:RadSlider>
    <asp:Button ID="btn" runat="server" Text="Get custom attribute" OnClientClick="GetAttribute();return false;" />
    </form>
</body>
</html>

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

All the best,
Svetlina
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.
0
Austin
Top achievements
Rank 1
answered on 20 Sep 2018, 11:58 AM

I have located a web element via xpath and save it in variable like 

Element element_name = //a[@class='k-button k-button-icontext k-primary k-grid-update']

I want to extract certain attribute value against it likes text() and its id.

What is the coded step process for it.

I tried with element_name.getattribute(text) its not working.

 

Please help me with all sort of these similar commands.

0
Nikolai
Telerik team
answered on 21 Sep 2018, 08:30 AM
Hi Austin,


This forum thread is referring Telerik ASP.NET Ajax Slider control but it seems you're trying to do automation tests via Telerik TestStudio or Testing Framework is this correct?
Assuming you are trying to do test automation the easiest way to get an Element's text is to use the TextContent property, here is a working example against Kendo button control:
this.ActiveBrowser.NavigateTo("https://demos.telerik.com/kendo-ui/button/index");
this.ActiveBrowser.WaitUntilReady();
             
var element = this.ActiveBrowser.Find.ById("textButton");
Assert.IsNotNull(element);
             
string text = element.TextContent;



Regards,
Nikolai
Progress Telerik 
Tags
Slider
Asked by
ldc0618
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Austin
Top achievements
Rank 1
Nikolai
Telerik team
Share this question
or