Blog

How to close CalendarExtender on lost focus or mouse out

Posted by Suthish Nair Blogs | AJAX in C# Dec 08, 2010
CalendarExtender control will not close automatically once opened without selecing a date. This small code snippets helps to achive the control to close once its loses the focus.
 
<
script language="javascript" type="text/javascript">
   var blnflag = false;
   document.onmouseout =
function(sender, args)
   {
      if (event.srcElement.tagName.toLowerCase() == "div" && event.srcElement.outerHTML.indexOf("ajax__calendar") > 0) blnflag = true;
      if (blnflag && event.srcElement.tagName.toLowerCase() != "div")
      {
         blnflag =
false;
         $find(
"CEBID1").hide();
      }
   }
</script>






<
asp:TextBox id="txtFrom" onkeypress="return false;" onkeydown="return false;" onmouseover="return false;" runat="server" style="width: 100px" />
<img id="img1" runat="server" alt="Date" src="images/cal.gif" temp_src="images/cal.gif" />
<cc1:CalendarExtender BehaviorID="CEBID1" runat="server" ID="cl1" TargetControlID="txtFrom" PopupButtonID="img1" Format="dd-MMM-yyyy"></cc1:CalendarExtender>
post comment
     

Use <asp:ImageButton runat="Server" .../> instead of <img ... >

Posted by S S Dec 05, 2012
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts