In some cases, controls added to a page aren't being added to the designer.cs partial class file.
Pertinent facts:
We use the WebApplication extension
I always use "Source" view (rather than "Design" view) to compose the html
The problem seems to occur in .ascx files, and not in .aspx files ...
but perhaps that might be related to the fact that we typically place .aspx files in the root folder, and .ascx files in a sub-folder ...
so aspx classes would be in the root namespace and ascx classes wouldn't
( rather than due to the type of file )
In the controls (aspx/ascx) that have the problem, the designer.cs header shows:
Runtime Version:2.0.50727.42
In those that work, the header shows:
Runtime Version:2.0.50727.1433
(copying a header from a "good" designer.cs file into a "bad" one, didn't fix the problem, and the entries for each control within the project file [.csproj] are indistinguishable)
Any idea what might be causing this ?
Is there a way to force the re-generation of the designer.cs file ?
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.
Don't forget to click "Mark as Answer" on the post that helped you.
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.
Is your control in the ascx ? If so, it won't show up in the code behind of your aspx. You have to use the FindControl method.
Thanks, but the problem has nothing to do with that.
When you add a control (ex. <asp:xxx runat="server" /> ) to an ascx or aspx file, visual studio is supposed to automatically add the definition for that control to the designer.cs file (associated with that ascx or aspx).
Sometimes that works (for me), and sometimes it doesn't.
Yep, that post (thread) is dealing with the same problem (or at least a similar one). Thanks for finding it ( I'd searched this forum, but didn't know about that one ... too many similar forums )
I've experienced the case where a newly added control doesn't get added to designer.cs, and been able to resolve it simply by cutting / pasting the control.
But the problem I'm having here is that nothing at all is being added to designer.cs.
I've tried:
cut / paste ( that normally works if it's only a single control that didn't get added to designer.cs )
right-click refresh in the design view ( your original suggestion )
deleting the designer.cs file and modifying the ascx / aspx
( mentioned in the post you referred me to ... according to the post, that should have caused VS to re-create the designer.cs, but in my case it did not )
Dear grundt, I presume, based upon the dates of your original and last posts, that this problem may well be long-gone. However, strangely I am getting *exactly* the behaviour that you describe. That is: non-re-generation of the designer. None of the applied
solutions has any effect whatsoever. Things to note in my case are: 1. I have the same runtime version (....1433). 2. I am working with a control (ASCX). 3. The error list shows the warning "Generation of designer file failed: The method or operation is not
implemented." 3. I have another control, in the same folder ("Controls") that does re-create it's designer correctly with each change to the ASCX. It is using the same namespace, in the form: CompanyName.Client.Project.Controls 4. Investigating the possible
differences between these files reveals no significant configuration differences, other than actual asp:xxx controls implemented on each page. Based on a hunch that this issue may be related to namespace issues, I started by changing the namespace - I have
a work-around, but no fix: simply make sure your namespace doesn't include the word "Controls". Repeatable steps to resolve the issue appear to be: 1. Erase the entire contents of the affected designer file and save the empty file. (Feel free to keep the file
opened in the text editor so you can inspect changes when it is (or isn't) re-generated correctly. It makes no difference if you're viewing this file.) 2. In your ASCX file, modify the "Inherits" attribute in the Control directive so that it no longer has
the word "Controls" in it. In this example, try, "ControlsX". You don't need to save the file; just flip views in the text editor to your designer file. It should now be updated. Any advances on this would be appreciated. Kyma
grundt
Member
35 Points
26 Posts
controls not added to designer.cs
Mar 14, 2008 03:07 PM|LINK
In some cases, controls added to a page aren't being added to the designer.cs partial class file.
Pertinent facts:
The problem seems to occur in .ascx files, and not in .aspx files ...
In the controls (aspx/ascx) that have the problem, the designer.cs header shows:but perhaps that might be related to the fact that we typically place .aspx files in the root folder, and .ascx files in a sub-folder ...
so aspx classes would be in the root namespace and ascx classes wouldn't
( rather than due to the type of file )
In those that work, the header shows:
(copying a header from a "good" designer.cs file into a "bad" one, didn't fix the problem, and the entries for each control within the project file [.csproj] are indistinguishable)
Any idea what might be causing this ?
Is there a way to force the re-generation of the designer.cs file ?
amensi
Contributor
2381 Points
421 Posts
Re: controls not added to designer.cs
Mar 14, 2008 04:13 PM|LINK
Hi,
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.
Don't forget to click "Mark as Answer" on the post that helped you.
grundt
Member
35 Points
26 Posts
Re: controls not added to designer.cs
Mar 14, 2008 04:55 PM|LINK
That didn't work either
amensi
Contributor
2381 Points
421 Posts
Re: controls not added to designer.cs
Mar 14, 2008 05:09 PM|LINK
Is your control in the ascx ? If so, it won't show up in the code behind of your aspx. You have to use the FindControl method.
Don't forget to click "Mark as Answer" on the post that helped you.
grundt
Member
35 Points
26 Posts
Re: controls not added to designer.cs
Mar 14, 2008 05:26 PM|LINK
Thanks, but the problem has nothing to do with that.
When you add a control (ex. <asp:xxx runat="server" /> ) to an ascx or aspx file, visual studio is supposed to automatically add the definition for that control to the designer.cs file (associated with that ascx or aspx).
Sometimes that works (for me), and sometimes it doesn't.
amensi
Contributor
2381 Points
421 Posts
Re: controls not added to designer.cs
Mar 14, 2008 05:29 PM|LINK
Check this(second post) : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2051545&SiteID=1
Let me know if it helps
Don't forget to click "Mark as Answer" on the post that helped you.
grundt
Member
35 Points
26 Posts
Re: controls not added to designer.cs
Mar 14, 2008 06:33 PM|LINK
Yep, that post (thread) is dealing with the same problem (or at least a similar one). Thanks for finding it ( I'd searched this forum, but didn't know about that one ... too many similar forums )
I've experienced the case where a newly added control doesn't get added to designer.cs, and been able to resolve it simply by cutting / pasting the control.
But the problem I'm having here is that nothing at all is being added to designer.cs.
I've tried:
( mentioned in the post you referred me to ... according to the post, that should have caused VS to re-create the designer.cs, but in my case it did not )
So far, no solution and no work-around.
GLind
Member
12 Points
6 Posts
Re: controls not added to designer.cs
Apr 16, 2008 04:26 PM|LINK
I got the same problem for a large ascx file. My problem is also that we are working with TFS.
So I can't check in this file until I solves it.
grundt
Member
35 Points
26 Posts
Re: controls not added to designer.cs
Apr 16, 2008 04:50 PM|LINK
TFS ?
Could you please look at the header comment in the designer.cs file and indicate which runtime version it's showing
( Runtime Version:2.0.50727.???? )
( sorry, I'm not aware of any solution or work-around ... but that information might help in the diagnosis )
kyma
Member
4 Points
2 Posts
Re: controls not added to designer.cs
Apr 21, 2008 01:51 AM|LINK