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

Access custom attributes in javascript

2 Answers 301 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 15 Sep 2010, 06:58 AM
Hi

In javascript how do I access custom attributes that I have added to a RadDatePicker in the code behind?

protected void Page_Load(object sender, EventArgs e)
{
    RadDatePicker1.ClientEvents.OnDateSelected = "LoadChildrenForDatePicker";
    RadDatePicker1.Attributes.Add("children", "someothercontrolid");
}


and the javascript:
function LoadChildrenForDatePicker(sender, e)
{
    if (e.get_oldDate() != e.get_newDate())
    {
        //doesn't work - throws error
        //var childs = sender.getAttribute("children");
        //doesn't work - returns null
        var childs = sender.get_element().getAttribute("children");
    }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Radoslav
Telerik team
answered on 15 Sep 2010, 11:38 AM
Hi Jeremy,

Could you please try using the following code snippet and let me know if the issue still persists:
function LoadChildrenForDatePicker(sender, e)
{
   if (e.get_oldDate() != e.get_newDate())
   {
       var id = sender.get_element().id + "_wrapper";
       var childs = $get(id).getAttribute("children");
   }
}

Looking forward for your reply.

All the best,
Radoslav
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
Jeremy
Top achievements
Rank 1
answered on 16 Sep 2010, 01:32 AM
That works perfectly :)
Tags
Calendar
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Jeremy
Top achievements
Rank 1
Share this question
or