|
-
Aug 4th, 2004, 03:15 PM
#1
Thread Starter
Member
How would I use a calendar to highlight different days from database?
How would I pull dates from a database to show up highlighted on a calendar? What I mean by this is, I have a calendar that shows each day of the month and I have certain days that I want to have highlighted so visitors will know to click on them instead of every day in the month.
If there are highlighted days, visitors will know which days to click on instead of clicking on random days.
-
Aug 5th, 2004, 07:39 AM
#2
From my limited use of calender controls i don't think this would be possible.
I reckon you'll probably have to code your own calender control to do this.
But as usual i wait to be proven wrong.
-
Aug 5th, 2004, 12:13 PM
#3
PowerPoster
Like my calendar for my blog?
www.variantx.com
I have the code I use if you want it, I pull the information based off the month selected, find the days that have valid info, then I make links from each of the days that are valid. The rest are disabled. Just finished it up last week.
-
Aug 5th, 2004, 12:21 PM
#4
Thread Starter
Member
That's exactly what I'm looking for, can you give me some ideas on how to do it?
-
Aug 5th, 2004, 02:57 PM
#5
PowerPoster
I will give you the code as soon as I get my other machine up that has the code on it... stand by.
-
Aug 5th, 2004, 10:31 PM
#6
PowerPoster
Code:
int[] days; // Holds the days to render for display.
private void Page_Load(object sender, System.EventArgs e)
{
// Need this to set the current date of the calendar. If this isn't done
// and a user selects to see a months view, the min date will be returned
// because it isn't initialized.
if(!Page.IsPostBack)
{
calBlog.VisibleDate = DateTime.Today;
SetBlogDates(DateTime.Now);
}
}
private void calBlog_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
{
bool matched = false;
// Add custom text to cell in the Calendar control.
if(days != null)
{
foreach(int d in days)
{
if (e.Day.Date.Day == d && !e.Day.IsOtherMonth)
{
e.Cell.BackColor = Color.LightSteelBlue;
matched = true;
}
}
}
if(!matched)
{
e.Cell.BackColor = Color.White;
e.Day.IsSelectable = false;
}
}
private void calBlog_SelectionChanged(object sender, System.EventArgs e)
{
Response.Redirect("BlogDay.aspx?Date=" + HttpUtility.UrlEncode(calBlog.SelectedDate.ToShortDateString()));
}
private void lbtnMonthView_Click(object sender, System.EventArgs e)
{
Response.Redirect("BlogMonth.aspx?Date=" + HttpUtility.UrlEncode(calBlog.VisibleDate.ToShortDateString()));
}
private void calBlog_VisibleMonthChanged(object sender, System.Web.UI.WebControls.MonthChangedEventArgs e)
{
SetBlogDates(e.NewDate);
}
private void SetBlogDates(DateTime dt)
{
BlogPostCollection bpCol = BlogPostManager.GetBlogPostByMonth(dt, General.ConnectionString);
ArrayList temp = new ArrayList();
bool alreadyIn = false;
foreach(BlogPost bp in bpCol)
{
foreach(object itm in temp)
{
if(bp.DatePosted.Day == (int)itm)
alreadyIn = true;
}
if(alreadyIn)
alreadyIn = false;
else
temp.Add(bp.DatePosted.Day);
}
days = new int[temp.Count];
for(int i = 0; i < temp.Count; i++)
days[i] = (int)temp[i];
}
-
Aug 6th, 2004, 07:51 AM
#7
Thread Starter
Member
Thanks, but I need code for VB.net. That is C#. I'm sure I can just try and convert it to VB.net somehow.
Thanks for your time
It's not the size of the dog in the fight, it's the size of the fight in the dog.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|