I have a legacy web project created in visual studio 2005 that has been recently upgraded to visual studio 2010. It builds against .net 2.0
It contains an ascx user control that contains a fragment that looks like
<select runat="server" id="foo">
<option runat="server" id="bar" value="1">1</option>
</select>
The original designer code looks like this:
protected global::System.Web.UI.WebControls.ListItem bar;
Whenever I edit anything in the .ascx file (even adding a line break), the designer automatically updates to look like this:
protected global::System.Web.UI.HtmlControls.HtmlGenericControl bar;
At that point, the page stops working and provides me the following runtime error:
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The base class includes the field 'bar', but its type (System.Web.UI.HtmlControls.HtmlGenericControl) is not compatible with the type of control (System.Web.UI.WebControls.ListItem).
I then have to hand edit the ascx.designer.cs file to fix the damage that visual studio did.
What can I do to stop visual studio from eating my designer file, short of rewriting all of the legacy option select fragments into asp listcontrol objects?
I had the same problem. I changed some part of my ASP.net project and after that I reached this problem :
The base class includes the field 'Option1',
but its type (System.Web.UI.HtmlControls.HtmlGenericControl) is not compatible
with the type of control (System.Web.UI.WebControls.ListItem).
For fixing this problem, I modified this file <MyFileName>.aspx.designer.cs
and I searched Option1
and I have replaced
protected global::System.Web.UI.HtmlControls.HtmlGenericControl.ListItem Option1;
with
protected global::System.Web.UI.WebControls.ListItem Option1;
Finally, I built my solution and my problem have gone.