Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 203937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:25:23+00:00 2026-05-11T17:25:23+00:00

For an unknown reason, I have 1 page that I can’t access by ID

  • 0

For an unknown reason, I have 1 page that I can’t access by ID to any of the component.

Here is some informations. The page use asp:Content because the website use MasterPage. Inside the asp:Content, this page has a asp:FormView with some data that I cannot access from the CodeBehind.

Here is the Page declaration:

Here is the code in the page behind that doesn’t compile :

protected void FormView1_PreRender(object sender, EventArgs e)
{
    DateBirthdayValidator.MaximumValue = DateTime.Now.Date.ToString("dd-MM-yy");
}

Here is the error :

Error 2 The name ‘DateBirthdayValidator’ does not exist in the current context

I have search in google, I got some answer about using FindControl but it doesn’t work. Any idea?

Edit1:

I can access the FormView1 component but no the validator inside the EditItemTemplate. How can I access control that is inside the EditTemplate?

Edit2:

If I try: FormView1.FindControl("DateBirthdayValidator") it compile but always return null. So still doesn’t work but at least I can access the FormView1…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:25:23+00:00Added an answer on May 11, 2026 at 5:25 pm
    protected void FormView1_PreRender(object sender, EventArgs e)
    {
        if(FormView1.CurrentMode == FormViewMode.Edit)
            ((RangeValidator)FormView1.FindControl("DateBirthdayValidator")).MaximumValue = DateTime.Now.Date.ToString("dd-MM-yy");
    }
    

    The FormView doesn’t have the control created until it’s in the mode you want. Since the DateBirhdayValidator was in the Edit Mode, it required to have a validation in the CodeBehind to be sure to Find the control only when the state is in edit.

    I found the solution here, see the post from Steven Cheng[MSFT].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple yield use case and for some unknown reason the default
I have a layout that should be fairly straightforward, but for some unknown reason
We have an application that generates pdf files, some times for some unknown reason,
I am trying to use log4net in a VB.NET app for some unknown reason
I have a mouse hook that (for an unknown reason) dies every now and
I have some trouble with XPath. For some unknown reason the result I get
For some unknown reason if I have: class A{ int stars; public int getStars(){
Using CSS we have a panel with overflow:auto. For some unknown reason the panel
For some unknown reason I'm running into a problem when passing a variable to
I have numerous functions (unknown at design time) that each take a specific number

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.