当然
ASPX 部分:
<td><asp:TextBox id="textBeginStation" runat="server"></asp:TextBox></td>
<td>
<asp:TextBox ID="textBeginServiceDateTime" runat="server"></asp:TextBox>
<ajaxToolkit:MaskedEditExtender
ID="textBeginServiceDateTimeMaskedEditExtender" runat="server"
TargetControlID="textBeginServiceDateTime" MaskType="DateTime"
Mask="9999/99/99 99:99" UserDateFormat="YearMonthDay"
UserTimeFormat="TwentyFourHour">
</ajaxToolkit:MaskedEditExtender>
</td>
<td>
<asp:TextBox ID="textBeginStationDateTime" runat="server"></asp:TextBox>
<ajaxToolkit:MaskedEditExtender
ID="textBeginStationDateTimeMaskedEditExtender" runat="server"
TargetControlID="textBeginStationDateTime" MaskType="DateTime"
AutoComplete="False" Mask="9999/99/99 99:99" UserDateFormat="YearMonthDay"
UserTimeFormat="TwentyFourHour" EnableViewState="False">
</ajaxToolkit:MaskedEditExtender>
</td>
<td><asp:TextBox ID="textBeginRemarque" runat="server"></asp:TextBox></td>
这只是一个示例,其余部分非常相似。这是包含在 MS AJAX 的 UpdatePanel 中的 UserControl 的一部分
链接按钮代码:
ProductionDependencyFactory depFactory = new ProductionDependencyFactory();
try
{
DateTime beginServiceDateTime = DateTime.Parse(textBeginServiceDateTime.Text);
DateTime beginStationDateTime = DateTime.Parse(textBeginStationDateTime.Text);
DateTime endServiceDateTime = DateTime.Parse(textEndServiceDateTime.Text);
DateTime endStationDateTime = DateTime.Parse(textEndStationDateTime.Text);
NormalTrainTimeMilageCalculator calculator = depFactory.Create<NormalTrainTimeMilageCalculator>();
calculator.BeginStation = textBeginStation.Text;
calculator.BeginServiceDateTime = beginServiceDateTime;
calculator.BeginStationDateTime = beginStationDateTime;
calculator.EndStationDateTime = endStationDateTime;
calculator.EndServiceDateTime = endServiceDateTime;
calculator.EndStation = textEndStation.Text;
labelTotalHour.Text = calculator.TotalTime().Hours.ToString();
labelTotalMinute.Text = calculator.TotalTime().Minutes.ToString();
labelTotalMilage.Text = calculator.TotalMilage().ToString();
}
catch (Exception)
{
// Do nothing
}