Asp.net Sharepoint webparts-在.designer.cs文件中作为基本用户控件生成的自定义用户控件
我正在使用VisualStudio2010为Sharepoint 2010开发一个web部件 我已经创建了一个要包含在web部件中的用户控件。但是,当我在MyWebPart.ascx(在设计视图中)中删除用户控件时,它会在MyWebPart.ascx.designer.cs中生成,如下所示:Asp.net Sharepoint webparts-在.designer.cs文件中作为基本用户控件生成的自定义用户控件,asp.net,visual-studio-2010,user-controls,sharepoint-2010,web-parts,Asp.net,Visual Studio 2010,User Controls,Sharepoint 2010,Web Parts,我正在使用VisualStudio2010为Sharepoint 2010开发一个web部件 我已经创建了一个要包含在web部件中的用户控件。但是,当我在MyWebPart.ascx(在设计视图中)中删除用户控件时,它会在MyWebPart.ascx.designer.cs中生成,如下所示: protected global::System.Web.UI.UserControl customUserControl; 而不是: protected global::FullNamespace.Co
protected global::System.Web.UI.UserControl customUserControl;
而不是:
protected global::FullNamespace.ControlTemplates.MyUserControl customUserControl;
它可以工作,但我需要将customUserControl
转换为代码隐藏中的具体MyUserControl(例如,如果希望在PageLoad事件中设置其某些属性)
如何解决此问题?到目前为止,我的解决方案是在
yourpage.cs
中声明protected global::FullNamespace.ControlTemplates.MyUserControl customUserControl
。因此,它可以正确地获取实际类型
我认为这是最简单的“解决方案”。然而,我仍然觉得丑陋和怪异
如果你有更好的解决方案,请与我分享