I am trying to set the time validator on the time textbox. Right now it is not possib开发者_开发知识库le to add anything that's not increments of 30 min intervals. How would I change the timeEntry() to allow any input form the user to set minutes but validate input at the same time. Basically I would like to be able to set any minutes for 1 to 60.
string script = @"jQuery('.time').timeEntry({timeSteps: [1,30,00]}} );";
ScriptManager.RegisterStartupScript(this, this.GetType(), "timeEntryScript", script, true);
if I switch it to {timeSteps: [1,00]} I get default values set to current minutes. So for instance, if I start typing 10 for hours and current time is 47 min. It will output 10:47. We want to default to 10:00 when typing in 10 for the hour.
Here is where I found the plugin comes from: http://keith-wood.name/timeEntryRef.html
Also I tried this: didn't work
string script = @"jQuery('.time').timeEntry({timeSteps: [1,0], defaultTime: '00:00AM', initialField:0});";
ScriptManager.RegisterStartupScript(this, this.GetType(), "timeEntryScript", script, true);
I emailed the guy who wrote this, his response was, quite "the feature is not supported". I went with .NET version of the control that works great. Here is where the code can be downloaded
http://www.michaelkbell.com/TimePicker/default.aspx
His documentation is not working so essentially what I did was added DLL to my bin directory, added TimePicker control to a panel on the page inside update panel. It automatically validates the input and corrects the time. Also there are down/up arrows.
List<DateTime> list = new List<DateTime>();
list.Add(DateTime.Now);
list.Add(DateTime.Now.AddSeconds(30));
list.Add(DateTime.Now.AddMinutes(30));
list.Add(DateTime.Now.AddHours(3));
TimeSelector timer = new TimeSelector();
timer.ID = "timer1";
timer.DisplayButtons = true;
timer.DisplaySeconds = false;
timer.SetTime(0, 0, TimeSelector.AmPmSpec.AM);
TimeSelectorAvailabilityValidator TimeSelectorAvailabilityValidator1 = new TimeSelectorAvailabilityValidator();
TimeSelectorAvailabilityValidator1.AppointmentList = list;
TimeSelectorAvailabilityValidator1.AppointmentLengthInMinutes = 90;
TimeSelectorAvailabilityValidator1.ControlToValidate = timer.UniqueID; // "myText";
pnlTimer.Controls.Add(timer);
public void SetTime(object sender, EventArgs args)
{
TimeSelector ts = (TimeSelector)pnlTimer.FindControl("timer1");
lblTime.Text = "Submitted Time: " + ts.Date.ToShortTimeString();
}
精彩评论