【问题标题】:Sharepoint webparts - Custom user control generated as base UserControl in the .designer.cs fileSharepoint webparts - 在 .designer.cs 文件中作为基本 UserControl 生成的自定义用户控件
【发布时间】:2011-07-21 09:00:12
【问题描述】:

我正在使用 Visual Studio 2010 为 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 事件中设置它的一些属性)。

我该如何解决这个问题?

【问题讨论】:

    标签: asp.net visual-studio-2010 user-controls sharepoint-2010 web-parts


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2019-12-24
      • 2011-07-11
      • 2012-02-19
      • 1970-01-01
      • 1970-01-01
      • 2011-01-22
      • 2011-06-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多