5

During my development, I have a web user control project and another web project which will use the user controls from the web user control project.

So I copy the DocControl.ascx file to my web project and try to use the properties of the DocControl.ascx. But VS does not know the properties of the control. So when I check the designer.cs, the reference is like that

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

Which should be

protected global::MSN.DocControl Control;

So I changed the name of the control from System.Web.UI.UserControl to MSN.DocControl and I can use the properties of the DocControl.ascx.

But my issue is whenever I modify ( eg. put a lable in aspx) the aspx file, the reference in designer.cs become

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

So I has to change it whenever I modify my aspx.

What should I do so I don't need to change the designer.cs

Thanks in advance......

Kyle Trauberman
  • 25,414
  • 13
  • 85
  • 121
kevin
  • 13,559
  • 30
  • 79
  • 104
  • Did you propagate the changes in the designer.cs file..? also make sure that the other files are not referencing the old protected value – MethodMan Dec 30 '11 at 08:17
  • @DJKRAZE - What do you mean propagate ? Sorry I don't get it. – kevin Dec 30 '11 at 08:29
  • did you make the changes in all the places where protected global::System.Web.Ui.UserControl was being referenced? Can you do CTRL+F and locate that in all files or entire project – MethodMan Dec 30 '11 at 08:34
  • No I don't make any more changes to the DocControl and the web user control project. – kevin Dec 30 '11 at 08:35
  • so what are you saying now.. ? how come you had to make the change out of curiosity.. was it working before..? you can use VS to make the change for you not sure if you were aware of that or not.. – MethodMan Dec 30 '11 at 08:38
  • when ever I try to use the control, it's **protected global::System.Web.UI.UserControl Control;** in the designer.cs default so I changed it to **protected global::MSN.DocControl Control;**.and when ever I try to modify the aspx file which contains the control , it become **protected global::System.Web.UI.UserControl Control;** again. I don't do anything to the Web User Control. – kevin Dec 30 '11 at 08:53
  • It was like that from the start. Do I has to configure something in VS ? – kevin Dec 30 '11 at 08:55
  • Pls see my answer below. Hope that it helps you too. – kevin Nov 20 '12 at 02:55

2 Answers2

3

I have solved it by moving

protected global::MSN.DocControl Control;

from designer.cs to .cs page.

So whenever you made any changes, it will be OK.

@kokbira - > hope that it helps you.

kevin
  • 13,559
  • 30
  • 79
  • 104
1

In my case, it was a bad src path in my register line. This caused no error messages, but would generate the generic control instead of the specific class, with the same symptoms you describe.

I had this (which has the wrong Src path):

<%@ Register TagPrefix="uc" TagName="Pipes" Src="/Controls/Pipes.ascx" %>
...
<uc:Pipes id="ucPipes" runat="server" />

and it generated this, which is generic, and has none of the control's properties:

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

When I did the correct path, with Category folder, it worked:

<%@ Register TagPrefix="uc" TagName="Pipes" Src="/Category/Controls/Pipes.ascx" %>
...
<uc:Pipes id="ucPipes" runat="server" />

and generated this correct one, so all properties worked:

 protected global::Company.Category.Controls.Pipes ucPipes;
goodeye
  • 2,389
  • 6
  • 35
  • 68