【问题标题】:SharePoint WebPart Type QuestionSharePoint WebPart 类型问题
【发布时间】:2011-04-15 19:57:42
【问题描述】:

我想根据传递给方法的 WebPart 的类型对 WebParts 做一些事情。 我发现我在做:

if(obj is Microsoft.SharePoint.WebPartPages.ContentEditorWebPart)
...
else if (obj is SummaryLinkWebPart)

对所有 WebPart 继续这样做听起来很有趣。有没有我应该使用的设计模式?

【问题讨论】:

    标签: sharepoint web-parts


    【解决方案1】:

    如果您需要访问特定类型的成员,那么确实没有任何 superclean 方法可以这样做。如果你愿意,你可以使用as操作符来达到和上面一样的效果:

    wp = obj as Microsoft.SharePoint.WebPartPages.ContentEditorWebPart;
    if(wp != null)
       ...
    

    【讨论】:

      猜你喜欢
      • 2011-11-29
      • 2011-06-02
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      • 2014-05-15
      • 2011-06-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多