在 Visual Studio 2010 中更改网页后 Designer.cs 损坏
当我在 aspx 文件中进行更改时,Visual Studio 行为不正常。它对 Designer.cs 文件进行更改。这些更改意味着我无法通过代码隐藏文件中的 ID 访问任何控件。
当我恢复在 Designer.cs 文件中在我背后所做的更改(使用 SVN)时,我的构建再次成功,一切正常。
我看到 Visual Studio 删除了设计器文件中的很多行。
我在网上读到了一些类似的问题,但我找不到一个好的解决方案。
你们中有人在使用 Visual Studio 时遇到过同样的问题吗?可以帮我解决这个问题吗?
更新:我发现 Visual Studio 将此行添加到 Designer.cs:
protected global::System.Web.UI.WebControls.UpdatePanel UpdatePanel1;
但这应该是:
protected global::System.Web.UI.UpdatePanel UpdatePanel1;
当我在 Designer.cs 文件中手动进行此更改时,它会起作用。但每次我对 aspx 文件进行更改时,Visual Studio 都会再次创建错误的引用。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我有同样的问题。我的解决方法是将定义从设计器文件移动到代码隐藏文件,并将其正确定义为:
Protected WithEvents UpdatePanel1 As Global.System.Web.UI.UpdatePanel
而不是让设计者继续错误地覆盖它,如
Protected WithEvents UpdatePanel1 As Global.System.Web.UI.WebControls.UpdatePanel
我使用 vs2013 vb.net asp web 表单应用程序。
我还看到了将 web.config 文件中的目标框架更改为 4.0 的建议(对我来说不起作用,我的目标是 4.5,两个目标都遇到问题)
,我还看到了使用 Register 标签的建议,例如:
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web"%>
在页面顶部。这确实解决了我测试时抛出的“错误”,但是它导致我的所有 asp 标记出现大量“警告”。
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.
我的办公室在 Visual Studio 2013 中受到此问题的困扰。我们使用以下解决方法:
属性
。应用程序
选项卡上,更改目标框架
版本并保存项目。.aspx
文件。这在 100% 的情况下都有效,但我们发现它弄乱了我们的一些 web.config 设置。
我们现在使用以下解决方法,该解决方法似乎也有效,并且不会对项目配置文件进行任何重大更改:
卸载项目
。重新加载项目
。.aspx
文件。My office is plagued by this issue in Visual Studio 2013. We were using the following workaround:
Properties
.Application
tab, change theTarget framework
version and save the project..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:
Unload Project
.Reload Project
..aspx
file again.确保cs文件的类名与designer.cs相同,并检查aspx文件中页面的Inherits属性是否相同。另请检查您的项目中是否有任何类与您的页面类名同名,我也想知道在 aspx 页面中进行任何更新时出现的错误。
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.