Access custom attributes in javascript

3 posts, 1 answers
  1. Jeremy
    Jeremy avatar
    96 posts
    Member since:
    Mar 2010

    Posted 15 Sep 2010 Link to this post

    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. Answer
    Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 15 Sep 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeremy
    Jeremy avatar
    96 posts
    Member since:
    Mar 2010

    Posted 15 Sep 2010 Link to this post

    That works perfectly :)
Back to Top