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

Clearing RadDatepicker that is in a RadWindow

2 Answers 101 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brad
Top achievements
Rank 1
Brad asked on 06 Oct 2011, 06:41 AM
I have a form that appears in a RadWindow. On this form I have RadDatePicker.

There is a button on this form that calls some javascript to clear all of the form fields.

All get cleared, except for the RadDatePicker. Reason being, I cant find it.

The code I am trying to use looks like this.

var StartDatePicker = $find("<%=dpActivitytStartDate.ClientID %>");
if (StartDatePicker){
    StartDatePicker.clear();
}

However StartDatePicker is never found, therefore, never cleared.

I figure this might have something do to with the iFrame that the radWindow is in

So I tried finding the RadDatePicker like this.

$("#rwAdvancedSearchForm").contents().find("[id$='dpActivityEndDate']")

That does not find it either.

So I tried this.

var StartDatePicker = $("[id$='rwAdvancedSearchForm']").contents().find("[id$='dpActivityEndDate']");
if (StartDatePicker){
    StartDatePicker.clear();
}

In this case StartDatePicker is NOT null,

However I then get the error..

StartDatePicker.clear is not a function

What is the trick here? How to I clear a RadDatepicker that is in a RadWindow?

2 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 10 Oct 2011, 03:30 AM
Hello Brad,

The right approach to clear the picker's date is the first one you tried. Can you double check which is the Telerik.Web.UI dll version you are using? You can explore the Bin folder of your we site and see this in Properties -> Details. Or check the References window of the project.

Regards,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Shinu
Top achievements
Rank 2
answered on 10 Oct 2011, 07:57 AM
Hello Brad,

I tried the following markup and JavaScript which worked as expected on my end.
aspx:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
  <Windows>
  <telerik:RadWindow ID="RadWindow1" runat="server">
     <ContentTemplate>
         <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
         </telerik:RadDatePicker>
         <asp:Button ID="Button1" runat="server" Text="Close" OnClientClick="Close();return false" />
     </ContentTemplate>
   </Windows>
</telerik:RadWindowManager>
JS:
<script type="text/javascript">
function Close(sender, args)
{
 var RadDatePicker1 = $find('<%= RadDatePicker1.ClientID %>');
 RadDatePicker1.get_element().parentNode.style["display"] = "none";
}
</script>

Thanks,
Shinu.
Tags
General Discussions
Asked by
Brad
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Shinu
Top achievements
Rank 2
Share this question
or