Weekly view for Calendar control or 3rd Party component

G

Guest

Hello.

I am using the ASP.NET calendar object and am looking to provide a "weekly
view", but not the typical "Outlook" style. Rather, I just want it to render
the calendar normally, but only display the current week and not any of the
other weeks within the given month.

If this isn't possible with the built-in component, has anyone else solved
this issue with a third party component?

Thanks in advance.
 
K

Ken Cox - Microsoft MVP

Hi Brenden,

I'm not sure if this is what you're after, but it was a fun little project.

If it's what you're after, let us know?

Ken
Microsoft MVP [ASP.NET]


<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim dt As DateTime
dt = Now
Calendar1.VisibleDate = dt
Calendar1.SelectedDate = dt
End Sub

Public Shared Function Week _
(ByVal tdDate As System.DateTime) As Integer
Dim myCI As New Globalization.CultureInfo("en-US")
Dim myCal As Globalization.Calendar = myCI.Calendar
Dim myCWR As Globalization.CalendarWeekRule = _
myCI.DateTimeFormat.CalendarWeekRule
Dim myFirstDOW As DayOfWeek = _
myCI.DateTimeFormat.FirstDayOfWeek
Return myCal.GetWeekOfYear(tdDate, myCWR, myFirstDOW)
End Function

Protected Sub Calendar1_DayRender _
(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DayRenderEventArgs)
If Week(e.Day.Date) <> Week(Calendar1.SelectedDate) Then
e.Cell.Text = ""
End If
End Sub




</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:calendar id="Calendar1" runat="server"
ondayrender="Calendar1_DayRender"></asp:calendar>

</div>
</form>
</body>
</html>
 
G

Guest

Thank you Ken.

That was what I was trying to achieve. I should be able to modify your
example to meet my needs.

Much appreciated.

-Brenden

Ken Cox - Microsoft MVP said:
Hi Brenden,

I'm not sure if this is what you're after, but it was a fun little project.

If it's what you're after, let us know?

Ken
Microsoft MVP [ASP.NET]


<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim dt As DateTime
dt = Now
Calendar1.VisibleDate = dt
Calendar1.SelectedDate = dt
End Sub

Public Shared Function Week _
(ByVal tdDate As System.DateTime) As Integer
Dim myCI As New Globalization.CultureInfo("en-US")
Dim myCal As Globalization.Calendar = myCI.Calendar
Dim myCWR As Globalization.CalendarWeekRule = _
myCI.DateTimeFormat.CalendarWeekRule
Dim myFirstDOW As DayOfWeek = _
myCI.DateTimeFormat.FirstDayOfWeek
Return myCal.GetWeekOfYear(tdDate, myCWR, myFirstDOW)
End Function

Protected Sub Calendar1_DayRender _
(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DayRenderEventArgs)
If Week(e.Day.Date) <> Week(Calendar1.SelectedDate) Then
e.Cell.Text = ""
End If
End Sub




</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:calendar id="Calendar1" runat="server"
ondayrender="Calendar1_DayRender"></asp:calendar>

</div>
</form>
</body>
</html>

Brenden Bixler said:
Hello.

I am using the ASP.NET calendar object and am looking to provide a "weekly
view", but not the typical "Outlook" style. Rather, I just want it to
render
the calendar normally, but only display the current week and not any of
the
other weeks within the given month.

If this isn't possible with the built-in component, has anyone else solved
this issue with a third party component?

Thanks in advance.
 
Joined
Oct 16, 2007
Messages
2
Reaction score
0
problem:weekly calender asp.net 2.0

Hi Ken,

in your suggested calender when we click on the next or previous button, the dates are not displayed on the calender,wht can i do ,pls help me.

Thnx in advance.
 
Joined
Oct 16, 2007
Messages
2
Reaction score
0
Hi,

in above suggested calender when we click on the next or previous button, the dates pertaining to next week are not displayed on the calender,wht can i do ,can anyone help me.

Thnx in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top