I am using SharePoint 2010 Foundation on a vmware virtual machine. I am using Visual Studio 2012 update 3.
I am working on a visual web part project. I have so far in this project only used asp.net controls in the markup. I have had no html tags.
I tried to add an html tag to the .ascx markup file.
When I build and deploy/ran the project the debugger catches an exception in the .ascx.g.cs file in the @_BuildControlTree function. The following line is where the exception occurs.
@__parser.AddParsedSubObject(new System.Web.UI.LiteralControl("\r\n\r\n<div />\r\n\r\n "));
The exception is WebPartPageUserException. I tried to find out more about what is going on. I found this msdn article: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpartzone.addparsedsubobject.aspx. It gives 1 sentance about what the AddParsedSubObject method does. It has a second sentance in the article that describes conditions for a WebPartPageUserException to be thrown. It says the exception will be thrown if the object is not a LiteralControl or its Text Property is not empty. Could that sentance be wrong? Should the or be an and?
The AddParsedSubObject is called for every control. The LiteralControls are generated for every html tag I have. I only have one which is a div tag. At the line where that LiteralControl with a non empty text of div tag is called that exception gets thrown.
Can visual webparts have html tags? Does something special have to be done when they do? I can't think of any other reasons why this exception would be thrown.