Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 990
  • Last Modified:

C#: field validation: "does not contain a definition for 'Requiredfieldvalidator3'" ?

Hoi all...
I have the following working code:
-----------------------------
<form id="Form1" method="post" runat="server">
<asp:ValidationSummary runat="server" HeaderText="Please correct the following errors:" ShowSummary="true"
      DisplayMode="BulletList" ID="Validationsummary1" />

Variable name:
<!--StartFragment -->
<asp:RequiredFieldValidator ControlToValidate="variableName" runat="server" ErrorMessage="Please enter a name for the variable." id="RequiredFieldValidator1">
      Enter a name for the variable.
</asp:RequiredFieldValidator>
<input id="variableName" style="WIDTH: 640px" type="text" runat="server"><br>
<br>
English:
<asp:RequiredFieldValidator ControlToValidate="txtEnglish" runat="server" ErrorMessage="English text is missing." id="Requiredfieldvalidator2">
      Please enter an english text.
</asp:requiredfieldvalidator><br>
<input type="text" id="txtEnglish" runat="server" style="WIDTH:640px" NAME="txtEnglish"><br>
<br>
<asp:button id="Button1" style="" runat="server" Text="Save" Width="144px"></asp:button>

</form>
-----------------------------


This works as it should.
If I add a new field with validation i get the error message:
"'ASP.multiLanguageEditVariable_aspx' does not contain a definition for 'Requiredfieldvalidator3'"

This is the new (and broken) code:


-----------------------------
<form id="Form1" method="post" runat="server">
<asp:ValidationSummary runat="server" HeaderText="Please correct the following errors:" ShowSummary="true"
      DisplayMode="BulletList" ID="Validationsummary1" />

Variable name:
<!--StartFragment -->
<asp:RequiredFieldValidator ControlToValidate="variableName" runat="server" ErrorMessage="Please enter a name for the variable." id="RequiredFieldValidator1">
      Enter a name for the variable.
</asp:RequiredFieldValidator>
<input id="variableName" style="WIDTH: 640px" type="text" runat="server"><br>
<br>
English:
<asp:RequiredFieldValidator ControlToValidate="txtEnglish" runat="server" ErrorMessage="English text is missing." id="Requiredfieldvalidator2">
      Please enter an english text.
</asp:requiredfieldvalidator><br>
<input type="text" id="txtEnglish" runat="server" style="WIDTH:640px" NAME="txtEnglish"><br>
<br>
German:
<asp:RequiredFieldValidator ControlToValidate="txtGerman" runat="server" ErrorMessage="German translation is missing." id="Requiredfieldvalidator3">
      Please enter a translation.
</asp:requiredfieldvalidator><br>
<input type="text" id="txtGerman" runat="server" style="WIDTH:640px" NAME="txtGerman"><br>
<br>
<asp:button id="Button1" style="" runat="server" Text="Save" Width="144px"></asp:button>

</form>
0
Smoerble
Asked:
Smoerble
1 Solution
 
atomicchipCommented:
It looks like your RequiredFieldValidator3 (or is it Requiredfieldvalidator3 - as shown in your error) is not referenced properly in the code-behind. Check to make sure that there is a protected object named Requiredfieldvalidator3 declared in the code-behind. Also, make sure that the case used in the code-behind matches the case used in the aspx page.

Hope that helps,
DB
0
 
SmoerbleAuthor Commented:
Yes, it helped, thank you.
125 credits for you :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now