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

[Solved] accessing a dynamically added DatePicker in javascript

1 Answer 99 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Benjamin asked on 17 Nov 2009, 11:51 AM
Hi,

I am having problems accessing the DatePicker component in javascript when added the DatePicker from code behind.
I would like to reposition the DatePicker's Calendar, which script works for DatePickers added on the markup(aspx) using the <%=DatePicker1.ClientID%>
However I am not sure how I can reference the component dynamically added in code behind. I have tried to pass the  DynamicDatePicker.ClientID to the script which manipulates the position of the Calendar. Unfortunately I have an earlier version of RAD controls so I have to this script manipulation, or the nasty way: I have to hardcode the position from code behind which is not a very efficient way of resolving this issue.
thanks

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 19 Nov 2009, 05:21 PM
Hello Benjamin,

I believe you can save your date picker's client ID in a hidden input on page and then try to find the input and take its value:

<input type="hidden" id="dynamicPickerId" runat="server" />

protected void Page_PreRender(object sender, EventArgs e)
{
    dynamicPickerId.Value = DynamicDatePicker.ClientID;
}

And then in your javascript:

var pickerId = $get('<%= dynamicPickerId.ClientID %>').value;
var picker = $find(pickerId);


All the best,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Benjamin
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or