3

So I was creating a SharePoint 2013 visual web part on Visual Studio 2012 and came to this problem. Visual Studio automatically creates WebPartUserControl.ascx.cs and WebPartUserControl.ascx.g.cs. the WebPartUserControl.ascx.g.cs is generated automatically when you edit the WebPartUserControl.ascx file. So I've added a couple of ContentTemplate tags into .ascx file and Visual Studio generated this code in WebPartUserControl.ascx.g.cs :

public partial class WebPartUserControl {
   ...

   public static implicit operator global::System.Web.UI.TemplateControl(WebPartUserControl target)
   {
       return target == null ? null : target.TemplateControl;
   }

   ...
}

When I try to deploy the solution, Visual Studio underlines the implicit operator global::System.Web.UI.TemplateControl and I get this error:

Namespace.WebPart.WebPartUserControl.implicit operator 
System.Web.UI.TemplateControl(Namespace.WebPart.WebPartUserControl)': 
user-defined conversions to or from a base class are not allowed

I don't even imagine how to solve this even though im struggling on this issue for a couple of hours now... Can somebody help me, please? I assume I have to add something to the .ascx file or to WebPartUserControl.ascx.cs maybe? Thanks in advance!

Gintas K
  • 1,438
  • 3
  • 18
  • 38

0 Answers0