开发者

AjaxControlToolkit CalendarExtender selected value is null

开发者 https://www.devze.com 2023-01-14 05:56 出处:网络
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.

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号