1

Visual Studio isn't behaving normally when I make a change in an aspx file. It makes changes to the designer.cs file. These changes mean that I cannot access any of my controls by their ID in my code behind file.

When I revert the changes (using SVN), that have been made behind my back, in the designer.cs file, my build succeeds again and everything works fine.

I see that Visual Studio deletes a lot of lines in the designer file.

I've read some similar issues on the web but I can't find a good solution for this.

Has anyone of you experienced the same problems with Visual Studio and can help me solving this?

Update: I found that Visual Studio adds this line to the designer.cs:

 protected global::System.Web.UI.WebControls.UpdatePanel UpdatePanel1;

But this should be:

 protected global::System.Web.UI.UpdatePanel UpdatePanel1;

When I make this change manually in the designer.cs file, it works. But every time I make a change to the aspx file, Visual Studio creates again the wrong reference.

Sir Crispalot
  • 4,792
  • 1
  • 39
  • 64
ThdK
  • 9,916
  • 23
  • 74
  • 101
  • 1
    Possible duplicate of http://stackoverflow.com/questions/45325/how-do-you-force-visual-studio-to-regenerate-the-designer-files-for-aspx-ascx-f – user1069816 Oct 13 '15 at 13:51

3 Answers3

4

im having the same issue. my workaround is moving the definition from the designer file to the code behind file and defining it properly as: Protected WithEvents UpdatePanel1 As Global.System.Web.UI.UpdatePanel

instead of letting designer keep overwriting it improperly as Protected WithEvents UpdatePanel1 As Global.System.Web.UI.WebControls.UpdatePanel

im using vs2013 vb.net asp web forms application.

i've also seen suggestions to change the target framework in the web.config file to 4.0 (did not work for me, im targeting 4.5, was getting the problem with both targets)

and i also saw a suggestion to use the Register tag like: <%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web"%> at the top of the page. this did resolve the 'error' that was being thrown when i tested it, however it caused numerous 'warnings' to appear for all of my asp tags.

benicillin
  • 101
  • 1
  • 3
4

My office is plagued by this issue in Visual Studio 2013. We were using the following workaround:

  1. Right-click on the project and select Properties.
  2. On the Application tab, change the Target framework version and save the project.
  3. Repeat steps 1 and 2 to set the target framework back to the one you want.
  4. Save the .aspx file again.

This would work 100% of the time, but we discovered that it messed up some of our web.config settings.

We are now using the following workaround, which also seems to work and does not make any breaking changes to the project config files:

  1. Right-click on the project and select Unload Project.
  2. Right-click on the project and select Reload Project.
  3. Save the .aspx file again.
m-smith
  • 2,943
  • 4
  • 25
  • 39
1

Make sure that the class name of the cs file is the same as the designer.cs and check the Inherits attribute of the page in the aspx file is the same. Also check if there is any class in your project with the same name as your page class name, also i would like to know the error that appear when you make any updates in the aspx page.

Samir Adel
  • 2,691
  • 2
  • 15
  • 16
  • I've made a change again and the designer.cs file has been changed. When i build this time, i only get 2 errors: The type or namespace name 'UpdatePanel' does not exist in the namespace 'System.Web.UI.WebControls' (are you missing an assembly reference?) – ThdK Feb 22 '12 at 11:44
  • Because one of the lines added to the designer files is: protected global::System.Web.UI.WebControls.UpdatePanel UpdatePanel1; – ThdK Feb 22 '12 at 11:45
  • is your application is asp.net 2 or 4 ?! – Samir Adel Feb 22 '12 at 12:03
  • update your web.config file to include the following – Samir Adel Feb 22 '12 at 15:20
  • I'm sorry to say but that line is already included in my web.config. But thanks for trying to find something that can resolve this issue. – ThdK Feb 23 '12 at 07:39
  • 1
    Did you ever figure out this issue? I have the same issue but I've only started getting it with VS 2013 – Kevin Nov 15 '13 at 03:50