Last post Feb 06, 2007 09:27 PM by azote
Jan 24, 2007 06:19 PM|TnNytehawk|LINK
I'm having an issue with the CalendarExtender not rendering properly when inside a Detailsview linked to a SQLDataSource that doesn't return an initial record on page load.
I have a list box that populates selections from a SQLDataSource, and a DetailView that shows details based on the listbox selection. For the detail data source I have the DefaultValue of the ControlParameter set to 0 so it won't show a record until someone
selects a value in the list box. This causes the Calendar to display poorly, which also renders it inoperable.
If I change the DefaultValue to 1, which returns a recordset, then the Calendar displays properly and works great.
Example Code (Stripped down but verified to cause the error)
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<form id="form1" runat="server">
<ajax:ScriptManager ID="smAjax" runat="server" />
<ajax:UpdatePanel ID="pnlBoxes" runat="server">
<asp:ListBox ID="lstList" runat="server" DataSourceID="dsData" DataTextField="strName"
DataValueField="intID" AutoPostBack="True" Rows="10" Width="294" SelectionMode="Single"
<asp:DetailsView ID="dvTest" runat="server" DataSourceID="dsDetails"
<asp:TextBox ID="txtDate" runat="server" Text='<%# Bind("dtmDate") %>' />
<act:CalendarExtender ID="calPopup" TargetControlID="txtDate" runat="server" />
<asp:SqlDataSource ID="dsData" runat="server" ConnectionString="<%$ ConnectionStrings:TrustedConnection %>"
SelectCommand="Select intID, strName From Table" SelectCommandType="StoredProcedure">
<asp:SqlDataSource ID="dsDetails" runat="server" ConnectionString="<%$ ConnectionStrings:TrustedConnection %>"
SelectCommand="SELECT dtmDate FROM Table WHERE (intID = @intID)">
<asp:ControlParameter ControlID="lstList" DefaultValue="0" Name="intID" PropertyName="SelectedValue" />
If I change the DefaultValue on line 36 to an ID in the table, then the Calendar works perfectly. Leave the DefaultValue at 0, which doesn't return an initial recordset but does properly display records when the Listbox Selection is made, and the Calendar
doesn't display properly at all.
Display Problem: The calendar will initially pop up with a background the width of the screen, the Header and Footer are left aligned and the calendar days are in the middle. The days are jumbled together and the pointer doesn't change properly when mousing
over them. When you select the header the calendar days simply move down a bit and the Months are displayed all jumbled together. If you select the header again, the Months move down on top of the days and the years are listed.
It seems that having a CalendarExtender inside a DetailsView that is bound to a data source that doesn't return a recordset on page load all wrapped inside an ASP.Net Ajax UpdatePanel causes the Calendar to display improperly. If you take everything out
of the UpdatePanel and let the page refresh on each item change, then having a DefaultValue = 0 doesn't effect it and the Calendar displays properly.
Any ideas? ;-)
Jan 25, 2007 02:24 PM|dotnet18|LINK
A workaround is to add these outside of UpdatePanel control.
<asp:TextBox ID="txtStartDate" runat="server" Visible="false"></asp:TextBox>
<cc1:CalendarExtender ID="cceStartDate" runat="server" TargetControlID="txtStartDate" Format="dd-MM-yyyy" />
Feb 02, 2007 04:35 PM|rbuckton|LINK
A similar issue has been documented in CodePlex and we are looking at a resolution. In the meantime the workaround that dotnet18 mentioned is one option. UpdatePanel does not take into account changes to the <head> tag which is where the link for the CSS
file is added. We should have a fix for in Development before too much longer.
Feb 06, 2007 09:27 PM|azote|LINK