我正在使用的MaskedEditExtender
控件设置为MaskType="DateTime"
和AcceptAMPM="true"
,但我需要知道用户如何更改上午/下午而无需输入AM A
和PM P
?有没有办法可以在此控件中添加箭头或其他内容,以便在从AM更改为PM时更加用户友好?我的用户不会知道他们需要输入要更改的值。
<asp:TextBox ID="txtDateTime" runat="server"></asp:TextBox>
<asp:MaskedEditExtender ID="MaskedEditExtender1" runat="server"
TargetControlID="txtDateTime" MaskType="DateTime" Mask="99/99/9999 99:99"
MessageValidatorTip="true" CultureName="en-US" ErrorTooltipEnabled="True"
AcceptAMPM="true">
</asp:MaskedEditExtender>
答案 0 :(得分:0)
我认为没有任何方法可以改变功能,至少在没有大量工作的情况下。如果您需要更灵活的东西,我建议您查看jQuery Timepicker。
答案 1 :(得分:0)
<script type="text/javascript">
//Set the default text to "PM"
var mee;
function pageLoad() {
//Please use your MaskedEditExtender's id or behaviorId.
mee = $find("MaskedEditExtender3");
//The target textbox control
var e = mee.get_element();
//Remove the focus event handler
if (mee._focusHandler) {
$removeHandler(e, "focus", mee._focusHandler);
}
//Add a new focus event handler which inherits from the old one.
mee._focusHandler = Function.createDelegate(mee, newFocus);
$addHandler(e, "focus", mee._focusHandler);
}
function newFocus() {
mee._onFocus();
if ((mee._MaskType == AjaxControlToolkit.MaskedEditType.Time || mee._MaskType == AjaxControlToolkit.MaskedEditType.DateTime) && mee.get_CultureAMPMPlaceholder() != "" && mee._getClearMask() == "") {
if (mee._AcceptAmPm) {
//The original code of default AM/PM text in function _onFocus() is:
//this.InsertAMPM(this.get_CultureAMPMPlaceholder().substring(0,1));
mee.InsertAMPM(meeTueEndCorp.get_CultureFirstLetterPM());
mee.setSelectionRange(0, 0);
}
}
}
</script>
<div>
<strong>Enter Time (format: <em>99:99:99</em>):</strong>
<br />
<asp:TextBox ID="TextBox3" runat="server" Width="130px" Height="16px" />
<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender3" runat="server" TargetControlID="TextBox3"
Mask="99:99:99" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError" MaskType="Time" AcceptAMPM="True" ErrorTooltipEnabled="True" />
<ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator3" runat="server" ControlExtender="MaskedEditExtender3"
ControlToValidate="TextBox3" IsValidEmpty="False" EmptyValueMessage="Time is required"
InvalidValueMessage="Time is invalid" Display="Dynamic" TooltipMessage="Input a time"
EmptyValueBlurredText="*" InvalidValueBlurredMessage="*" />
<br />
<em><span style="font-size: 8pt">Tip: Type 'A' or 'P' to switch AM/PM</span></em>
</div>
</form>
检查此链接,可能会有所帮助。 http://forums.asp.net/t/1339632.aspx 或者,如果要将默认值设置为PM。我已经修改了ajax控件工具包代码中的代码并再次编译它以默认为PM工作。 在我的博客上查看此代码。