简体   繁体   English

Visual Studio 2010不会在设计器文件中生成新的控件定义

[英]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. 我遇到一个偶然的问题,在向aspx页面添加新控件后,未在设计器文件中创建控件定义,这意味着在代码隐藏中未定义它。 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. 到目前为止,我只在使用嵌套母版页的aspx页上看到它。 At the same time as this error is occurring on the aspx page, designer updates DO work on user controls 在aspx页面上发生此错误的同时,设计者更新也在用户控件上起作用

The usual tricks of switching from source view to design view, saving, reloading the project, restarting visual studio do not work. 从源视图切换到设计视图,保存,重新加载项目,重新启动Visual Studio的通常技巧不起作用。 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. 我不想尝试“转换为Web应用程序”,因为该项目已经是一个Web应用程序,这可能会影响项目中的所有页面,而不仅仅是错误页面。

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? 有谁知道一个允许重新生成单个设计器文件的扩展名-或任何KB或修补程序或其他方式来解决此问题?

Its Visual Studio 2010, targeting .Net Framework 3.5, code behind in C# 其针对.Net Framework 3.5的Visual Studio 2010,在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. 我的控件不是Login内容模板的一部分,我想asp.net会忽略它们。

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. 如果您在.cs文件中声明它们,则它们仍然最终会成为未设置对象引用错误。

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. 我以为我应该添加这种补救措施,因为其他地方似乎没有涵盖。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有“新样式项目”的 Visual Studio 2017+ - ASPX 文件未生成.designer 文件 - Visual Studio 2017+ with "new style project" - ASPX files not generating .designer files Visual Studio 2010错误?设计器文件中的命名空间错误 - Visual Studio 2010 bug? Wrong namespace in designer files Visual Studio 2010禁用特定ascx控件的Designer代码生成 - Visual Studio 2010 Disable Designer Code Generation for particular ascx controls Visual Studio 2010设计器未正确显示AJAX选项卡容器 - Visual Studio 2010 designer not displaying AJAX tab container correctly 将Visual Studio 2008添加到Telerik RadGrid EditFormTemplate中时,Visual Studio 2008不会将控件添加到设计器文件中 - Visual Studio 2008 does not add control to designer file when adding it into a Telerik RadGrid EditFormTemplate Visual Studio 2013设计器未为Telerik控件生成代码 - Visual Studio 2013 designer not generating code for Telerik controls Visual Studio 2010图表控件 - 线条颜色 - Visual Studio 2010 Chart control - line color Ajax控件工具包,Visual Studio 2010,错误 - Ajax Control Toolkit, Visual Studio 2010, error 为Visual Studio 2010和ASP.net和C#生成Excel文件示例 - Generating an Excel File Example for Visual Studio 2010 and ASP.net and C# 在Visual Studio 2008/2010设计器中无法调整带有Designer属性的WebControl的大小 - WebControl decorated with Designer attribute cannot be resized in Visual Studio 2008/2010 designer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM