How do you force Visual Studio to regenerate the .

2019-01-01 06:46发布

Sometimes when I'm editing page or control the .designer files stop being updated with the new controls I'm putting on the page. I'm not sure what's causing this to happen, but I'm wondering if there's any way of forcing Visual Studio to regenerate the .designer file. I'm using Visual Studio 2008

EDIT: Sorry I should have noted I've already tried:

  • Closing & re-opening all the files & Visual Studio
  • Making a change to a runat="server" control on the page
  • Deleting & re-adding the page directive

30条回答
孤独寂梦人
2楼-- · 2019-01-01 07:04
  • Select-all in the designer file and delete everything in the file, leaving it blank and then save
  • Select-all in the ASPX/ASCX file and cut everything and then re-paste it back
  • The designer file should have regenerated the code
查看更多
浅入江南
3楼-- · 2019-01-01 07:04

I had two problems... outdated AJAXControlkit - deleted the old dll, removed old controls from toolbox, downloaded new version, loaded toolbox, and dragged and dropped new controls on the page (see http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Studio_.NET_2005/Q_24591597.html)

Also had misspelling in my label control (had used 'class' instead of 'cssclass').

Ta

查看更多
与君花间醉酒
4楼-- · 2019-01-01 07:06

My experience is that if you want to do like in this article, like stated above.

Your markup file (aspx/ascx) has to include the CodeBehind="MyPage.aspx.cs" attribute or else it won´t work. I blogged about it here.

查看更多
谁念西风独自凉
5楼-- · 2019-01-01 07:06

If you are using VS2013 or later , make sure that the code referenced with attribute "CodeBehind" not "CodeFile", then do below steps

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="yourControl.ascx.cs" Inherits="yourControl.yourControl" %>
  • create empty designer page (or clear it if it's already exists "yourControl.ascx.designer.cs")
  • in the ascx (or aspx) copy all code , the delete it, then save. re-past it again , then save.
  • the designer file should be populated now.
查看更多
还给你的自由
6楼-- · 2019-01-01 07:07

There is another possibility: You may have an error in your .aspx file that does not allow Visual Studio to regenerate the designer.

If you switch to Design View, it will show the control as unable to be rendered. Fixing the control (in my case it was an extra quote in the properties) and recompiling should regenerate the designer.

查看更多
十年一品温如言
7楼-- · 2019-01-01 07:07

in solution explorer just right click and select convert to web application. It will generate all the designer files again.

查看更多
登录 后发表回答