<p>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</p>

<p><strong>EDIT:</strong> Sorry I should have noted I've already tried:</p>

<ul>
<li>Closing &amp; re-opening all the files &amp; Visual Studio</li>
<li>Making a change to a runat="server" control on the page</li>
<li>Deleting &amp; re-adding the page directive</li>
</ul>

[{'answer_id': 45327, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 10, 'selected': True, 'text': '<p>If you open the .aspx file and switch between design view and html view and \nback it will prompt VS to check the controls and add any that are missing to \nthe designer file.</p>\n\n<p>In VS2013-15 there is a <strong>Convert to Web Application</strong> command under the <strong>Project</strong> menu. Prior to VS2013 this option was available in the right-click context menu for as(c/p)x files. When this is done you should see that you now have a *.Designer.cs file available and your controls within the Design HTML will be available for your control.</p>\n\n<p>PS: This should not be done in debug mode, as not everything is "recompiled" when debugging.</p>\n\n<p>Some people have also reported success by (making a backup copy of your .designer.cs file and then) deleting the .designer.cs file.  Re-create an empty file with the same name.</p>\n\n<p>There are many comments to this answer that add tips on how best to re-create the designer.cs file.</p>\n'}, {'answer_id': 45328, 'author': 'EndangeredMassa', 'author_id': 106, 'author_profile': 'https://Stackoverflow.com/users/106', 'pm_score': 2, 'selected': False, 'text': "<p>(The following comes from experience with VS2005.)</p>\n\n<p>If you edit an ASPX page while debugging, then the codebehind doesn't get updated with the new classes. So, you have to stop debugging, trivially edit the ASPX page (like add a button or something), then click Design View, then delete the button. Then, your designer files should be updated.</p>\n\n<p>If you are having a different issue with VS2008, then I can't help.</p>\n"}, {'answer_id': 45334, 'author': 'Glenn Slaven', 'author_id': 2975, 'author_profile': 'https://Stackoverflow.com/users/2975', 'pm_score': 7, 'selected': False, 'text': "<p>Well I found a solution that works, though I don't really like it.  I had to delete the .designer.cs file then recreate an empty file with the same name. When I went back in and saved the aspx file again, the designer file was re-generated.</p>\n\n<p>Dodgy!</p>\n"}, {'answer_id': 52010, 'author': 'DevelopingChris', 'author_id': 1220, 'author_profile': 'https://Stackoverflow.com/users/1220', 'pm_score': 4, 'selected': False, 'text': "<p>the only way I know is to delete the designer file, and do a convert to web app. However when you do this, it usually pops up with the error, as to why it didn't auto-regen in the first place, its usually a control ref that isn't declared in the head of the page.</p>\n"}, {'answer_id': 176401, 'author': 'y0mbo', 'author_id': 417, 'author_profile': 'https://Stackoverflow.com/users/417', 'pm_score': 5, 'selected': False, 'text': '<p>There is another possibility: You may have an error in your .aspx file that does not allow Visual Studio to regenerate the designer.</p>\n\n<p>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.</p>\n'}, {'answer_id': 176407, 'author': 'Mark Cidade', 'author_id': 1659, 'author_profile': 'https://Stackoverflow.com/users/1659', 'pm_score': 2, 'selected': False, 'text': '<ul>\n<li>Select-all in the designer file and delete everything in the file, leaving it blank and then save</li>\n<li>Select-all in the ASPX/ASCX file and cut everything and then re-paste it back</li>\n<li>The designer file should have regenerated the code</li>\n</ul>\n'}, {'answer_id': 492317, 'author': 'Ruvan Fernando', 'author_id': 5080, 'author_profile': 'https://Stackoverflow.com/users/5080', 'pm_score': 6, 'selected': False, 'text': '<p>I use the following method which works everytime:</p>\n\n<ul>\n<li>Select all of the <i>code-in-front</i> (html markup etc) in the editor of the aspx/ascx file.</li>\n<li>Cut.</li>\n<li>Save.</li>\n<li>Paste.</li>\n<li>Save.</li>\n</ul>\n\n<p>Recompile.</p>\n'}, {'answer_id': 533833, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>Delete the designer.cs file and then right click on the .aspx file and choose "Convert To Web Application".  If there is a problem with your control declarations, such as a tag not being well-formed, you will get an error message and you will need to correct the malformed tag before visual studio can successfully re-generate your designer file.</p>\n\n<p>In my case, at this point, I discovered that the problem was that I had declared a button control that that was not inside of a form tag with a runat="server" attribute.</p>\n'}, {'answer_id': 687382, 'author': 'Johan Leino', 'author_id': 83283, 'author_profile': 'https://Stackoverflow.com/users/83283', 'pm_score': 3, 'selected': False, 'text': '<p>My experience is that if you want to do like in <a href="http://blog.bdapps.com/2008/07/15/RestoreDesignercsFilesInVisualStudio.aspx" rel="noreferrer">this</a> article, like stated above.</p>\n\n<p>Your markup file (aspx/ascx) has to include the CodeBehind="MyPage.aspx.cs" attribute or else it won´t work. I blogged about it <a href="http://johanleino.spaces.live.com/blog/cns!6BE273C70C45B5D1!279.entry?&amp;_c02_vws=1" rel="noreferrer">here</a>.</p>\n'}, {'answer_id': 846580, 'author': 'Overflew', 'author_id': 40486, 'author_profile': 'https://Stackoverflow.com/users/40486', 'pm_score': 3, 'selected': False, 'text': "<p>I often found that <strong>copy/pasting caused this behaviour</strong> for me. Most cases can be solved by editing the ID of a server control (just add a character, then delete it).</p>\n\n<p>Also remember that control inside things like Repeaters aren't visible in the designer file.</p>\n\n<p>And yes, there are cases where you need to do the delete-the-file magic listed above - but the name-change solution will work most of the time.</p>\n"}, {'answer_id': 2074217, 'author': 'sameer', 'author_id': 245306, 'author_profile': 'https://Stackoverflow.com/users/245306', 'pm_score': 2, 'selected': False, 'text': '<p>Here is wat i experienced ,\nSelect the website folder right click in the Solution Explorer, select Convert to Web application for all the aspx file a designer file will get generated.</p>\n\n<p>Sameer</p>\n'}, {'answer_id': 2160455, 'author': 'osexp2000', 'author_id': 261622, 'author_profile': 'https://Stackoverflow.com/users/261622', 'pm_score': 0, 'selected': False, 'text': '<ol>\n<li>replace your custom tag with a invalid tag name. Save it</li>\n<li>restore the invalid tag name back to custom tag name. Save it. Then you will be prompted to checkout the *.designer.cs files(or silently modify the designer.cs) and produce correct variable of custom tag control.</li>\n</ol>\n'}, {'answer_id': 2307810, 'author': 'Ritter', 'author_id': 278336, 'author_profile': 'https://Stackoverflow.com/users/278336', 'pm_score': 0, 'selected': False, 'text': '<p>I had this problem and for me, I had a space in one of my ID values for one of my controls. I took the space out and the designer file regenerated itself.</p>\n'}, {'answer_id': 2742674, 'author': 'bcweis', 'author_id': 329516, 'author_profile': 'https://Stackoverflow.com/users/329516', 'pm_score': 1, 'selected': False, 'text': "<p>This is a bug in the IDE; I've seen it since VS 2003. THe solution is simple though.</p>\n\n<p>Save your files. Completely exit the IDE (make sure the process stops, task mgr.)</p>\n\n<p>Reopen the solution, dirty the markup, save. Fixed.</p>\n"}, {'answer_id': 3064138, 'author': 'amac44', 'author_id': 369630, 'author_profile': 'https://Stackoverflow.com/users/369630', 'pm_score': 0, 'selected': False, 'text': '<p>In my case I was just missing a register TagPrefix at the top.  Somehow the previous dev worked without having this in there?</p>\n'}, {'answer_id': 3187480, 'author': 'VoltaicShock', 'author_id': 115578, 'author_profile': 'https://Stackoverflow.com/users/115578', 'pm_score': 0, 'selected': False, 'text': '<p>I have had this issue before.  I usually just hit enter to add a line and then wait for the plus/minus to show on the html page and the designer should add what you need.  I have also had to close the project and reopen it to get it to work.</p>\n'}, {'answer_id': 3200749, 'author': 'user381377', 'author_id': 381377, 'author_profile': 'https://Stackoverflow.com/users/381377', 'pm_score': 1, 'selected': False, 'text': '<p>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 <a href="http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Studio_.NET_2005/Q_24591597.html" rel="nofollow noreferrer">http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Studio_.NET_2005/Q_24591597.html</a>)</p>\n\n<p>Also had misspelling in my label control (had used \'class\' instead of \'cssclass\').</p>\n\n<p>Ta</p>\n'}, {'answer_id': 3678602, 'author': 'Derek Kalweit', 'author_id': 443635, 'author_profile': 'https://Stackoverflow.com/users/443635', 'pm_score': 0, 'selected': False, 'text': '<p>I\'ve had this problem a lot, and just did again. I tried fixing it using these suggestions, and nothing worked. I finally found that I had the \'Title\' attribute in the page header twice(I added to the end, not realizing that VS added a blank Title="" to the beginning)-- removing the extra attribute caused VS2008 to re-generate the designer file... I hope VS2010 fixes this problem, letting us know why the designer file generation isn\'t happening...</p>\n\n<p>-- \nDerek</p>\n'}, {'answer_id': 3706475, 'author': 'yertle', 'author_id': 447034, 'author_profile': 'https://Stackoverflow.com/users/447034', 'pm_score': 2, 'selected': False, 'text': '<p>When you are in design view, right click on the screen and hit refresh. </p>\n'}, {'answer_id': 4264088, 'author': 'WynandB', 'author_id': 192886, 'author_profile': 'https://Stackoverflow.com/users/192886', 'pm_score': 0, 'selected': False, 'text': "<p>Apart from all the good answers already given, I'd like to add to @johan-leino's great answer. In my case, for some arbitrary reason, the <code>CodeBehind</code> attribute was omitted from the <code>@Page</code> directive/.aspx file. Likewise, it might be worthwhile to check the <code>CodeFile</code> attribute for <code>@Control</code> directives/.ascx files (obviously in conjunction with an <code>Inherits</code> attribute in both cases).</p>\n\n<p>Depending on the exact scenario and reason required to 'force' a regenerate of .designer.cs, one could also try to format the document (potentially indicating a parsing error) before (quick) saving (regardless whether there were any changes or not) and check the Error List for warnings.</p>\n"}, {'answer_id': 4770314, 'author': 'Geoff', 'author_id': 569317, 'author_profile': 'https://Stackoverflow.com/users/569317', 'pm_score': 6, 'selected': False, 'text': '<p>I recently saw that I was having the same problem.  Visual Studio 2010 was refusing to update the designer file.</p>\n\n<p>As it turns out, VS doesn\'t modify the designer file for a page that uses CodeFile (run off of pages) instead of CodeBehind (DLL).  This is true no matter how many times you close VS, reload the project, re-create the control(s), or modify a file.  Nothing would prompt VS to regenerate the designer.  It\'s as if it doesn\'t create the designer file for CodeFile pages but does require it to be there.</p>\n\n<p>I changed it to CodeBehind and saved the page.  The designer file updated immediately.  Then I just changed it back and everything was still golden.  This behavior seems to be new with VS 2010 / .NET 4.0 as VS 2008 by default didn\'t suffer from this.</p>\n\n<p>It\'s this part:</p>\n\n<pre><code>&lt;%@ Page Language="vb" AutoEventWireup="false" CodeFile="YourPage.aspx.vb" Inherits="YourPageClass" %&gt;\n</code></pre>\n\n<p>Change CodeFile to CodeBehind, save, and then revert.</p>\n'}, {'answer_id': 5834527, 'author': 'Boris Lutskovsky', 'author_id': 118122, 'author_profile': 'https://Stackoverflow.com/users/118122', 'pm_score': 0, 'selected': False, 'text': '<p>In my case, it was fixed when I added a CodeBehind to the @Page section. </p>\n'}, {'answer_id': 6205742, 'author': 'Code Maverick', 'author_id': 682480, 'author_profile': 'https://Stackoverflow.com/users/682480', 'pm_score': 0, 'selected': False, 'text': '<p>I know I\'m late to the party, but I thought if after trying the accepted answer by @Glenn Slaven and the current highest rated answer by @Espo you are still out of luck, the following might save some people out there some trouble.</p>\n\n<p>User Controls (.ascx) are what constantly stop auto-generating for me. I\'ve found that in the instances where I use other User Control(s) in my User Control, it breaks the auto-generation.  </p>\n\n<p>The solution I came up with was to use the trick we all know of for getting IntelliSense to work in User Controls or Skin files when using CSS classes from external sources.  Instead of just referencing the CSS file, now I Register the other User Control(s) that I need.  It looks something like this:</p>\n\n<pre><code>&lt;% If False Then %&gt;\n&lt;%@ Register TagPrefix="uc" TagName="Title" Src="~/controls/title.ascx" %&gt;\n&lt;link rel="stylesheet" type="text/css" href="../css/common.css"  /&gt;\n&lt;% End If %&gt;\n</code></pre>\n\n<p>After that, I Save the file, which prompts the auto-generation to regenerate, and I\'m back up and running.</p>\n'}, {'answer_id': 6209870, 'author': 'Carlo', 'author_id': 780443, 'author_profile': 'https://Stackoverflow.com/users/780443', 'pm_score': 1, 'selected': False, 'text': '<p>If you are like me and you add old .ASPX files to a more recent project.\nYou are probably going to forget some of the controls used on the page.</p>\n\n<p>If so, first thing, if there are multiple files you are installing;\nFix one at a time first.</p>\n\n<p>When you compile, fix errors generated. They will probably be the same\nerrors in all the files.</p>\n\n<p>Next, if you have Designer files, delete all of the inserted - designer files.\nNext, make sure there are not any other errors when you compile, other than\nthe designer files.</p>\n\n<p>Finally right click your web project and click on Convert to Web Application.\nThis will insert the designer files you need.</p>\n\n<p>These are the absolute best steps to fix the issues.</p>\n'}, {'answer_id': 6745978, 'author': 'The Demz', 'author_id': 844700, 'author_profile': 'https://Stackoverflow.com/users/844700', 'pm_score': 1, 'selected': False, 'text': '<p>I had the problem that my new controls would not generate in the designer file when declared in the .ascx file. The problem was that i declared them in the code behind also. So deleting the declaration in the code behind solved my problem.</p>\n'}, {'answer_id': 10644696, 'author': 'Tacroy', 'author_id': 1026164, 'author_profile': 'https://Stackoverflow.com/users/1026164', 'pm_score': 1, 'selected': False, 'text': "<p>One thing that nobody's mentioned is to <strong>visit the page</strong>. I had my designer file stop regenerating because I was including a user control that didn't exist (for various reasons), and none of the things suggested here worked. For whatever reason, I didn't get any errors in Visual Studio - besides the one complaining about the fact that my client-side controls didn't exist because they weren't being regenerated, of course. </p>\n\n<p>It took actually visiting the page to get ASP.Net to tell me the error.</p>\n"}, {'answer_id': 10683403, 'author': 'you y', 'author_id': 1248684, 'author_profile': 'https://Stackoverflow.com/users/1248684', 'pm_score': 2, 'selected': False, 'text': '<p>The solution the worked for me is:</p>\n\n<p>I just copied the page and and pasted it in the same portion, then renamed the first page(what ever name) and renamed the copied page as the original page.  Now the controls are accessible.</p>\n'}, {'answer_id': 11246048, 'author': 'Rory Solley', 'author_id': 436302, 'author_profile': 'https://Stackoverflow.com/users/436302', 'pm_score': 2, 'selected': False, 'text': "<p>Just to add to the long list of answers here - I've just run into this issue in VS2010 (SP1) with an .aspx file. I tried adding and removing standard ASP controls (which has worked in the past) but in the end, I had to remove one of the <strong>runat=server lines</strong> from an existing control (and save) to force the designer file to regenerate.</p>\n"}, {'answer_id': 11467149, 'author': 'Ben Weeks', 'author_id': 1523068, 'author_profile': 'https://Stackoverflow.com/users/1523068', 'pm_score': 1, 'selected': False, 'text': "<p>This can also happen if you update the namespace and don't update the namespace in the designer file. Fix: Update the namespace in the designer file too.</p>\n"}, {'answer_id': 14433337, 'author': 'Sean Werkema', 'author_id': 412416, 'author_profile': 'https://Stackoverflow.com/users/412416', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve encountered the same problem for years now, working in Visual Studio 2008.  And I\'ve tried every "solution" on StackOverflow and dozens of blogs, just like I\'m sure all of you have.  And sometimes they work, and sometimes they don\'t, just like I\'m sure all of you have encountered.  And apparently it\'s still an issue in VS2010 and VS2012.</p>\n\n<p>So finally, a couple of months ago, I decided enough was enough, and over a few weeks <strong>I built a tool called "Redesigner" that generates .designer files.  It\'s open-source under the BSD license</strong>, with the source code available on SourceForge — free to use, free to steal, free to do anything you please with.  And it does what Visual Studio fails to do so often, which is generate .designer files quickly and reliably.</p>\n\n<p>It\'s a stand-alone command-line tool that parses .aspx and .ascx files, performs all the necessary reflection magic, and spits out correct .designer files.  It does all the parsing and reflection itself to avoid relying on existing code, which we all know too well is broken.  It\'s written in C# against .NET 3.5, but it makes pains to avoid using even System.Web for anything other than type declarations, and <strong>it doesn\'t use or rely on Visual Studio at all</strong>.</p>\n\n<p>Redesigner can generate new .designer files; and it offers a --verbose option so that when things go wrong, you get far better error messages than "Exception of type System.Exception was thrown."  And there\'s a --verify option that can be used to tell you when your existing .designer files are broken — missing controls, bad property declarations, unreadable by Visual Studio, or otherwise just plain borked.</p>\n\n<p>We\'ve been using it at my workplace to get us out of jams for the better part of the last month now, and while Redesigner is still a beta, it\'s getting far enough along that it\'s worth sharing its existence with the public.  I soon intend to create a Visual Studio plugin for it so you can simply right-click to verify or regenerate designer files the way you always wished you could.  But in the interim, the command-line usage is pretty easy and will save you a lot of headaches.</p>\n\n<p>Anyway, <strong>go download a copy of Redesigner now and stop pulling out your hair</strong>.  You won\'t always need it, but when you do, you\'ll be glad you have it!</p>\n\n<p><strong><a href="https://sourceforge.net/projects/redesigner/" rel="nofollow">https://sourceforge.net/projects/redesigner/</a></strong></p>\n'}, {'answer_id': 14643083, 'author': 'tommycode', 'author_id': 274216, 'author_profile': 'https://Stackoverflow.com/users/274216', 'pm_score': 3, 'selected': False, 'text': '<p>I\'ve found a way to solve this problem without changing any code or running commands like "Convert to Web Application" - and it\'s simple too!</p>\n\n<p>What I found was that restarting Visual Studio often solves the problem, but sometimes it doesn\'t. In those cases, if you close Visual Studio and then <strong>delete all content in the "obj" directory for the web project</strong> before you open it again, it has always worked for me.</p>\n\n<p>(when started again you just add a space and remove it again and then hit save to have the designer file properly regenerated)</p>\n'}, {'answer_id': 17270697, 'author': 'Aries51', 'author_id': 861581, 'author_profile': 'https://Stackoverflow.com/users/861581', 'pm_score': 0, 'selected': False, 'text': "<p>I know this is an old topic but I just wanted to add a solution that wasn't suggested yet.</p>\n\n<p>I had the same problem with a resource file. I edited it outside Visual Studio and the designer file hadn't updated properly.</p>\n\n<p>Renaming the file did the trick of regenerating the Designer file. I just renamed it to the initial name again and that worked just fine!</p>\n"}, {'answer_id': 18235559, 'author': 'Joanne', 'author_id': 2683021, 'author_profile': 'https://Stackoverflow.com/users/2683021', 'pm_score': 0, 'selected': False, 'text': "<p>I'm in VS 2003 and none of these worked for me. What worked was to open the code at the top of the .vb page in the section labeled Web Form Designer Generated Code (the part that says not to edit there) and declare it there, where the system declared all the other controls. Bizzare.</p>\n"}, {'answer_id': 19921423, 'author': 'Vandesh', 'author_id': 1891625, 'author_profile': 'https://Stackoverflow.com/users/1891625', 'pm_score': 2, 'selected': False, 'text': '<p>Another thing which worked was -  </p>\n\n<ol>\n<li>Manually delete &amp; then Create a designer file in filesystem.   </li>\n<li><strong>Edit Project</strong> file.</li>\n<li>Add code to include designer<br>\nEg: <code>&lt;Compile Include="&lt;Path&gt;\\FileName.ascx.designer.cs"&gt;\n      &lt;DependentUpon&gt;FileName.ascx&lt;/DependentUpon&gt;\n    &lt;/Compile&gt;</code></li>\n<li>Reload Project</li>\n<li>Open as(c/p)x file in design/view mode &amp; save it.</li>\n<li>Check designer file. Code will be there.</li>\n</ol>\n'}, {'answer_id': 21445020, 'author': 'ATL_DEV', 'author_id': 148298, 'author_profile': 'https://Stackoverflow.com/users/148298', 'pm_score': 5, 'selected': False, 'text': '<p>Most of the solutions here don\'t work if you\'re running Visual Studio 2013 and possibly 2012. Microsoft probably introduced some optimizations to make the IDE snappier, consequently they\'ve reduced the number of cases that trigger the code generator. The following scenarios that used to work no longer do:</p>\n\n<ol>\n<li>Delete the aspx or ascx file -- No longer checks for this case</li>\n<li>Cut all the content and repaste into the aspx or ascx file -- No longer works, no change in the references</li>\n<li>Convert to Web Application -- Option no longer available</li>\n<li>Arbitrarily changing content on the aspx/ascx file -- No longer works (see 2).</li>\n</ol>\n\n<p>The solution is surprisingly simple, but it\'s slightly cumbersome. In order to trigger the code generator, change something that would require the designer.aspx.cs to be generated. Changing content that doesn\'t affect code, such as a CSS style or adding text, won\'t trigger the code generator. You must change a referenced control. Here\'s how to do it:</p>\n\n<p>In the ascx or aspx change the ID of the control</p>\n\n<pre><code>&lt;asp:HyperLink ID="MyLink" runat="server" NavigateUrl="~/Default.aspx" Text="Home" /&gt;\n</code></pre>\n\n<p>to </p>\n\n<pre><code>&lt;asp:HyperLink ID="theLINK" runat="server" NavigateUrl="~/Default.aspx" CssClass="tab" Text="Home" /&gt;\n</code></pre>\n\n<p>Go to the ascx.cs or aspx.cs and make sure you rename all references to "MyLink" to "theLINK" as well. Save and do build and the you should be good to go.</p>\n'}, {'answer_id': 21775355, 'author': 'O D', 'author_id': 3244163, 'author_profile': 'https://Stackoverflow.com/users/3244163', 'pm_score': 3, 'selected': False, 'text': '<p>Convert to Web Application did not work for me.</p>\n\n<p>Deleting designer.cs and pasting a blank designer.cs did not work either.</p>\n\n<p>But yes this worked:</p>\n\n<ol>\n<li>Select all(Default.aspx)</li>\n<li>Cut</li>\n<li>Save Default.aspx</li>\n<li>Paste</li>\n<li>Save Default.aspx</li>\n</ol>\n\n<p>Done. New designer.cs generated. :)</p>\n'}, {'answer_id': 27568568, 'author': 'SNag', 'author_id': 979621, 'author_profile': 'https://Stackoverflow.com/users/979621', 'pm_score': 2, 'selected': False, 'text': '<p><strong>TL;DR;</strong><br>\nEdit the <code>Inherits</code> attribute of the ASPX page\'s <code>@Page</code> directive and hit Save. Your designer file should be regenerated.</p>\n\n<p>Ensure that <code>Inherits</code> = &lt;namespace&gt;.&lt;class_name&gt; and <code>CodeBehind</code> = &lt;class_name&gt;.aspx.cs</p>\n\n<hr>\n\n<p>I was trying to do this on a <strong>Sharepoint 2010 project, using VS 2010 and TFS</strong>, and none of the solutions above worked for me. <em>Primarily, the option, <strong>"Convert to Web Application"</strong> is missing from the right-click menu of the .ASPX file when using TFS in VS 2010.</em></p>\n\n<p><a href="https://stackoverflow.com/a/706617/979621">This answer helped finally</a>. My class looked like this:</p>\n\n<pre><code>namespace MyProjects.Finance.Pages\n{\n    public partial class FinanceSubmission : WebPartPage\n    {\n        protected void Page_Load(object sender, EventArgs e)\n        {\n        }\n\n        // more code\n    }\n}\n</code></pre>\n\n<p>And my <code>@Page</code> directive was (line-breaks here for clarity):</p>\n\n<pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" \n    CodeBehind="FinanceSubmission.aspx.cs"\n    Inherits="MyProjects.Finance.Pages.FinanceSubmission"\n    MasterPageFile="~masterurl/default.master" %&gt;\n</code></pre>\n\n<p>I first changed the <code>Inherits</code> to <strong>MyProjects.Finance.Pages</strong>, hit Save, then changed it back to <strong>MyProjects.Finance.Pages.FinanceSubmission</strong> and hit Save again. And wallah! The designer page was regenerated!</p>\n\n<p>Hope this helps someone using TFS!</p>\n'}, {'answer_id': 28462259, 'author': 'Tarek El-Mallah', 'author_id': 471499, 'author_profile': 'https://Stackoverflow.com/users/471499', 'pm_score': 2, 'selected': False, 'text': '<p>If you are using VS2013 or later , make sure that the code referenced with attribute "CodeBehind" not "CodeFile", then do below steps</p>\n\n<pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="yourControl.ascx.cs" Inherits="yourControl.yourControl" %&gt;\n</code></pre>\n\n<ul>\n<li>create empty designer page (or clear it if it\'s already exists "yourControl.ascx.designer.cs")</li>\n<li>in the ascx (or aspx) copy all code , the delete it, then save. re-past it again , then save.</li>\n<li>the designer file should be populated now.</li>\n</ul>\n'}, {'answer_id': 29692102, 'author': 'nouman arshad', 'author_id': 4542348, 'author_profile': 'https://Stackoverflow.com/users/4542348', 'pm_score': 2, 'selected': False, 'text': '<p>Within the Visual Studio:</p>\n\n<p>1) Remove your aspx.designer.cs file</p>\n\n<p>2) Right click on your aspx file and select "Convert to Web Application"\nThis should add the aspx.designer.cs back and up to date.</p>\n\n<p>If you get an error saying:</p>\n\n<p>"Generation of designer file failed: The method or operation is not implemented."</p>\n\n<p>Try close Visual Studio and then reopen your project and do step number two again</p>\n\n<p><a href="https://stackoverflow.com/questions/20858121/how-to-generate-aspx-designer-cs-in-visual-studio">How to generate aspx.designer.cs in visual studio?</a></p>\n'}, {'answer_id': 36071389, 'author': 'user3911976', 'author_id': 3911976, 'author_profile': 'https://Stackoverflow.com/users/3911976', 'pm_score': 2, 'selected': False, 'text': '<p>in solution explorer just right click and select convert to web application. It will generate all the designer files again.</p>\n'}, {'answer_id': 41700737, 'author': 'Sean Tovson', 'author_id': 7431166, 'author_profile': 'https://Stackoverflow.com/users/7431166', 'pm_score': 0, 'selected': False, 'text': '<p>For VS2015... here\'s a VB example for switching from a WebSite project to a Web Application Project that worked for me.  None of the other solutions worked for me, which is why I\'m sharing this.  It\'s not elegant, but works.</p>\n\n<p>Step 0: Replace all " CodeFile=" with " CodeBehind=" in your project\nStep 1: Close the Solution.\nStep 2: Run a home-grown Windows app with the following code (below steps).\nStep 3: Re-open the solution.\nStep 4: In Solution Explorer, make sure you are Showing All Files, and search for designer.vb (or designer.cs for C#)\nStep 5: Select all the missing files, and include them in your project.\nStep 6: For each file, view the main page / control and save it.</p>\n\n<pre><code>    private void button1_Click(object sender, EventArgs e)\n    {\n        ProcessDirectory(new DirectoryInfo(textBox1.Text));\n    }\n\n    private void ProcessDirectory(DirectoryInfo directory)\n    {\n        ProcessMask(directory, ".ascx", ".vb");\n        ProcessMask(directory, ".aspx", ".vb");\n\n        foreach (DirectoryInfo directoryInfo in directory.GetDirectories())\n            ProcessDirectory(directoryInfo);\n    }\n\n    private void ProcessMask(DirectoryInfo directory, string maskStart, string maskEnd)\n    {\n        FileStream fs;\n        foreach (FileInfo file in directory.GetFiles(string.Format("*{0}{1}", maskStart, maskEnd)))\n        {\n            string designerFileName = file.Name.Replace(string.Format("{0}{1}", maskStart, maskEnd), string.Format("{0}.designer{1}", maskStart, maskEnd));\n            if (directory.GetFiles(designerFileName).Length == 0)\n            {\n                using (fs = File.Create(Path.Combine(directory.FullName, designerFileName)))\n                {\n                    fs.Close();\n                }\n            }\n        }\n    }\n</code></pre>\n'}, {'answer_id': 43373646, 'author': 'WonderWorker', 'author_id': 1271898, 'author_profile': 'https://Stackoverflow.com/users/1271898', 'pm_score': 0, 'selected': False, 'text': '<p>I thought I had this problem and was tearing my hair out, but then I realised that I was trying to reference a control from a static method. </p>\n\n<p>Making the method non-static resolved the issue for me.</p>\n'}, {'answer_id': 46830358, 'author': 'Glaucyo Ricas', 'author_id': 8227605, 'author_profile': 'https://Stackoverflow.com/users/8227605', 'pm_score': 0, 'selected': False, 'text': '<ol>\n<li><p>Close designer.cs.</p></li>\n<li><p>Change your aspx file to design view.</p></li>\n<li><p>Right-Click –> Refresh.</p></li>\n<li><p>Save</p></li>\n</ol>\n'}, {'answer_id': 51278640, 'author': 'Niaz Morshed', 'author_id': 1429854, 'author_profile': 'https://Stackoverflow.com/users/1429854', 'pm_score': 0, 'selected': False, 'text': '<p>One of my solution, which works for me.</p>\n\n<ol>\n<li>Close the Visual Studio</li>\n<li>Remove hidden .vs directory</li>\n<li>Remove existing .sln file</li>\n<li>load the project in visual studio using .csproj file</li>\n</ol>\n'}, {'answer_id': 57054057, 'author': 'Sampat', 'author_id': 2077750, 'author_profile': 'https://Stackoverflow.com/users/2077750', 'pm_score': 2, 'selected': False, 'text': '<ol>\n<li><p><strong>Step 1</strong>: Select all your aspx code, Cut [ CTRL+X ] that code and Save.</p></li>\n<li><p><strong>Step 2</strong>: Again paste the same code in the same page and save again</p></li>\n</ol>\n\n<p>Now your .desinger page will refresh with all controls in .aspx page. </p>\n'}, {'answer_id': 63206491, 'author': 'Rupesh Kumar Tiwari', 'author_id': 1949796, 'author_profile': 'https://Stackoverflow.com/users/1949796', 'pm_score': 0, 'selected': False, 'text': '<p>In Visual Studio 2019 below are the steps:</p>\n<ol>\n<li>Create <code>webform1.aspx</code></li>\n<li>Copy your aspx code and paste in <code>webform1.aspx</code></li>\n<li>Compile your project you should have designer code inside <code>webform1.aspx.designer.cs</code></li>\n<li>Now you can copy designer code and use in your original webform.</li>\n</ol>\n'}, {'answer_id': 66422008, 'author': 'Tiptop', 'author_id': 12346630, 'author_profile': 'https://Stackoverflow.com/users/12346630', 'pm_score': 0, 'selected': False, 'text': '<p>If you see this while using Visual Basic 2019 and you clicked on the &quot;permanently delete this file&quot; confirmation, you can recover the designer.cs files from your recycle bin...it will regenerate in Visual Basic automatically. I just did it and found my file just as it was.</p>\n'}, {'answer_id': 66941706, 'author': 'Bimal Das', 'author_id': 4586387, 'author_profile': 'https://Stackoverflow.com/users/4586387', 'pm_score': 1, 'selected': False, 'text': '<p>The solution was for me to change from <em><strong><code>None</code></strong></em> to <em><strong><code>Compile</code></strong></em> in <code>.csproj</code> file</p>\n<pre><code>&lt;Compile Include=&quot;Logout.aspx.designer.cs&quot;&gt;\n      &lt;DependentUpon&gt;Logout.aspx&lt;/DependentUpon&gt;\n&lt;/Compile&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/45325', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2975/']