Designer.cs not updating when new controls added t

2019-01-11 10:17发布

I've added a new control to my aspx files and noticed that not only was the new control not added to the designer file but that it was also missing quite a few other controls that were added by other members of the team. I've tried deleting the designer.cs file and using "Convert to Web Application" with no success. Some other things i've tried have been excluding the aspx from the project, building, and then re-including with no success. I've also manually entered in a control that was missing in the designer into the designer. When I run after do so an error appears saying the control isn't defined, even though it actually is, and that I should check if I'm missing a directive.

The first control I added was copy and paste from a similar control and made necessary changes. But, i've also tried manually creating the control with the same results.

Any ideas?

11条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-11 10:56

For me the solution was to:

Put your page in design view and right click / refresh. It will sync the controls with the designer.cs. Make sure designer.cs is close before doing this.

Source

查看更多
贼婆χ
3楼-- · 2019-01-11 10:57

To replace the designer file in VS 2013:

  1. Delete the old *.designer.cs file
  2. select the *.aspx file
  3. Select “Convert to Web Application“ from the Project top drop-down bar
查看更多
一纸荒年 Trace。
4楼-- · 2019-01-11 11:00

One simple/stupid mistake that also results in similar symptoms is if you copy aspx and aspx.cs files and rename them, but neglect to update the references inside the file.

I came across this question trying to find the temp asp.net directory, but clearing that didn't help. I then realized that I did not update CodeFile="Page.ascx.cs" after I had copied the files to create a new modified version of the page. Then i was trying to add a control and reference it in PageModified.ascx.cs but kept saying it didn't exist.

查看更多
我命由我不由天
5楼-- · 2019-01-11 11:00

This also seems to happen when you have a usercontrol that references another usercontrol in the same namespace. if you move the referenced user control to a different namespace the problem goes away

查看更多
我想做一个坏孩纸
6楼-- · 2019-01-11 11:01

Sometimes there might be errors in html like two controls having the same Id. Also be careful with div and span tags. These stops the designer from getting updated. For all of these, check the warnings in Error List and fix them. You are ready to go. This solved my issue.

查看更多
7楼-- · 2019-01-11 11:07

Try this

1.- Change CodeBehind="Name.aspx.cs" to CodeFile ="Name.aspx.cs"

2.- Build

3.- Change CodeFile ="Name.aspx.cs" to CodeBehind ="Name.aspx.cs"

查看更多
登录 后发表回答