I have addEvent method in my .aspx.cs file. In which i want to use my checkbox and cheboxList but when i use it is shows me the error as shown in image below. as well as i have specify the code of my page hope you get the idea the problem which i am facing.
I have page something link as shown in the image and at the ADD EVENT it shows me error. When i remove the STATIC Keyword my calender ADD Button not working.
protected void chkRecSch_CheckedChanged(object sender, EventArgs e)
{
if (chkRecSch.Checked == true) {
//BindCheckBoxList();
BindCheckBoxListWithNextSevenDays();
weekChk.Visible = true;
}
else { weekChk.Visible = false; }
}
public void BindCheckBoxListWithNextSevenDays()
{
DateTime today = DateTime.Now;
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("date", typeof(string));
for (int i = 1; i <= 7; i++)
{
dt.Rows.Add(i, today.AddDays(i).ToString("dddd yyyy-MM-dd")); // (dddd yyyy-MM-dd) will return the date in following format (Wednesday 2020/02-05)
}
chkweek.DataSource = dt;
chkweek.DataBind();
}
[System.Web.Services.WebMethod]
public static int addEvent(ImproperCalendarEvent improperEvent)
{
if (chkRecSch.Checked == true)
{
foreach (ListItem li in weekChk.Items)
{
if (li.Selected == true)
{
Label1.Text += li + " ";
}
}
}
CalendarEvent cevent = new CalendarEvent()
{
title = "Schedular Master",
description = "Schedular Master",
StartDate = improperEvent.start,
StartTime = improperEvent.startTime,
EndDate = improperEvent.end,
EndTime = improperEvent.endTime,
UserID = System.Web.HttpContext.Current.Session["AdminID"].ToString(),
ProviderId = improperEvent.ProviderId
};
if (CheckAlphaNumeric(cevent.title) && CheckAlphaNumeric(cevent.description))
{
int key = EventDAO.AddScheduleMaster(cevent);
return key;
}