473,756 Members | 8,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calendar Control - Programatically set the calendar to a date range

Hi All, Hope someone can help!

I am building an Event Calendar app based around the Calendar
WebControl which builds an SQL string based on the SelectedDates
property which is passed to Page.StartDate and Page.EndDate
properties.

This works nicely and I can select a Day, Week or Month and run my SQL
against them.

There is also a shortcuts dropdown to allow the user to select Today,
Last Month, This Month, Next Month, Next Two Weeks, Next 30 Days, Next
60 Days, Next 90 Days.

Again, these all work nicely as I set the Page.StartDate and
Page.EndDate based on the option and run the SQL then update the
Calendar.Visibl eDate to Page.StartDate.

The problem is it would be nice for the Calendar object to reflect the
shortcut ranges. This is OK for Today as I can just set the
SelectedDate to the Page.StartDate. However the SelectedDates property
is read only.

Is there any way to set a range of dates to be selected based on the
Page.StartDate and Page.EndDate properties?

Many TIA

--
Shevek

The Poster Previously Known As Moldy
Nov 18 '05 #1
3 3607
you can write a handler for DayRender event and check for the date and
change color accordingly.

private void Calendar1_DayRe nder(object
sender,System.W eb.UI.WebContro ls.DayRenderEve ntArgs e )
{
if (e.Day.Date >= Page.StartDate && e.Day.Date <= Page.EndDate)
{
e.Cell.BackColo r = System.Drawing. Color.LightGray ;
}
}

hth,
Av.

"Shevek" <sh************ ****@moldy.me.u k> wrote in message
news:uk******** *************** *********@4ax.c om...
Hi All, Hope someone can help!

I am building an Event Calendar app based around the Calendar
WebControl which builds an SQL string based on the SelectedDates
property which is passed to Page.StartDate and Page.EndDate
properties.

This works nicely and I can select a Day, Week or Month and run my SQL
against them.

There is also a shortcuts dropdown to allow the user to select Today,
Last Month, This Month, Next Month, Next Two Weeks, Next 30 Days, Next
60 Days, Next 90 Days.

Again, these all work nicely as I set the Page.StartDate and
Page.EndDate based on the option and run the SQL then update the
Calendar.Visibl eDate to Page.StartDate.

The problem is it would be nice for the Calendar object to reflect the
shortcut ranges. This is OK for Today as I can just set the
SelectedDate to the Page.StartDate. However the SelectedDates property
is read only.

Is there any way to set a range of dates to be selected based on the
Page.StartDate and Page.EndDate properties?

Many TIA

--
Shevek

The Poster Previously Known As Moldy

Nov 18 '05 #2
On Wed, 23 Jun 2004 18:01:57 +0530, "avnrao" <av*@newsgroups .com>
wrote:
you can write a handler for DayRender event and check for the date and
change color accordingly.

private void Calendar1_DayRe nder(object
sender,System. Web.UI.WebContr ols.DayRenderEv entArgs e )
{
if (e.Day.Date >= Page.StartDate && e.Day.Date <= Page.EndDate)
{
e.Cell.BackColo r = System.Drawing. Color.LightGray ;
}
}

hth,
Doesn't quite work!

I already use the DayRender event to apply styles and onmouseover to
give the dates borders and rollovers.

If I change the first line to

If (e.Day.Date.ToS hortDateString >= Me.StartDate And
e.Day.Date.ToSh ortDateString <= Me.EndDate) or e.Day.IsSelecte d Then

then it seems to keep the cssclass in the viewstate and is there when
I browse back and forth through the calendar....
If e.Day.IsSelecte d Then
If bEvent Then
e.Cell.ApplySty le(ForeOrange)
e.Cell.CssClass = "EventSelectedD ay"
e.Cell.Attribut es.Add("onmouse over",
"javascript:thi s.className = 'EventSelectedD ayOver';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:thi s.className = 'EventSelectedD ay';")
Else
e.Cell.CssClass = "SelectedDa y"
e.Cell.Attribut es.Add("onmouse over",
"javascript:thi s.className = 'SelectedDayOve r';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:thi s.className = 'SelectedDay';" )
End If
ElseIf e.Day.IsWeekend Then
If bEvent Then
e.Cell.ApplySty le(ForeOrange)
e.Cell.CssClass = "EventWeekendDa y"
e.Cell.Attribut es.Add("onmouse over",
"javascript:thi s.className = 'EventWeekendDa yOver';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:thi s.className = 'EventWeekendDa y';")
Else
e.Cell.CssClass = "WeekendDay "
e.Cell.Attribut es.Add("onmouse over",
"javascript:thi s.className = 'WeekendDayOver ';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:thi s.className = 'WeekendDay';")
End If
ElseIf e.Day.IsOtherMo nth Then
If bEvent Then
e.Cell.ApplySty le(ForeYellow)
e.Cell.CssClass = "EventOtherMont hDay"
e.Cell.Attribut es.Add("onmouse over",
"javascript:thi s.className = 'EventOtherMont hDayOver';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:thi s.className = 'EventOtherMont hDay';")
Else
e.Cell.CssClass = "OtherMonth Day"
e.Cell.Attribut es.Add("onmouse over",
"javascript:thi s.className = 'OtherMonthDayO ver';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:thi s.className = 'OtherMonthDay' ;")
End If
Else
If bEvent Then
e.Cell.ApplySty le(ForeOrange)
e.Cell.CssClass = "EventDay"
e.Cell.Attribut es.Add("onmouse over",
"javascript:thi s.className = 'EventDayOver'; ")
e.Cell.Attribut es.Add("onmouse out",
"javascript:thi s.className = 'EventDay';")
Else
e.Cell.CssClass = "Day"
e.Cell.Attribut es.Add("onmouse over",
"javascript:thi s.className = 'DayOver';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:thi s.className = 'Day';")
End If
End IfAv.

"Shevek" <sh************ ****@moldy.me.u k> wrote in message
news:uk******* *************** **********@4ax. com...
Hi All, Hope someone can help!

I am building an Event Calendar app based around the Calendar
WebControl which builds an SQL string based on the SelectedDates
property which is passed to Page.StartDate and Page.EndDate
properties.

This works nicely and I can select a Day, Week or Month and run my SQL
against them.

There is also a shortcuts dropdown to allow the user to select Today,
Last Month, This Month, Next Month, Next Two Weeks, Next 30 Days, Next
60 Days, Next 90 Days.

Again, these all work nicely as I set the Page.StartDate and
Page.EndDate based on the option and run the SQL then update the
Calendar.Visibl eDate to Page.StartDate.

The problem is it would be nice for the Calendar object to reflect the
shortcut ranges. This is OK for Today as I can just set the
SelectedDate to the Page.StartDate. However the SelectedDates property
is read only.

Is there any way to set a range of dates to be selected based on the
Page.StartDate and Page.EndDate properties?

Many TIA

--
Shevek

The Poster Previously Known As Moldy

--
Shevek

The Poster Previously Known As Moldy
Nov 18 '05 #3
On Wed, 23 Jun 2004 13:59:38 +0100, Shevek
<sh************ ****@moldy.me.u k> wrote:
On Wed, 23 Jun 2004 18:01:57 +0530, "avnrao" <av*@newsgroups .com>
wrote:
you can write a handler for DayRender event and check for the date and
change color accordingly.

private void Calendar1_DayRe nder(object
sender,System .Web.UI.WebCont rols.DayRenderE ventArgs e )
{
if (e.Day.Date >= Page.StartDate && e.Day.Date <= Page.EndDate)
{
e.Cell.BackColo r = System.Drawing. Color.LightGray ;
}
}

hth,
Doesn't quite work!

I already use the DayRender event to apply styles and onmouseover to
give the dates borders and rollovers.

If I change the first line to

If (e.Day.Date.ToS hortDateString >= Me.StartDate And
e.Day.Date.ToS hortDateString <= Me.EndDate) or e.Day.IsSelecte d Then

then it seems to keep the cssclass in the viewstate and is there when
I browse back and forth through the calendar....


Got it! It was not working because my Page.StartDate and Page.EndDate
are both dates stored as strings...

Dim dStartDate, dEndDate As Date
If IsDate(Me.Start Date) Then dStartDate = Me.StartDate
If IsDate(Me.EndDa te) Then dEndDate = Me.EndDate
If (e.Day.Date >= dStartDate And e.Day.Date <= dEndDate) Then

....has fixed it!

Cheers!


If e.Day.IsSelecte d Then
If bEvent Then
e.Cell.ApplySty le(ForeOrange)
e.Cell.CssClass = "EventSelectedD ay"
e.Cell.Attribut es.Add("onmouse over",
"javascript:th is.className = 'EventSelectedD ayOver';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:th is.className = 'EventSelectedD ay';")
Else
e.Cell.CssClass = "SelectedDa y"
e.Cell.Attribut es.Add("onmouse over",
"javascript:th is.className = 'SelectedDayOve r';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:th is.className = 'SelectedDay';" )
End If
ElseIf e.Day.IsWeekend Then
If bEvent Then
e.Cell.ApplySty le(ForeOrange)
e.Cell.CssClass = "EventWeekendDa y"
e.Cell.Attribut es.Add("onmouse over",
"javascript:th is.className = 'EventWeekendDa yOver';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:th is.className = 'EventWeekendDa y';")
Else
e.Cell.CssClass = "WeekendDay "
e.Cell.Attribut es.Add("onmouse over",
"javascript:th is.className = 'WeekendDayOver ';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:th is.className = 'WeekendDay';")
End If
ElseIf e.Day.IsOtherMo nth Then
If bEvent Then
e.Cell.ApplySty le(ForeYellow)
e.Cell.CssClass = "EventOtherMont hDay"
e.Cell.Attribut es.Add("onmouse over",
"javascript:th is.className = 'EventOtherMont hDayOver';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:th is.className = 'EventOtherMont hDay';")
Else
e.Cell.CssClass = "OtherMonth Day"
e.Cell.Attribut es.Add("onmouse over",
"javascript:th is.className = 'OtherMonthDayO ver';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:th is.className = 'OtherMonthDay' ;")
End If
Else
If bEvent Then
e.Cell.ApplySty le(ForeOrange)
e.Cell.CssClass = "EventDay"
e.Cell.Attribut es.Add("onmouse over",
"javascript:th is.className = 'EventDayOver'; ")
e.Cell.Attribut es.Add("onmouse out",
"javascript:th is.className = 'EventDay';")
Else
e.Cell.CssClass = "Day"
e.Cell.Attribut es.Add("onmouse over",
"javascript:th is.className = 'DayOver';")
e.Cell.Attribut es.Add("onmouse out",
"javascript:th is.className = 'Day';")
End If
End If
Av.

"Shevek" <sh************ ****@moldy.me.u k> wrote in message
news:uk****** *************** ***********@4ax .com...
Hi All, Hope someone can help!

I am building an Event Calendar app based around the Calendar
WebControl which builds an SQL string based on the SelectedDates
property which is passed to Page.StartDate and Page.EndDate
properties.

This works nicely and I can select a Day, Week or Month and run my SQL
against them.

There is also a shortcuts dropdown to allow the user to select Today,
Last Month, This Month, Next Month, Next Two Weeks, Next 30 Days, Next
60 Days, Next 90 Days.

Again, these all work nicely as I set the Page.StartDate and
Page.EndDate based on the option and run the SQL then update the
Calendar.Visibl eDate to Page.StartDate.

The problem is it would be nice for the Calendar object to reflect the
shortcut ranges. This is OK for Today as I can just set the
SelectedDate to the Page.StartDate. However the SelectedDates property
is read only.

Is there any way to set a range of dates to be selected based on the
Page.StartDate and Page.EndDate properties?

Many TIA

--
Shevek

The Poster Previously Known As Moldy

--
Shevek

The Poster Previously Known As Moldy
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3672
by: Tim Graichen | last post by:
Hello, I am making use of the Active X calendar control (mscal.Calendar.7) in several places in my main form, with the following code Below is an example of the code I'm using for the controls. Private Sub DateSold_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) SoldCal.Visible = True
7
2757
by: TDIOwa | last post by:
I have a form that has a specific date on it. I want to open another form that has the Active Control Calendar on it. I want to open this form to the specific date on the first form. I have searched this forum high and low to find a solution and have tried virtually everything mentioned, all to no avail. Some solutions even crash the computer. Does anyone have any ideas? Thanks TD
1
1292
by: Peter | last post by:
Hi Is it possible that in the asp.net calendar control the selected date would be by default current day. I mean that user would not have to click todays date if the user wants to pick it but current date would be selected by default thanks Peter
0
984
by: Peer K | last post by:
Hello, This is driving me nuts! It's a bit hard to explain so please bare with me. I have an ASP.NET page that uses the calendar control. I use DayRender to set specific days selectable depending on data in a database. Works fine. I want to be able to give a user a direct link that shows content for a specified date - AND sets the calendar control to that date. I've done this by making a direct link in the form...
2
1354
by: Jay | last post by:
I had such good luck asking about a rich textbox control, that I will do the same for a calendar control. I want a calendar control (not a date picker) that will show day, week, month, year views, etc. and that can be bound to a datasource. Shareware Commericial product Thanks
8
1902
by: tfsmag | last post by:
i need to create a date range based on the current "shown" month on a calendar control to query a database and populate a datagrid based on that date range. how can i retrieve the "shown" month and year from the calendar control to create this range. Here is what i was thinking, all i need is the "shown" month and year to complete. ----------------------------------------------- Dim themonth as string = (need code to retreive "shown"...
2
364
by: niju | last post by:
Hi all, I am using a calendar control to populate date for users. However, I need to stop users from selecting date from past. Is there a way to populate calendar from DateTime.now onwards.Any help would be appreciated Many Thanks Niju
1
2220
by: Cong | last post by:
Hi I have two unbounded text boxes (startdate and enddate). If I entered the date manually I can can set validation for the text box for example < date() this will works but if I have a calendar control populating the date automaticcaly. It will bypass the validation. I try this for validation but does not
2
15166
by: Bob | last post by:
How do I show a calendar control or another appropriate control to pick a date and time for a cell in a column in a datagridview? Thanks for any help. Bob
0
9384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9973
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9645
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8645
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6473
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3276
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2612
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.