1

I've been banging my head on this one. I've never used the auto-generated designer files in Visual Studio before (it's the OCD...), but I'm trying to use them now and I don't know if this is a known problem or if I'm just SOL.

In my SharePoint project in Visual Studio 2010, the auto-generated code-behind *.aspx.designer.cs files are not generating any code for Application Pages in the project. It works as expected for user controls in the SharePoint project, and for standard .aspx pages in a non-SharePoint project on the same box. However, if you add a new page to a SharePoint project, like: Add > New Item... > Application Page (under Installed Templates > Visual C# > SharePoint > 2010 on the left), the designer files don't work.

I've tried a number of methods I've found online, chiefly:

  • Change the .aspx file and save
  • Cut the entire .aspx file, save, paste it all back, save
  • Deleted and recreated the designer file
  • Deleted and recreated the entire page

None of these have worked for me.

Additionally:

  • This is not permissions related (account is an administrator and UAC is disabled on this box, VS is running as admin)
  • There are no extensions installed in this case, so that's out
  • Design view is not an option for the Application Page template, so you can't toggle it
  • In SharePoint projects there is no option for "Convert to Web Application"

From:

How do you force Visual Studio to regenerate the .designer files for aspx/ascx files?

Visual studio 2010 not generating new control definitions in designer file

Visual Studio 2010 Designer File Not Updating

This seems to me to be related to the Application Page template, as the Designer works fine for user controls in the same project, and the Application Page template doesn't allow Design View. Does anyone know how to resolve this?

6
  • Some thoughts: Have you looked in the Project folder for the designer file? Recreated with a different name? What does switching to designer view do in VS (Rightclick -> View Designer)?
    – Mike
    Jun 10, 2013 at 16:47
  • View Designer isn't a right-click option on application pages. From the top menus, View > Designer does nothing except reload the markup. I did open the project file in Notepad and all the designer files are registered the exact same way that they are for the user controls which work. Jun 10, 2013 at 16:49
  • It isn't just one page either. Unfortunately it's all pages with the Application Page template. Jun 10, 2013 at 16:51
  • (Excuse my ignorance) What about adding the designer file to the project? What does that do?
    – Mike
    Jun 10, 2013 at 17:17
  • ??? When you add a new "Application Page" it generates an .aspx, aspx.cs, and .aspx.designer.cs. The designer file is registered in the project file, but fails to function as expected. One suggestion that I read online was to delete the file on the file system and recreate a blank (.txt) file with the same name (just change the extension) and add only the namespace and partial class declarations. Then rebuild. Or change the .aspx and save. Either of those should force VS to regenerate the designer file. Didn't work. Jun 10, 2013 at 17:25

1 Answer 1

2

Creating Application Pages for SharePoint

I found this (Excerpt):

Note

You can only design the page in the Source view of the designer. The Design view of the designer is disabled for application pages.

Also found a workaround:

Design View on SharePoint Project Visual Studio 2010

here is a trick for this little problem:

add a user control to your project. copy all the markup code over to this user control. design away, then copy the markup back into your application page to start refining your code to work as a sharepoint item.

3
  • Meh, I'll just keep defining the controls in the code-behind by hand like I've been doing. I understand the reason for the Design View being restricted (master page tokenization/rendering I assume), but the auto-generation of the control names failing seems like unfortunate collateral damage. Thanks for settling that! Jun 10, 2013 at 17:47
  • yes, designer files being generated are misleading with this template. You're welcome!
    – Mike
    Jun 10, 2013 at 17:48
  • I don't really care about the Design View, but I was starting to get used to the .aspx.designer.cs doing its job lol. Jun 10, 2013 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.