我在文本框上有一个必填字段Validator,上面有一个Watermark。我正在使用Ajax Toolkit ValidatorCalloutExtender。用户仍然可以单击提交按钮而不进行任何验证。我在网上研究但找不到有用的信息。我不确定我在这里缺少什么。
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" Width="403px"
Text='<%# Bind("Email") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldEmail" runat="server"
ErrorMessage="*** This is a required field ***" ControlToValidate="TextBox6" Display="None"
Font-Bold="True" ForeColor="#FF3300"></asp:RequiredFieldValidator>
<ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtenderEmail" runat="server" TargetControlID="RequiredFieldEmail" HighlightCssClass="validatorCalloutHighlight">
</ajaxToolkit:ValidatorCalloutExtender>
<ajaxToolkit:TextBoxWatermarkExtender ID="AuthorEmail_TextBoxWatermarkExtender" runat="server"
Enabled="True" WatermarkText="<<Type the first 4 letters of the first name to autopopulate>>"
TargetControlID="TextBox6">
</ajaxToolkit:TextBoxWatermarkExtender>
<ajaxToolkit:AutoCompleteExtender ID="autoComplete00" runat="server" EnableCaching="true"
BehaviorID="AutoCompleteExa" MinimumPrefixLength="3" TargetControlID="TextBox6"
ServicePath="../AutoComplete.asmx" ServiceMethod="GetCompletionList" CompletionInterval="1000"
CompletionSetCount="10" CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true">
</ajaxToolkit:AutoCompleteExtender>
</EditItemTemplate>
答案 0 :(得分:1)
将RequiredFieldValidator的InitialValue设置为WatermarkText。修改所需的fieldvalidator的标记,如下所示,看看它是否有帮助。
<asp:RequiredFieldValidator ID="RequiredFieldEmail" runat="server" ErrorMessage="*** This is a required field ***" ControlToValidate="TextBox6" Display="None" InitialValue="<<Type the first 4 letters of the first name to autopopulate>>" Font-Bold="True" ForeColor="#FF3300"></asp:RequiredFieldValidator>