Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The name does not exist in the current context

Tags:

asp.net

I have a masterpage in my asp.net 3.5 application and I have some controls and jquery stuff. I try to access the controls in codebehind and it says :

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

Why it is not accessible in codebehind ?

like image 444
naveed Avatar asked Dec 21 '22 14:12

naveed


1 Answers

When you create a code behind file, ASP.NET also automatically generates a designer file (which is right next to it). In that designer file all the controls are initialized and loaded. Sometimes (for reasons unknown) when you create a new control, it fails to re-initialize the designer file and you can't get access to the control in the code behind file.

Try doing this >

  1. Delete the designer file (right click > delete)
  2. Right click on the aspx file > Convert to Web Application

Should work now

like image 84
neebz Avatar answered Jan 11 '23 20:01

neebz