1

I have a validator in my page:

<asp:RequiredFieldValidator ID="rfv1" runat="server" ControlToValidate="IdentifySEDSED1TxtDate" ErrorMessage="Significant Event Date 1 is missing" ValidType="SEDate">*</asp:RequiredFieldValidator>

I found that in Page_Load: (below is a screen shot from the Watch Window)

this.FindControl("rfv1")    {Text = "*"}    

rfv1    The name 'rfv1' does not exist in the current context

See, I can get this control with FindControl, but I can't get it using ID directly! What happens?

Cheng Chen
  • 42,509
  • 16
  • 113
  • 174
  • Not sure if it applies here, but I've had a simliar problem writing C# win forms: when I declared a variable and initialized it, the watch window gave the same message as you have, but when I actually used it, everything was and it showed the value. – Rox Jun 10 '10 at 07:51
  • Is your Validator inside a FormView? – Tim Schmelter Jun 10 '10 at 08:05

1 Answers1

0

If you are finding the panels on the page, you need to find them in the form of the page, as panels are placed inside the form, but not on the page directly.

Atleast I assume that this is the problem....

does this work:

this.Form.FindControl(rfv1);
VoodooChild
  • 9,776
  • 8
  • 66
  • 99