Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net Sharepoint webparts-在.designer.cs文件中作为基本用户控件生成的自定义用户控件_Asp.net_Visual Studio 2010_User Controls_Sharepoint 2010_Web Parts - Fatal编程技术网

Asp.net Sharepoint webparts-在.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

我正在使用VisualStudio2010为Sharepoint 2010开发一个web部件

我已经创建了一个要包含在web部件中的用户控件。但是,当我在MyWebPart.ascx(在设计视图中)中删除用户控件时,它会在MyWebPart.ascx.designer.cs中生成,如下所示:

protected global::System.Web.UI.UserControl customUserControl;
而不是:

protected global::FullNamespace.ControlTemplates.MyUserControl customUserControl;
它可以工作,但我需要将
customUserControl
转换为代码隐藏中的具体MyUserControl(例如,如果希望在PageLoad事件中设置其某些属性)


如何解决此问题?

到目前为止,我的解决方案是在
yourpage.cs
中声明
protected global::FullNamespace.ControlTemplates.MyUserControl customUserControl
。因此,它可以正确地获取实际类型

我认为这是最简单的“解决方案”。然而,我仍然觉得丑陋和怪异

如果你有更好的解决方案,请与我分享