Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ajax Calendar: Is there an option for DateTime .. not just Date?

Status
Not open for further replies.

fr2

Programmer
May 13, 2008
45
US
Am using the Ajax calendar .. and I can select a date and it puts it in the textbox ..ok.

However I need it to select DateTime ex.
2/2/2009 12:00AM ..say as default when you select a date.

Is there an option on the calendar for datetime .. instead of just date?
 
What I did, and this may not be right, was to append the time as Now() to the date. This way it grabs the system time.
 
bigfoot ... not clear on your answer .. what if the date is in the future?

say the user picks a date like "9/24/2008" ... i want it to show in the textbox as

"9/24/2008 12:00AM" instead .... so I'm not clear on this suggestion .. since I believe Now() shows the current datetime .. not the future!


jmeckley:
I looked at the sample demo .. but there is no datetime datef format .. this is what I saw ..

* reserved characters = [d,M,y]
Try these...

Date: MMMM d, yyyy
MMM d, yyyy
Default

 
Sorry fr2, that was a before coffee answer.
The Calendar control will only display and return date information. If you need time information then you have to use a control similar to Outlook's scheduler.

If you need it at "12:00AM" then you could append that onto the date the control returns.
If the user needs to pick a date then you're kinda stuck.
Unless you want to subclass the datetime control.

Sorry, did that answer it? I've always bought whatever control does what I want but my current company is um "thrifty" LOL, and I don't have that luxury here.
 
if you select a date then it automatically defaults the time to 12:00 am.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
bigfoot:
Hmm .. this is getting trickier .. and about to throw in the towel!

"If you need it at "12:00AM" then you could append that onto the date the control returns"

The problem is the calender control and the associated textbox is contained in a formview control .. so the controls are not visible when I go to the page-behind code to write code to grab the date selected .... plus the date is selected from the calendar prior to clicking the "Update" buttom on the formview .. so its all kinda jacascript that inserts the date into the textbox ... all kinda behind the scenes ...

Do you know of how I would grab the date returned from within a formview control?

jmeckley:
"if you select a date then it automatically defaults the time to 12:00 am."

Are u sure? I went to the link u provided and I selected several different dates to test and only the date shows, no time
 
that's just formatting. a DateTime object contains all parts. how you format for display irrelevant.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
fr2, are you using the Ajax Calendar control, or the New 2.0 version?

And I feel your pain on the FormView but there's an excellent workaround. Any control in the formview can be had with FindControl, and it's easy to code.

Say you're looking for a textbox. It would work like this:
Dim text As String = DirectCast(DataView1.FindControl("myTextbox"), Label).Text

This would assign the value of the textbox to text, but you could also create an object of type Webcontrols.Textbox and use it.

But in your case you don't have to.
in your Calendar inside your FormView, there's a Format command that looks like this:
Format="MMMM d, yyyy" Do as jmeckley suggests and change it to: Format="MMMM d, yyyy hh:mm:ss". It will come out as 12:00:00

Hope this helps.






 
Thank you bigfoot .. it worked .. Actually I used the format
"M/d/yyyy hh:mm:ss" .. which is what I need and it worked great

just curious .. is there a way to tweak the format so that it appends "AM" to the selected date .. say
9/24/2008 12:00:00 AM"

if not no big deal! .. Thanks again


<cc1:CalendarExtender ID="CalendarExtender2" Format="M/d/yyyy hh:mm:ss" runat="server" CssClass="MyCalendar"
PopupPosition="right" TargetControlID="txtDateTime" PopupButtonID="imgCalendar" >
</cc1:CalendarExtender>
 
jmeckley

Thanks soo much!

Format="M/d/yyyy hh:mm:ss tt"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top