This is a migrated thread and some comments may be shown as answers.
RadTextBox Attribute
2 Answers 123 Views
This is a migrated thread and some comments may be shown as answers.
Jeroen Eikmans
Top achievements
Rank 1
Jeroen Eikmans asked on 25 Mar 2010, 02:47 PM
Hi,

I have a RadTextBox on my page.
Using radTextBox.Attributes.Add("Key", "Value") I add some value i need to the control.

I've been looking for a way where i can get that value in the ClientEvent OnTextChanged.
The sender in the OnTextChanged-event (which is the RadTextBox i believe) doesn't have a method like get_attribute.

Is there some other way to access this attribute client-side?

Kind regards,
Roel

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 25 Mar 2010, 02:59 PM
Hi Roel,

Here is how to do it:

<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<script runat="server">
 
    protected void Page_Load(object sender, EventArgs e)
    {
        RadTextBox1.Attributes.Add("mykey", "myvalue");
    }
     
</script>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<telerik:RadTextBox ID="RadTextBox1" runat="server">
    <ClientEvents OnValueChanged="MyValueChanged" />
</telerik:RadTextBox>
 
<script type="text/javascript">
 
function MyValueChanged(sender, args)
{
    alert(sender._textBoxElement.getAttribute("mykey"));
}
 
</script>
 
</form>
</body>
</html>


Sincerely yours,
Dimo
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
Accepted
Princy
Top achievements
Rank 1
answered on 25 Mar 2010, 03:07 PM
Hello,

I tried following code in order to get the attribute that we set from from code behind.

C#:
 
RadTextBox1.Attributes.Add("key","value"); 

JavaScript:
 
    function OnValueChanged(sender, args) { 
        alert(sender._textBoxElement.getAttribute("key"));       
    } 

Try this and see whether it is working fine for you.

Regards,
Princy.
Tags
Input
Asked by
Jeroen Eikmans
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Princy
Top achievements
Rank 1
Share this question
or