About MeIntegrating BlogEngineTweet Old Post
in .Net - 23 Jan, 2011
by Ajay Matharu - 8 comments
The name does not exists in the current context asp.net

Many a times while writing a code we get this error which says, “The name <control> does not exists in the current context”. This is because the code behind file is not able to find the control being added to your aspx file.

Control does not exists in current context

Control does not exists in current context

There are three possible solutions for this error,

1 – There are two classes with same name. Possibly you have renamed a page and created a new one, but you did not changed the name in the cs file. So make sure you have only one file with this name in your project. There may be two files with different name but same class name this may create problems.

2 – Multiple web.config files in your project. Make sure you have only one web.config file in your project. However you can have mulitple web.config files in your project but that has to be in particular format check here.

3 – The designer file is not refreshed.

control does not exists in current context designer file

control does not exists in current context designer file

In this case you have to delete the existing designer file

delete web page designer file

delete web page designer file

After deleting the file right click on the page, in this case default.aspx and select “Convert to web application”

regenerate designer file - convert page to web application

regenerate designer file - convert page to web application

Once you convert it will prompt for confirmation just select yes

web Page to web application conversion prompt

web Page to web application conversion prompt

Once converted you can see the added control declaration in the designer file.

New designer file after converting page to web application

New designer file after converting page to web application

Now you can use the control in your code behind.

Enjoy coding :)

  • abcd

    I have deleted the aspx.designer.cs file but on the right click I am not getting option ‘CONVERT O WEB APPLICATION’………..Can you plz tell me what might the problem?????????????????????

    • Vijendra

      Intellisense not working after doing above operation….

  • http://www.error1310.com/ Error 1310

    Error 1310 appears while saving or executing this code, Following are the steps outlined to detect the technical issues on your computer, and fix error 1310 your own:
    Log-In from the Server containing Installation Files
    Clean Previous Setup Configurations
    Ensure Administrative Privileges to Perform the Installation
    Reregister Windows Installer
    Clean the Setup Extracted Temporary Files

  • dotnet11

    I also did the above way but the problem persist till now…Showing me that ”
    control does not exists in current context¬†”….Please help me…

  • Mohini

    Thank Dost….chal gaya

  • Jigar Poladia

    Thank You Ajay. This works.

  • vijay

    s its solved.. two different aspx pages were refering to same cs file

    vijay

  • J.S

    thank you very much!