开发者

ASP.NET - Using checkbox from the calender control

I am implementing a leave system using the calender control. Something like below :-

ASP.NET - Using checkbox from the calender control

Following is the markup :-

<asp:Calendar ID="Calendar1" runat="server" ondayrender="Calendar1_DayRender" 
            ShowGridLines="True">
        </asp:Calendar>
        <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem Value="vacation" Text="Vacation" />
            <asp:ListItem Value="sick" Text="Sick" />
            <asp:ListItem Value="training" Text="Training" />
        </asp:DropDownList>
        <asp:Button ID开发者_开发知识库="Button1" runat="server" Text="Save" onclick="Button1_Click" />

Following is the code-behind :-

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        if (!e.Day.IsOtherMonth && !e.Day.IsWeekend)
        {
            CheckBoxList list = new CheckBoxList();
            list.Items.Add(new ListItem("Half day"));
            list.Items.Add(new ListItem("Full day"));
            e.Cell.Controls.Add(list);
        }

    }

However, I am not able to access the the checkbox values neither in the button_click event nor in the DayRender event? Could anybody help? Is there a better way to implement this?


Because you are not binding any event handler to the CheckBox's also you haven't shown us the java-script you are using for Button click so I assume that you instead wanted to run a Server side code instead of Client side java-script. So instead of using OnClick attribute which is for client event script you should use Click Event which is for server side code

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜