Search code examples
c#asp.netvisual-studiodotnetnuke

Visual Studio 2010 Disable Designer Code Generation for particular ascx controls


I am currently developing a website for a Berkeley Club in Visual Studio 2010 Prof. Ed. using Asp.net and Dotnetnuke v6. This will be my second time encountering this specific problem/hassle. I created a new control (ascx file) and have been working on it some. I wanted to add the Dotnetnuke htmleditor since its sick so added the required code. Namely...

<%@ Register TagPrefix="dnn" TagName="TextEditor" Src="~/controls/TextEditor.ascx"%>

<dnn:TextEditor ID="EmailContent" runat="server" Height="400px" Width="100%" />

I also had to change the ascs.designer.cs file so that instead of reading

protected global::System.Web.UI.UserControl EmailContent;

it read like

protected global::DotNetNuke.UI.UserControls.TextEditor EmailContent;

This makes it use the DNN TextEditor which is what I want. The problem is that whenever VS uses the designer to autogenerate code it overwrites the bottom line with the top line. This means every time I change the ascx file I have to change the designer again. This has gotten annoying, but I have not been able to find a way to fix it. Any ideas on how to disable the VS designer for specific controls or for segments of code in a autogenerated designer file?


Solution

  • Put the EmailContent declaration in the ascx.cs file, and remove it from the ascx.designer.cs file. This will prevent the designer from messing up the type.

    This goes to ascx.cs:

    protected global::DotNetNuke.UI.UserControls.TextEditor EmailContent;