By default asp.net calendar control shows dates of current month. How is it possible to change programatically default month view?
Thanks!
You can use VisibleDate Property like:
int yourdesiredmonth = 5;
Calendar1.VisibleDate = new DateTime(Calendar1.TodaysDate.Year,yourdesiredmonth,1);
Related
I am trying to filter a table using a DateBox. The problem I have is that it doesn't display the records of that day when binding value is set to #datasource.query.filters.date._equals. However, it does work when the filter is _greaterThanOrEquals, but it also includes later records.
I am using SQL tables with date field type is DATE.
It's a bug. We're looking into it.
For now please use workaround:
Remove the binding and set 2 filters in onValueEdit event with code like:
widget.datasource.query.filters.FIELD_NAME._greaterThanOrEquals = newValue;
widget.datasource.query.filters.FIELD_NAME._lessThanOrEquals = newValue ? new Date(newValue.getTime() + 24*60*60*1000) : null;
widget.datasource.load();
bind DateBox value to
#datasource.query.filters.NameOfDateFiled._equals
and don't forget reload datasource in "onValueChange" event.
I have put SharePoint Date Time control in asp.net application page...Problem is by default it is taking Today date how to "stop tanking today date"...Thank you
I prefer using own control instead of sp date control.
var dateControl = new DateTimeControl();
dateControl.ID = "anyId";
dateControl.DateOnly = true;
dateControl.CssClassTextBox = "cssclass";
dateControl.LocaleId = Convert.ToInt32(SPContext.Current.RegionalSettings.LocaleId);
dateControl.OnValueChangeClientScript = "onApplyDateChangeValue(event)";
//if you want to set any value
dateControl.SelectedDate = DateTime.ParseExact("dateString", "dd.MM.yyyy",CultureInfo.InvariantCulture);
//Add to app page
"elementID".Controls.Add(dateControl);
It is working fine
write below code in side click function:
if (!spCal2.IsDateEmpty)
{
lblShowdtae.Text = dtSPdate.SelectedDate.ToString();
}
I want to validate the RadDatePicker when a date is selected. User should not select greater than a particular date ? How can I restrict user from selecting a date which is not greater than a particular date.
Particular date populated from the database.
You can use CompareValidator Control.Just note to compare to your date (ValueToCompare) instead of (ControlToCompare) and set the type. By default it's string as i remember.so you need to set it to Date.Also look to this page.
On your other question:
How can I restrict user from selecting a date which is not greater than a particular date.
In C#:
RadDatePicker1.MaxDate = myMaxDateTimeVariable;
or client-side:
var radDatePicker1 = $find("<%= RadDatePicker1.ClientID %>");
radDatePicker1.set_maxDate(myMaxDate);
In my project, I have used CalenderExtender (which comes with AJAX Control Toolkit) in my webpages.
Now, I want my calender to strikeout or disable the previous dates.
How can I do it in CalenderExtender?
Please use the js as follow to Strike Out the Past Days:
function checkDate(sender, args) {
if (sender._selectedDate < new Date()) {
alert("You cannot select a day earlier than today!");
sender._selectedDate = new Date();
// set the date back to the current date
sender._textbox.set_Value(sender._selectedDate.format(sender._format))
}
}
I am using the Ajax Control Toolkit Calendar Extender control. In some fields though I want to display the time along with the date. I have tried just setting the Format to "dd/MM/yyyy hh:mm:ss" but the time section gets wiped off. If the user wants to change the time section they can do it manually, the calendar drop down is only used for changing the date part.
Are there any workarounds or alternatives to get this working?
I have a similar issue and I'm planning to use a Date field and an associated time dropdown (in 1/2 hour increments). User sets the date in the date field, optionally using the calendar control, and pulls down to a valid time. I plan to have one selection in the time drop down be a "don't care" in case it an "all day" event.
[EDIT] I found this jquery plugin that I may end up using. I also found a link to Gaia DateTimePicker in the answers to this post (which now looks to be deleted, probably because the OP was asking for WPF controls, not web controls).
The Ra-Ajax Calendar is coming out with TIME support this upcoming Friday (28th of Nov. 2008) and it's LGPL licensed...
Based on CalendarExtender, you can set the format as "MM/dd/yyyy". After the user select the date in calendar, it will return 04/28/2009 for example. In the date selected event, you can append the current time after the date returned.
OnClientDateSelectionChanged="dateselect"
function dateselect(ev)
{
var calendarBehavior1 = $find("Calendar1");
var d = calendarBehavior1._selectedDate;
var now = new Date();
calendarBehavior1.get_element().value = d.format("MM/dd/yyyy") + " "+now.format("HH:mm:ss")
}
The only way to add time component to the AjaxControlToolKit CalendarExtender, is to append it using OnClientDateSelectionChanged and JavaScript.
<ajaxToolkit:CalendarExtender ID="ce1" runat="server" PopupButtonID="calImg" Enabled="true" Format="dd/MM/yyyy" TargetControlID="txtLeft" PopupPosition="TopRight" OnClientDateSelectionChanged="AppendTime"></ajaxToolkit:CalendarExtender>
and
<script language="javascript" type="text/javascript">
//this script will get the date selected from the given calendarextender (ie: "sender") and append the
//current time to it.
function AppendTime(sender, args) {
var selectedDate = new Date();
selectedDate = sender.get_selectedDate();
var now = new Date();
sender.get_element().value = selectedDate.format("dd/MM/yyyy") + " " + now.format("hh:mm tt");
}
</script>