當然
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
LinkButton的守則的UpdatePanel內的用戶控件的一部分:
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
}
是的,我想我會忘掉這一點。謝謝 – 2009-06-12 15:10:07
您是使用MaskedEditValidator控件,還是分配了EnableEventValidation =「false」? – 2011-01-12 17:43:55