I try to get date from CalendarExtender in two ways: one with updatepanel and one without but it doesn't work. value of this two calendar extender are null.
It's weird because I can select date from this extenders, and text of textboxes are set to selected date.
How to fix it ?
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="tbPlannedStart"
Format="d">
</asp:CalendarExtender>
<asp:TextBox ID="tbPlannedStart" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
<asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="tbPlannedEnd"
Format="d">
</asp:CalendarExtender>
<asp:TextBox ID="tbPlannedEnd" runat="server"></asp:TextBox>
protected 开发者_如何学Pythonvoid btnAddProject_Click(object sender, EventArgs e)
{
var service = new Service1Client("WSHttpBinding_IService13");
var project = new MyProject();
project.PlannedEnd = CalendarExtender2.SelectedDate;
project.PlannedStart = CalendarExtender1.SelectedDate;
service.AddProject(project);
}
It solved my problem:
project.PlannedEnd = System.Convert.ToDateTime(tbPlannedEnd.Text);
project.PlannedStart = System.Convert.ToDateTime(tbPlannedStart.Text);
精彩评论