Why do I get runtime error "Control ... cannot be verified"?

Posted on 2007-08-09
Last Modified: 2013-11-05
I'm trying to validate a radio button using a asp:CustomValidator. The general idea is that if the button is checked, a text box must have a valid date string. I get this run-time error when the Page.IsValid statement is evaluated -

"System.Web.HttpException: Control 'SettledBtn' referenced by the ControlToValidate property of 'SettledBtnCustomValidator' cannot be validated"

The page uses a Master page, and is organized as follows:

<asp:Content ...
<asp:ScriptManager ...
<table> ...
    <td style="background-color: #F0F5FF">

      <asp:RadioButton ID="SettledBtn" runat="server" GroupName="BatchBtns" Text="Settled"
               CausesValidation="true" OnCheckedChanged="RadioButton_CheckedChanged"  AutoPostBack="True" />

   </td>  ....
    <td style="width: 187px">
    <asp:TextBox ID="FromDate0" runat="server"></asp:TextBox>

    <asp:CustomValidator ID="SettledBtnCustomValidator" runat="server" ErrorMessage="From date required"
    ControlToValidate="SettledBtn" ValidationGroup="DateValidators"
     OnServerValidate="SettledBtnValidator_ServerValidate"  ></asp:CustomValidator>  
  <asp:AsyncPostBackTrigger ControlID="FromDate0" EventName="TextChanged" />
  <asp:AsyncPostBackTrigger ControlID="ToDate0" EventName="TextChanged" />

There are additional range and compare validator controls attached to the TromDate0 text box.
The code-behind is:

protected void SettledBtnValidator_ServerValidate(object source, ServerValidateEventArgs args)
// 'Settled batches' option was selected, so a 'From' date is required
args.IsValid = (SettledBtn.Checked && ! String.IsNullOrEmpty(FromDate0.Text));

This is quite frustrating, as I really need a clue. Any ideas why a radio button '... cannot be validated'?
Thanks for your help
Question by:shellback
    LVL 8

    Expert Comment

    Here ControlToValidate="FromDate0" text box not button

    Author Comment

    Thanks sabeesh - however, I just tried changing ControlToValidate to FromDate0. Compiled and published the website. After checking the settled button and leaving the FromDate0 textbox empty, I submitted the page. The desired error message 'From date required' did not appear, and the page continued on.

    I misstated when the runtime error occurs - it happens immediately after I check the settled button.

    Author Comment

    To anyone struggling with a similar problem - it seems that some controls cannot be validated with current validation controls, and radiobutton is one of them, the checkbox is another. I found a work-around suggested in the following discussion of CustomValidator controls (see

    Basically, the idea is to use the CustomValidator control without setting the ControlToValidate property. The server-side event handler still executes, however, the Value property of the arguments parameter passed in to the event handler contains an empty string. In my case, this was not a problem, as I could still refer to the controls I wanted to validate.

    The solution to the posted problem above:

     <asp:CustomValidator ID="SettledBtnCustomValidator" runat="server" ErrorMessage="From date required"
     OnServerValidate="SettledBtnValidator_ServerValidate"  ></asp:CustomValidator>  

    Note - no ControlToValidate property.  the event handler remains the same:

    protected void SettledBtnValidator_ServerValidate(object source, ServerValidateEventArgs args)
    // 'Settled batches' option was selected, so a 'From' date is required
    args.IsValid = (SettledBtn.Checked && !String.IsNullOrEmpty(FromDate0.Text));

    This works because I don't need to refer to args.Value in the event handler.

    Please close this question

    LVL 1

    Accepted Solution

    Closed, 250 points refunded.
    Community Support Moderator

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now