ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1735
Number of posts: 3305

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
help with calendar Posted by marcoskn1 on 19 Dec 2003 at 10:40 AM
i'm trying to put some dropdownlists , one to select year and another to select months

but i'd like these dropdowns to be with the current Month and Year of the calendar...

how can I do this ?


thanks!

Report
Re: help with calendar Posted by iwilld0it on 19 Dec 2003 at 11:32 AM
: i'm trying to put some dropdownlists , one to select year and another to select months
:
: but i'd like these dropdowns to be with the current Month and Year of the calendar...
:
: how can I do this ?
:
:
: thanks!
:
:

The code could look something like this.

Here is a sample of loading the dropdowns ...

cboMonths.Items.Add(New LisItem("January", "1"))
cboMonths.Items.Add(New LisItem("February", "2"))
cboMonths.Items.Add(New LisItem("March", "3"))
' etc ...

' I USUALLY use a loop to create this ...
cboYears.Items.Add(New ListItem("2003"))
cboYears.Items.Add(New ListItem("2002"))
cboYears.Items.Add(New ListItem("2001"))
' etc ...


I like to write functions to make the job easier ...


Public Sub SelectDate(ByRef Month As DropDownList, ByRef Year As DropDownList, ByVal someDate As Date)

    Dim li As ListItem
    li = Month.Items.FindByValue(someDate.Month.ToString)
    If Not li Is Nothing Then li.Selected = True

    li = Year.Items.FindByValue(someDate.Year.ToString)
    If Not li Is Nothing Then li.Selected = True

End Sub



Using the function to select todays date ...

Call SelectDate(cboMonths, cboYears, Date.Now)





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.