This is probably very simple and I am probably missing just the correct line that will make this work. I have writen a javascript function that I want to use with multiple RadDateTimePickers. I want to pass in the name of the RadDateTimePicker, eval the name to find the control and then run the rest of the script. I get the error "expression expected" when I do this. Any ideas?
function SetDate(pid, val) {
//the following statement fails with "expression expected"
//it is a mirror of the statement below that works except for variable substitution
var radCal= eval('$find("<%='+pid+'.ClientID%>")');
//the following statement works and is what I want replaced with the statement above this comment
//even though the eval() doesn't actually do anything, I just wanted to make sure it would work in an eval()
var radCal= eval('$find("<%=RadDateTimePicker1.ClientID%>")');
//value in val looks like: 03/10/2010
val = FormatDate(val);
var pd = new Date(val);
radCal.set_selectedDate(pd);
}
<a href="javascript:SetDate('RadDateTimePicker1', lastWeek());">Last Week</a>
<telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server" MinDate="2000/1/1" Width="170px" >
<TimeView ID="TimeView1" StartTime="09:00" EndTime="17:00" Interval="0:15:0" runat="server" />
</telerik:RadDateTimePicker>
function SetDate(pid, val) {
//the following statement fails with "expression expected"
//it is a mirror of the statement below that works except for variable substitution
var radCal= eval('$find("<%='+pid+'.ClientID%>")');
//the following statement works and is what I want replaced with the statement above this comment
//even though the eval() doesn't actually do anything, I just wanted to make sure it would work in an eval()
var radCal= eval('$find("<%=RadDateTimePicker1.ClientID%>")');
//value in val looks like: 03/10/2010
val = FormatDate(val);
var pd = new Date(val);
radCal.set_selectedDate(pd);
}
<a href="javascript:SetDate('RadDateTimePicker1', lastWeek());">Last Week</a>
<telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server" MinDate="2000/1/1" Width="170px" >
<TimeView ID="TimeView1" StartTime="09:00" EndTime="17:00" Interval="0:15:0" runat="server" />
</telerik:RadDateTimePicker>