Hi all, I want to do something like highlighting the particular date and leaving a note on the date on the calendar.
I added this to my aspx page :
<script runat="server">
void DayRender(Object sender, DayRenderEventArgs e)
{
if (e.Day.Date.Day == 18) --> How do I make this date to a date that has been chosen by the user? Instead of hardcoding it?
{
e.Cell.Controls.Add(new LiteralControl("<br />Leave"));
}
}
void Page_Load(Object sender, EventArgs e)
{
// Manually register the event-handling method for the DayRender
// event of the Calendar control.
Calendar1.DayRender += new DayRenderEventHandler(this.DayRender);
}
</script>
I added this set of codes on my aspx.cs page
if (TextBox1.Text != null || TextBox2.Text != null || TextBox4.Text != null)
{
DateTime selected = DateTime.ParseExact(TextBox1.Text, "MM-dd-yyyy", null);
DateTime selected2 = DateTime.ParseExact(TextBox2.Text, "MM-dd-yyyy", null);
DateTime now = Convert.ToDateTime(DateTime.Now.ToShortDateString());
if (selected <= now)
{
TextBox1.Text = DateTime.Now.ToString("yyyy-MM-dd");
}
if (selected2 <= now)
{
TextBox2.Text = DateTime.Now.ToString("yyyy-MM-dd");
}
string getSelectedDate = "";
getSelectedDate = selected.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);
string mySQL;
MySqlConnection connSave = new MySqlConnection(connStr);
connSave.Open();
mySQL = "INSERT into Attendance(StartDate, EndDate, Reason, UserID) VALUES(N'" + getSelectedDate + "', N'" + getSelectedDate + "', ?Reason, '" + Session["UserID"] + "')"; MySqlCommand cmdSave = new MySqlCommand(mySQL, connSave);
Guid myGuid = Guid.NewGuid();
cmdSave.Parameters.Add("?AttendanceID", myGuid.ToString());
cmdSave.Parameters.Add("?Reason", TextBox4.Text);
cmdSave.ExecuteNonQuery();
connSave.Close();
Response.Write(@"<script language = javascript>alert('Thank you for submitting the leave form, the admin will contact you regarding the make up lesson!');</script>");
}
What I want to achieve is basically let the user choose a date and then when the page refreshes, that particular will be highlighted and a note will be under that date. How do I achieve all these? Thank you!