RadDatePicker OnDateSelected event

2 posts, 0 answers
  1. Farjana
    Farjana avatar
    26 posts
    Member since:
    Aug 2013

    Posted 11 Nov 2013 Link to this post

    Hi,

    Can you tell me how to get the id of a dynamically created control in jquery
    I am creating a RadDatePicker dynamically in C# like:
     RadDatePicker rd = new RadDatePicker();
    rd.ID = "rd_"+ "i_"+ count;
    rd.ClientEvents.OnDateSelected = "dateSelected";

    where i and count are some dynamically generated variables.

    Now inside javascript func:
    function dateSelected(sender, args) 
            {
    // get the id of the sender(date picker) control;
    }
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Nov 2013 Link to this post

    Hi Farjana,

    Please have a look into the sample code I tried for your scenario.

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        int count = 5;
        RadDatePicker rd = new RadDatePicker();
        rd.ID = "rd_" + "i_" + count;
        rd.ClientEvents.OnDateSelected = "dateSelected";
        this.form1.Controls.Add(rd);
    }

    JavaScript:
    <script type="text/javascript">
        function dateSelected(sender, args) {
            alert(sender.get_id());
        }
    </script>

    Thanks,
    Shinu.
Back to Top