简体   繁体   中英

Visual studio 2010 not generating new control definitions in designer file

I am getting an occasional problem where, after adding a new control to an aspx page, the control definition is not created in the designer file - meaning its undefined in codebehind. Either if you type a new control into source or drag and drop from the toolbox, the designer is not updated. There are no errors or warnings on the page.

So far I've only seen it on aspx pages using nested master pages. At the same time as this error is occurring on the aspx page, designer updates DO work on user controls

The usual tricks of switching from source view to design view, saving, reloading the project, restarting visual studio do not work. I have write permissions to the designer file.

I thought it could be the combination of Extensions I have installed - but disabling all extensions does not help either. I am reluctant to actually uninstall my extensions - disabling should stop them loading shouldn't it.

I don't want to try 'convert to web application' as the project already is a web application, and this may affect all pages in the project, not just the one at fault.

I've had to resort to manually editing the designer file - which so far has caused no problems but is a pain. Does anyone know of an Extension that will allow regeneration of a single designer file - or of any KB or fix or other way to resolve this?

Its Visual Studio 2010, targeting .Net Framework 3.5, code behind in C#

我在这里遇到了同样的问题,我删除了设计器文件,然后执行了“转换为Web应用程序” ,重新创建了设计器文件,而没有修改项目中的其他任何内容,只需确保右键单击aspx页面并选择“转换为Web应用程序”菜单选项。

I have just had the same problem and after searching the web for a fix, none of the usual tricks worked for me. In the end I found that the controls I was adding were inside an existing custom control.

eg I was creating my own user password retrieval section (forgotten your password?) but started building it within the existing

<asp.Login>

tags. My controls weren't part of the Login content template and I guess asp.net was ignoring them.

When this happens no errors are displayed and there are no intellisense warnings either. Your controls just aren't available in code behind. If you add them to the designer manually they get lost the next time it regenerates. If you declare them in your .cs file they still end up as an object reference not set error.

Something to watch out for when you've been at it for too long and make a silly mistake. Thought I should add this remedy since it doesn't seemed to be covered elsewhere.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM