科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道在中编写一个Filter Provider WebPart(3)

在中编写一个Filter Provider WebPart(3)

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

WSSv3通过ASP.NET WebPart连接框架提供WebPart之间连接的编程。我们可以通过这种模式得到用户提供的搜索或过滤条件。

作者:sunmoonfire 来源:blog 2007年9月3日

关键字: SharePoint SharePoint2007 WebPart WSSv3 Office

  • 评论
  • 分享微博
  • 分享邮件
public virtual string ParameterName
    {
        
get
        {
            
return "Geographic Region";
        }
    }

    [wsswebparts.WebPartStorage(wsswebparts.Storage.None)]
    
public virtual ReadOnlyCollection<string> ParameterValues
    {
        
get
        {
            
string[] values = this.GetCurrentlySelectedGeographies();
            
return values == null ?
                
null :
                
new ReadOnlyCollection<string>(values);
        }
    }
   
    
public string[] GetCurrentlySelectedGeographies()
    {
        String[] choices 
= new String[5];
        
bool anythingSelected = false;

        
// It's possible for the ParameterValues property to be accessed
        
// before CreateChildControls has been called, so ensure the
        
// Region List combobox has been created.
        if (cblRegionList == null)
        {
            choices 
= null;
            
return choices;
        }

        
for (int i = 0; i < cblRegionList.Items.Count; i++)
        {
            
// Get the selected choices
            if (cblRegionList.Items[i].Selected)
            {
                anythingSelected 
= true;
                
if (cblRegionList.Items[i].Text != "All")
                {
                    choices[i] 
= cblRegionList.Items[i].Text;
                }
                
else
                {
                    choices 
= null;
                    
return choices;
                }
            }

        }
        
        
if (!anythingSelected)
            choices 
= null;

        
return choices;
    }

    
// Use the ConnectionProvider attribute to specify the method that
    
// the Web Part framework should call to allow us to return an instance
    
// of our ITransformableFilterValues interface.
    [aspnetwebparts.ConnectionProvider("Region Filter",
     
"ITransformableFilterValues", AllowsMultipleConnections = true)]
    
public wsswebparts.ITransformableFilterValues 
    SetConnectionInterface()
    {
        
return this;
    }

    
protected override void RenderContents(HtmlTextWriter output)
    {
        
this.EnsureChildControls();
        RenderChildren(output);
    }
}

在wssv3中,filter WebPart通过WebPart连接将筛选条件从一个WebPart(提供者WebPart)传递到另一个WebPart(消费者WebPart)。这使得我们可以编写更加成熟的应用,通过允许用户提供搜索或筛选的条件来整合2007 Microsoft Office system。(在接下来的系列文章中,将会有通过WebPart调用Excel Web Services的内容,请关注)

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章