Reputation: 19014
I'm using Visual Studio 2010 to develop a web part for Sharepoint 2010.
I've created a user control which I want to include in my web part. However, when I drop the user control in MyWebPart.ascx (in design view) it gets generated as follows in the MyWebPart.ascx.designer.cs:
protected global::System.Web.UI.UserControl customUserControl;
instead of:
protected global::FullNamespace.ControlTemplates.MyUserControl customUserControl;
It works, but I need to cast customUserControl
to the concrete MyUserControl in the code behind (e.g. if want to set some of its properties in the PageLoad event).
How do I fix this?
Upvotes: 0
Views: 327
Reputation: 11
So far, my solution is declare protected global::FullNamespace.ControlTemplates.MyUserControl customUserControl
in yourpage.cs
. So it can get the actual type correctly.
The is easiest "solution" I think. However I still feel ugly and weird.
If you've got a better solution, please share it with me.
Upvotes: 1