chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore - 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user