52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.ComponentModel;
|
|
|
|
[DefaultBindingProperty("Time")]
|
|
public partial class utility_TimeInput : System.Web.UI.UserControl
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (ViewState["TIME"] != null)
|
|
SetTime(ViewState["TIME"].ToString());
|
|
}
|
|
|
|
[Bindable(BindableSupport.Yes, BindingDirection.TwoWay)]
|
|
public string Time
|
|
{
|
|
get
|
|
{
|
|
return GetTime();
|
|
}
|
|
set
|
|
{
|
|
ViewState["TIME"] = value;
|
|
SetTime(value);
|
|
}
|
|
}
|
|
|
|
private void SetTime(string time)
|
|
{
|
|
if (time == null || time.Length < 5)
|
|
return;
|
|
string h = time.Substring(0, 2);
|
|
string m = time.Substring(3, 2);
|
|
|
|
if (ddlHour.Items.FindByValue(h) != null)
|
|
ddlHour.SelectedValue = h;
|
|
|
|
if (ddlMinute.Items.FindByValue(m) != null)
|
|
ddlMinute.SelectedValue = m;
|
|
}
|
|
|
|
private string GetTime()
|
|
{
|
|
if (ddlHour.SelectedValue == "" || ddlMinute.SelectedValue == "")
|
|
return "";
|
|
else
|
|
return ddlHour.SelectedValue + ":" + ddlMinute.SelectedValue;
|
|
}
|
|
} |