Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Disabling and showing stuffs based on calendar dates

$
0
0

Hi all, I want to do something like disabling the button1 from the starting date to the ending date. This means when my database has dates from 1-3, when I click on 1-3 on any of the day from 1-3, button 1 is not visible. I also have a panel which will show some details on the dates. I also want to make it look like when I click on any of the dates from 1-3 the panel is the same with information. Currently, the panel with the information only appears on day 1 and not 2 and 3. How do I modify my codes for this? 

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
string now = Calendar1.SelectedDate.ToString("yyyy-MM-dd");
DateTime current = DateTime.Now;
DateTime MyDateTime;
MyDateTime = new DateTime();
MyDateTime = DateTime.ParseExact(now, "yyyy-MM-dd",null);
Label15.Text = Calendar1.SelectedDate.ToString("MM-dd-yyyy");
TextBox1.Text = Label15.Text;
string user = (string)Session["UserID"];
Label12.Text = "";
Label13.Text = "";
Label14.Text = "";
TimeSpan diff = MyDateTime.Subtract(current);
if (diff.Days >= 0)
{
Button1.Visible = true;
}
else
{
Button1.Visible = false;
}


string mySQL;
MySqlConnection connDate = new MySqlConnection(connStr);
connDate.Open();
mySQL = "Select StartDate, EndDate, Reason from attendance where UserID = '" + user + "' and StartDate = '" +now+"'";
MySqlCommand cmdDate = new MySqlCommand(mySQL, connDate);
MySqlDataReader dr = cmdDate.ExecuteReader();


//using a while loop to read data from the reader
while (dr.Read())
{
Label12.Text = dr["StartDate"].ToString().Trim();
Label13.Text = dr["EndDate"].ToString().Trim();
Label14.Text = dr["Reason"].ToString().Trim();
string Startdate = Label12.Text;
string MyDateTime2 = MyDateTime.ToString("yyyy-MM-dd");
if (MyDateTime2.Equals(Startdate))
{
Button1.Visible = false;
}

//if (now == date)
//{
// Button1.Visible = false;
// Response.Redirect("viewCalendar.aspx");
//}
//else if (now != date)
//{

// Response.Redirect("viewCalendar.aspx");
//}
}
dr.Close();
Panel2.Visible = true;
connDate.Close();

}


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>