gpt4 book ai didi

ASP.NET 自定义验证器错误消息 : Control referenced by the property cannot be validated

转载 作者:行者123 更新时间:2023-12-02 05:48:58 25 4
gpt4 key购买 nike

我使用 ASP.NET 并有一个 Button 和一个 CustomValidator,它必须进行验证按钮。

<asp:Button ID="saveButton" runat="server" OnClick="SaveButton_Click" Text="Speichern"
CausesValidation="true"/>
<asp:CustomValidator runat="server" ID="saveCValidator" Display="Static"
OnServerValidate="EditPriceCValidator_ServerValidate"
ControlToValidate="saveButton" ErrorMessage="">

加载页面时,我收到错误消息:

"Control 'saveButton' referenced by the ControlToValidate property of 'saveCValidator' cannot be validated."

可能是什么问题?我在网上搜索过,但这没有多大帮助。

最佳答案

AFAIK,ControlToValidate 属性应指向输入控件,或为 CustomValidator 控件留空。

来自MSDN的引用:

Use the ControlToValidate property to specify the input control to validate. This property must be set to the ID of an input control for all validation controls except the CustomValidator control, which can be left blank. If you do not specify a valid input control, an exception will be thrown when the page is rendered. The ID must refer to a control within the same container as the validation control. It must be in the same page or user control, or it must be in the same template of a templated control.

The standard controls that can be validated are:

  • System.Web.UI.WebControls.DropDownList
  • System.Web.UI.WebControls.FileUpload
  • System.Web.UI.WebControls.ListBox
  • System.Web.UI.WebControls.RadioButtonList
  • System.Web.UI.WebControls.TextBox
  • System.Web.UI.HtmlControls.HtmlInputFile
  • System.Web.UI.HtmlControls.HtmlInputPassword
  • System.Web.UI.HtmlControls.HtmlInputText
  • System.Web.UI.HtmlControls.HtmlSelect
  • System.Web.UI.HtmlControls.HtmlTextArea

关于ASP.NET 自定义验证器错误消息 : Control referenced by the property cannot be validated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2637702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com