我在asp.net中使用带有AJAX工具包的掩码用于文本框,但是文本框不会受到这个掩码的影响,这是我的代码:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
TagPrefix="ajax" %>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<ajax:MaskedEditExtender TargetControlID="TextBox1" Mask="99-9999-9999999-999"
MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="Number" InputDirection="LeftToRight" AcceptNegative="None"
DisplayMoney="None"
ErrorTooltipEnabled="True" runat="server" ID="mskD" />
</div>
</form>
答案 0 :(得分:0)
您需要包含ToolkitScriptManager而不是默认的ASP.NET ScriptManager
<ajax:ToolkitScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<ajax:MaskedEditExtender runat="server"
TargetControlID="TextBox1"
Mask="99-9999-9999999-999"
MessageValidatorTip="true"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="Number"
InputDirection="RightToLeft"
AcceptNegative="Left"
DisplayMoney="Left"
ErrorTooltipEnabled="True"/>
</div>
您可能需要在项目中包含AjaxMin.dll才能使ToolkitScriptManager正常工作。