May 12, 2011, 9:09 AM
DateField in Menu not setting date in Code behind - possible bug?
Hi,
I have a datefield within a component menu on a toolbar within a gridpanel, when I attempt to read the datefield.text value or selected date value, after having picked a date, in code behind I get empty text, and not the date.
I am not sure if I am doing something wrong or this is a bug? In other areas of the application I can read the selected date from the text value.
Below is a simplified section of code that illustrates the problem I am experiencing, when I inspect the value of txtstartdate.text in the code behind it returns empty string, or if I assign the text a value in the the datefield it returns this value, but not the newly selected date.
I have a datefield within a component menu on a toolbar within a gridpanel, when I attempt to read the datefield.text value or selected date value, after having picked a date, in code behind I get empty text, and not the date.
I am not sure if I am doing something wrong or this is a bug? In other areas of the application I can read the selected date from the text value.
Below is a simplified section of code that illustrates the problem I am experiencing, when I inspect the value of txtstartdate.text in the code behind it returns empty string, or if I assign the text a value in the the datefield it returns this value, but not the newly selected date.
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="sandpit.aspx.vb" Inherits="Project_Gems.sandpit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<% @ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Store id="stoProjectMilestones" runat="server" GroupField="Tollgate_ID_Description" >
<Reader>
<ext:JsonReader >
<Fields>
<ext:RecordField name="Tollgate_ID_Description" Type="string"> </ext:RecordField>
<ext:RecordField name="Tollgate_ID" Type="int"> </ext:RecordField>
<ext:RecordField name="Tollgate_Task_ID" Type="Int"> </ext:RecordField>
<ext:RecordField name="Tollgate_Task_Sequence" Type="Float"> </ext:RecordField>
<ext:RecordField name="Tollgate" Type="String" > </ext:RecordField>
<ext:RecordField name="Tollgate_Task_Name" Type="String" > </ext:RecordField>
<ext:RecordField name="Documentation_Attached" Type="String" > </ext:RecordField>
<ext:RecordField name="Percent_Complete" Type="Float" > </ext:RecordField>
<ext:RecordField name="Tollgate_Status_ID" Type="Int"> </ext:RecordField>
<ext:RecordField name="Tollgate_Status" Type="String"> </ext:RecordField>
<ext:RecordField name="Tollgate_Owner_ID" Type="Int"> </ext:RecordField>
<ext:RecordField name="Tollgate_Owner" Type="String"> </ext:RecordField>
<ext:RecordField name="Proposed_Start_Date" Type="Date" > </ext:RecordField>
<ext:RecordField name="Target_Completion_Date" Type="Date" > </ext:RecordField>
<ext:RecordField name="Actual_Start_Date" Type="Date" > </ext:RecordField>
<ext:RecordField name="Actual_Completion_date" Type="Date" > </ext:RecordField>
<ext:RecordField name="Duration_Days" Type="Int"> </ext:RecordField>
<ext:RecordField name="Actual_duration" Type="Int"> </ext:RecordField>
<ext:RecordField name="TollGateDays" Type="Int"> </ext:RecordField>
<ext:RecordField name="Comments" Type="String"> </ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:GridPanel runat="server"
id="grdMilestones"
StripeRows ="true"
Trackmouseover="true"
frame="false"
Width="1200"
Height="550"
AutoDataBind ="true"
Border="true"
ShowMask="true"
StoreID ="stoProjectMilestones"
ClicksToEdit="50"
>
<TopBar >
<ext:Toolbar id="tbarProjectMilestones" runat="server" >
<Items>
<ext:Button runat="server" ID="cmdCreateMilestones" Text="Create Project Milestones" Icon="TableAdd" >
<Menu>
<ext:Menu ID="Menu1" runat="server" >
<items>
<ext:ComponentMenuItem runat="server" ID="cmilabel">
<Component>
<ext:Label Text="Enter Start Date:" ID="lblStartDate" runat="server"></ext:Label>
</Component>
</ext:ComponentMenuItem>
<ext:ComponentMenuItem runat="server" ID="cmiDate">
<Component>
<ext:DateField runat="server" Width="200" id="txtStartDate" />
</Component>
</ext:ComponentMenuItem>
<ext:MenuItem runat="server" id="cmdOkCreate" Icon ="Add" Text="Ok" Height="40">
<DirectEvents >
<Click OnEvent ="MnuOkClicked"></Click>
</DirectEvents>
</ext:MenuItem>
<ext:MenuItem runat="server" id="cmdCancel" Icon ="Cancel" Text="Cancel" Height="40">
</ext:MenuItem>
<ext:MenuSeparator runat="server" ID="mnuSep1"></ext:MenuSeparator>
</items>
</ext:Menu>
</Menu>
</ext:Button>
<ext:ToolbarSeparator runat="server" ID="tbmnuMilestones"></ext:ToolbarSeparator>
<ext:Button ID="cmdEdit" runat="server" Icon="BookEdit" Text="edit" ToolTip ="Edit Existing Milestone">
<DirectEvents>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:GridPanel>
</form>
</body>
</html>
Code Behind:Public Class sandpit
Inherits System.Web.UI.Page
Public Sub MnuOkClicked()
If txtStartDate.Text = "01/01/0001" Or txtStartDate.Text = "" Then
cmdCreateMilestones.ShowMenu()
txtStartDate.ShowIndicator()
lblStartDate.StyleSpec = "color:red;"
Exit Sub
End If
lblStartDate.StyleSpec = "color:black;"
Dim pm As New Project_Milestones_data
Try
Catch ex As Exception
End Try
End Sub
End Class