PDA

View Full Version : Coolite Datefield and ajax calendar extender



jmilton
Feb 16, 2010, 6:48 PM
I am having an issue with the Coolite DateField when I have the AJAX Calendar Extender on the same page (in my case I have the Coolite Control on one tab and the AJAX control on a second tab. The Coolite Control wont render the days in the calendar.

Here is the code:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DatefieldTest.aspx.cs" Inherits="junk_DatefieldTest" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Datefield Test</title>
</head>


<body>
<form id="form1" runat="server">

<table border="0" width="100%">
<tr>
<td align="center">
<ajax:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="360000" EnablePartialRendering="true" />
<ext:ScriptManager ID="ScriptManager2" runat="server"></ext:ScriptManager>
<ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Width="775px" BodyStyle="padding:2px;" DeferredRender="false">
<Tabs>
<ext:Tab ID="tabVisitRecord" runat="server" Title="Visit Record" AutoHeight="true">
<Body>
<table width="100%" style="text-align: left" border="0">
<tr>
<td><ext:FieldSet ID="fsStudentVisit" runat="server" Title="">
<Body>
<%--Comment: Visit Status (1st Panel)--%>
<ajax:UpdatePanel ID="pnlVisitStatus" runat="server" UpdateMode="Conditional" EnableViewState="true">
<ContentTemplate>
<ext:Panel ID="pnlVisit" runat="server" Title="Visit Status" AutoHeight="true" Frame="True" Collapsible="false" TitleCollapse="true" BodyStyle="padding:15px;" Collapsed="false" Icon="stopred">
<Body>
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<p>
Visit Date:
*</p>
<ext:DateField ID="txtVisitDate" runat="server" Width="108" Format="MM/dd/yyyy" AllowBlank="False"></ext:DateField>
</td>
</tr>
<tr>
<td colspan="4" style="height: 150px;"></td>
</tr>
</table>
</Body>
</ext:Panel>
</ContentTemplate>
</ajax:UpdatePanel>
</Body>
</ext:FieldSet>
</td>
</tr>
</table>
</Body>
</ext:Tab>


<%--Comment: Visit History Tab (2nd Tab)--%>
<ext:Tab ID="tabVisitHistory" runat="server" Title="Visit History" AutoHeight="true" BodyStyle="padding: 6px; ">
<Body>
<ext:FieldSet ID="fsVisitHistory" runat="server" Title="">
<Body>
<div style="text-align: left" class="bluetxtsmall">
<table width="100%" border="0">
<tr>
<td align="left">Search Start Date</td>
<td align="left" valign="top">&amp;nbsp;&amp;nbsp;&amp;nbsp;</td>
<td>Search End Date</td>
<td style="width: 70%;" align="right" valign="top" rowspan="2">&amp;nbsp;</td>
</tr>
<tr>
<td align="left" valign="top" style="padding: 6; white-space: nowrap">
<asp:TextBox ID="txtStartDate" runat="server" Width="70px" MaxLength="10" CssClass="txtLite"></asp:TextBox>
<asp:ImageButton ID="ibCalStart" runat="server" ImageUrl="~/images/Calendar_scheduleHS.png" BorderStyle="None"></asp:ImageButton><br />
<ajaxToolkit:MaskedEditValidator ID="mevtxtStartDate" runat="server" Font-Size="X-Small" Font-Names="Arial" ErrorMessage="Please enter a valid date" ControlToValidate="txtStartDate" ControlExtender="meetxtStartDate" EmptyValueMessage="Please enter a date" Display="Dynamic" InvalidValueMessage="Please enter a valid date" IsValidEmpty="False"></ajaxToolkit:MaskedEditValidator>
<ajaxToolkit:CalendarExtender ID="cetxtStartDate" runat="server" TargetControlID="txtStartDate" PopupButtonID="ibCalStart"></ajaxToolkit:CalendarExtender>
<ajaxToolkit:MaskedEditExtender ID="meetxtStartDate" runat="server" TargetControlID="txtStartDate" MaskType="Date" Mask="99/99/9999" AcceptAMPM="True"></ajaxToolkit:MaskedEditExtender>&amp;nbsp; &amp;nbsp;&amp;nbsp;
</td>
<td align="left" valign="top">&amp;nbsp;&amp;nbsp;&amp;nbsp;</td>
<td align="left" valign="top" style="white-space: nowrap">
<asp:TextBox ID="txtEndDate" runat="server" Width="70px" MaxLength="10" CssClass="txtLite"></asp:TextBox>
<asp:ImageButton ID="ibCalEnd" runat="server" ImageUrl="~/images/Calendar_scheduleHS.png" BorderStyle="None"></asp:ImageButton><br />
<ajaxToolkit:MaskedEditValidator ID="mevtxtEndDate" runat="server" Font-Size="X-Small" Font-Names="Arial" ErrorMessage="Please enter a valid date" ControlToValidate="txtEndDate" ControlExtender="meetxtEndDate" EmptyValueMessage="Please enter a date" Display="Dynamic" InvalidValueMessage="Please enter a valid date" IsValidEmpty="False"></ajaxToolkit:MaskedEditValidator>
<ajaxToolkit:CalendarExtender ID="cetxtEndDate" runat="server" TargetControlID="txtEndDate" PopupButtonID="ibCalEnd">
</ajaxToolkit:CalendarExtender>
<ajaxToolkit:MaskedEditExtender ID="meetxtEndDate" runat="server" TargetControlID="txtEndDate" MaskType="Date" Mask="99/99/9999" AcceptAMPM="True"></ajaxToolkit:MaskedEditExtender>
</td>
</tr>
<tr><td align="right" valign="top" style="padding: 0;" colspan="4"></td></tr>
<tr><td colspan="4" style="height: 150px;"></td></tr>
</table>


</Body>
</ext:FieldSet>
</Body>
</ext:Tab>
</Tabs>
</ext:TabPanel>


</td>
</tr>
</table>


<form>
<body>
</html>




using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class junk_DatefieldTest : System.Web.UI.Page


{
string myTab;
string myStudent;
string myVisit = "";
string myStartDate;
string myEndDate;





protected void Page_Load(object sender, EventArgs e)
{
myTab = Request.QueryString["t"];
myStudent = Request.QueryString["SID"];
myVisit = Request.QueryString["VID"];
myStartDate = Request.QueryString["SD"];
myEndDate = Request.QueryString["ED"];


if (!IsPostBack)
{
if ((myStartDate == "") || (myStartDate == null))
{
myStartDate = DateTime.Now.AddDays(-120).ToShortDateString();
}
if ((myEndDate == "") || (myEndDate == null))
{
myEndDate = DateTime.Now.ToShortDateString();
}


this.txtStartDate.Text = myStartDate;
this.txtEndDate.Text = myEndDate;
this.txtVisitDate.Value = DateTime.Now.ToShortDateString();
}
}
}