468,746 Members | 1,921 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,746 developers. It's quick & easy.

Weekly view for Calendar control or 3rd Party component

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.
Apr 3 '06 #1
2 2240
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" <Br***********@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
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.

Apr 3 '06 #2
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" wrote:
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" <Br***********@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
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.


Apr 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Luis E Valencia | last post: by
reply views Thread by maxrawson | last post: by
2 posts views Thread by Caesar Augustus | last post: by
5 posts views Thread by Peter | last post: by
2 posts views Thread by Paul | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.