Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: asp.net calendar enhancement

Reply
Thread Tools

Re: asp.net calendar enhancement

 
 
Fred.
Guest
Posts: n/a
 
      06-25-2003
Not sure how you intend to get input from the user but here's a sample
that allows selection from a listbox.

Drop the following code and codebehind into an ASPX page named
CustCal.
Set the Default namespace of the project to CSWeb.
Give it a try, nothing that this sample only does future navigation

(Is the CN tower in the clouds today?)

- Fred

**************ASPX code**********************
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="CustCal.aspx.vb" Inherits="VBWeb.CustCal" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Birthday Calendar</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Calendar id="Calendar1" style="Z-INDEX: 103; LEFT: 27px;
POSITION: absolute; TOP: 21px" runat="server" BackColor="#C0FFFF"
BorderStyle="Solid" Height="276px" Width="328px" ShowGridLines="True">
<DayStyle Font-Size="Smaller" Font-Names="Arial"></DayStyle>
<DayHeaderStyle Font-Size="XX-Small" Font-Names="Arial"
BackColor="#FFC0FF"></DayHeaderStyle>
<TitleStyle Font-Names="Arial"
BackColor="#C0C0FF"></TitleStyle>
</asp:Calendar>
<asp:ListBox id="lstMonth" style="Z-INDEX: 102; LEFT: 309px;
POSITION: absolute; TOP: 27px" runat="server" Font-Names="Arial"
Font-Size="XX-Small" Height="163px" Width="41px" Visible="False"
AutoPostBack="True"></asp:ListBox>
</form>
</body>
</HTML>

************** code behind **********************
Public Class CustCal
Inherits System.Web.UI.Page
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar
Protected WithEvents lstMonth As System.Web.UI.WebControls.ListBox

<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
InitializeComponent()
End Sub

Private Sub Calendar1_VisibleMonthChanged(ByVal sender As
System.Object, ByVal e As
System.Web.UI.WebControls.MonthChangedEventArgs) Handles
Calendar1.VisibleMonthChanged
'effectively cancel the navigation
Calendar1.VisibleDate = e.PreviousDate
'get a new month to display
ShowMonthSelector(e.PreviousDate)
End Sub

Private Function ShowMonthSelector(ByVal dtCurrent As Date) As Date
Dim i As Integer
'display an ordered list starting with the next month
lstMonth.Items.Clear()
For i = 1 To 12
lstMonth.Items.Add(Format(dtCurrent.AddMonths(i), "MMM"))
Next
lstMonth.Visible = True
End Function

Private Sub lstMonth_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
lstMonth.SelectedIndexChanged
Dim iMonth As Integer
Dim iYear As Integer
'set the calendar to the selecteed month
lstMonth.Visible = False
iMonth = Calendar1.VisibleDate.Month + lstMonth.SelectedIndex + 1
iYear = Calendar1.VisibleDate.Year
If iMonth > 12 Then
iYear += 1
iMonth = iMonth Mod 12
End If
Calendar1.VisibleDate = New Date(iYear, iMonth, 1)
End Sub
End Class



"Marlene" <(E-Mail Removed)> wrote in message news:<0bb801c33b2a$63a99830$(E-Mail Removed)>...
> Hello,
>
> I'm using the VB.net calendar for my aspx page and I was
> wondering if it is possible to enhance it so that the
> user can directly select which month and which year they
> would like to go to rather than only being able to go the
> next or previous months. If it is, how do I do this?
>
> Thanks,
> Marlene

 
Reply With Quote
 
 
 
 
Cann
Guest
Posts: n/a
 
      07-15-2003
http://cheapdevtools.com/product/product.asp?ProdID=246

> "Marlene" <(E-Mail Removed)> wrote in message news:<0bb801c33b2a$63a99830$(E-Mail Removed)>...
> > Hello,
> >
> > I'm using the VB.net calendar for my aspx page and I was
> > wondering if it is possible to enhance it so that the
> > user can directly select which month and which year they
> > would like to go to rather than only being able to go the
> > next or previous months. If it is, how do I do this?
> >
> > Thanks,
> > Marlene

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Firewall software enhancement suggestion ultimotion@gmail.com Cisco 0 11-29-2005 02:25 PM
Link TARGET Attribute Enhancement randau HTML 30 05-20-2005 09:09 AM
FlashIME2.0, the last editor enhancement you need! redguardtoo XML 0 07-26-2004 04:10 AM
nested if enhancement? Stephen XML 1 03-01-2004 07:58 PM
Re: asp.net calendar enhancement Marlene ASP .Net 0 06-25-2003 04:23 PM



Advertisments