views:

37

answers:

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?

A: 

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
In fact FindControl(id) can get this control, while using ID directly won't.
Danny Chen
How exactly code behind file and the page markup look like? Are you placing assignment in the Page_Load?
VoodooChild
are you using Visual Web Developer
VoodooChild
http://forums.asp.net/t/1006588.aspx may answer
VoodooChild