定制属性及配置界面

本文详细介绍SharePoint环境下WebPart的开发流程,涵盖WSS2.0与WSS3.0的区别,WebPart属性配置,自定义编辑界面的实现,以及示例代码解析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文地址http://tuqiang9999.blog.163.com/blog/static/3324132011628105554772/

最近一段时间都在研究SharePoint下的开发,感觉SharePoint中的内容还是比较繁杂 的,不知道自己入了门没有?顺手记录下了开发过程中的一些心得和体会,以加深自己的理解和掌握,如有不对的地方,还请各位不吝指正。今天先讲讲 SharePoint下Web Part的开发,这应该算是SharePoint下最常见的开发了吧,今天的重点是关于自定义属性及配置界面的实现。 一、开发环境         (1)Windows 2003 Server         (2)Windows SharePoint Service 3.0(或Microsoft Office SharePoint Server 2007)         (3)Visual Studio 2005         (5)SQL Server 2005         (6)Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions         (7)Windows SharePoint Services SDK 3.0

二、WSS 2.0和WSS 3.0下Web Part开发的不同     众所周知,Windows SharePoint Service 3.0(以下简称WSS 3.0)是基于ASP.NET  2.0进行了重写,因此与WSS 2.0有很多地方存在一些不同。对于Web Part的开发,也是如此。目前网络上的很多资料介绍的Web Part开发,还是基于WSS 2.0的,而非WSS 3.0风格的。     Web Part是首先在WSS 2.0作为仪表板(Dashboard)的替代技术引入的,后来ASP.NET 2.0中也引入了一个新版本的Web Part Framework,该框架可以脱离SharePoint的环境运行。WSS 3.0的Web Part框架也基于该ASP.NET Web Part Framework进行了完全的重构。不过为了兼容性(主要是考虑到以前的解决方案的升级),原WSS 2.0的Web Part框架也得以保留,但对于以后的开发而言,都应该基于WSS 3.0的ASP.NET框架进行。     例如,基于WSS 2.0的Web Part都是从 Microsoft.SharePoint.WebPartPages.WebPart类派生的,而WSS 3.0的Web Part应该从标准的ASP.NET类System.Web.UI.WebControls.WebParts.WebPart继承。下表是基于 ASP.NET Web Part Framework中一些新的属性和类型,以及为了兼容性而保留的对应WSS 2.0模型中的属性和类型,具体的示例将在下面的章节中出现。  
ASP.NET Web Parts SharePoint Backward Compatibility
WebBrowsableAttribute BrowsableAttribute WebDisplayName
FriendlyName WebDescription Description
Personalizable WebPartStorage PersonalizationScope
Storage EditorPart ToolPart EditorPartCollection
ToolPart[] CreateEditorParts() GetToolParts()
RenderContents() RenderWebPart()
SetPersonalizationDirty() SaveProperties

三、SharePoint Web Part开发基础        Web Part是一种特殊类型的Web Control(Web控件),它被部署于Web Part Zone控件内。虽然基于ASP.NET的Web Part Framework可以脱离WSS环境运行,但是WSS 3.0中的Web Part Framework提供了一些附加的功能,包括:动态SharePoint站点模型、模板框架、安全框架以及使用WSS Web Part Gallery的Web Part管理。     WSS 3.0中使用的Web Part Manager类为SPWebPartManager,它是在页面Web Part Zone对象和SharePoint内容数据库之间的桥梁。当在页面中添加一个Web Part时,实际上是在内容数据库中加入了一个Web Part的序列化实例。对于一个最简单的Web Part而言,只需从Web Part 基类System.Web.UI.WebControls.WebParts.WebPart.派生一个具体类,然后重写RenderContents方 法来以HTML方式呈现该Web Part,就像在ASP.NET中开发Web控件一样。一个Web Part的生命周期如下表所示:

方法/事件 描述    OnInit 处理控件的初始化 OnLoad 处理控件的装载
CreateChildControls 创建子控件 EnsureChildControls
确保CreateChildControls方法被调用,使用该方法来确保在访问控件的数据之前控件已经存在。 OnPreRender
处理在呈现可控件之前必须完成的任务,例如数据装载。异步页面任务应该从该方法中被启动。 Page.PreRenderComplete
在所有的控件都完成其OnPreRender 方法并且页面已经完成了异步任务的执行之后,将会触发该事件。 Render
呈现整个控件,包括外部标签。 RenderContents 仅仅呈现控件在外部标签和样式属性内的内容。

   

四、Web Part属性     除了类似输出”Hello World“这样内容的最简单Web Part之外,一般实际的Web Part都是可动态配置的,这是通过Web Part属性来实现的。     在WSS 2.0中,一个Web Part属性是这样子的:        

01[Description("Data Source Name"),
02      Category("Miscellaneous"),
03      DefaultValue(""),
04      WebPartStorage(Storage.Shared),
05      FriendlyName("Data Source Name"),
06      Browsable(false)]
07       public string DataSourceName
08       {
09           get { return this.dataSourceName; }
10           set { this.dataSourceName = value; }
11       }
12 
13      当然,这不是我们推荐的用法,而应该采用如下新的语法:
14      [WebDescription("Data Source Name"),
15       Category("Miscellaneous"),
16       DefaultValue(""),
17       Personalizable(PersonalizationScope.Shared),
18       WebDisplayName("Data Source Name"),
19       WebBrowsable(false)]
20       public string DataSourceName
21       {
22           get { return this.dataSourceName; }
23           set { this.dataSourceName = value; }
24       }

     

    上述两个声明是完全等价的,大家可以参考第二节中的对应表来一一比较。注意到上述属性中WebBrowsable的属性为false,如果该属性为 true的话,就是使用默认的属性编辑界面,也就是一个文本输入框,如果想定制该属性的输入界面,则应该将WebBrowsable属性置为false, 然后提供定制属性界面。     在WSS 2.0中,自定义属性配置界面是通过重写Web Part的GetToolParts方法实现的,例如:      

01/**//// <summary>
02      /// 配置界面。
03      /// </summary>
04      /// <returns></returns>
05       public override ToolPart[] GetToolParts()
06       {
07           ToolPart[] tools = new ToolPart[3];
08           tools[0]         = new Microsoft.SharePoint.WebPartPages.WebPartToolPart();
09           tools[1]         = new Microsoft.SharePoint.WebPartPages.CustomPropertyToolPart();
10           tools[2]         = new MyToolPart();
11           tools[2].Title   = "My Properties";
12           return tools;
13       }

 

     

    其中,Microsoft.SharePoint.WebPartPages.WebPartToolPart类提供标准的属性配置界面,如布局,大小 等;而Microsoft.SharePoint.WebPartPages.CustomPropertyToolPart则提供默认的自定义属性配置 界面,这是利用反射实现的,如上述属性WebBrowsable为false,则意味着使用该类来提供默认的配置界面;而第三项MyToolPart则是 为自己实现的定制配置界面。     因为这是WSS 2.0中已经过时的用法,所以在此不再详述,我们重点关注一下WSS 3.0中的对应的实现。在WSS 3.0(ASP.NET 2.0)中,自定义属性配置界面是通过重写Web Part的CreateEditorParts方法实现的:

01/**//// <summary>
02     /// 配置界面。
03     /// </summary>
04     /// <returns></returns>
05    public override EditorPartCollection CreateEditorParts()
06      {
07          EditorPartCollection baseParts = base.CreateEditorParts();
08          List<EditorPart> editorParts = new List<EditorPart>(1);
09          EditorPart part = new MyEditorPart();
10          part.ID = this.ID + "_MyEditor";
11          editorParts.Add( part );
12          return new EditorPartCollection(baseParts, editorParts);
13      }

   

    要实现一个EditorPart,最简单的是重写三个方法:        (1)CreateChildControls:负责创建EditorPart的子控件        (2)ApplyChanges:保存配置到Web Part的属性        (3)SyncChanges:从Web Part属性初始化EditorPart            以下是一个具体的WebPart的代码:

001using System;
002using System.Runtime.InteropServices;
003using System.Web.UI;
004using System.Web.UI.WebControls.WebParts;
005using System.Xml.Serialization;
006using Microsoft.SharePoint;
007using Microsoft.SharePoint.Utilities;
008using System.ComponentModel;
009using System.Collections.Generic;
010 
011namespace KingFactoryTagValueWebPart2
012{
013    [Guid("3fd90ae1-9ff9-4b5e-8262-ac2649be9ebe")]
014    public class KingFactoryTagValueWebPart2 : System.Web.UI.WebControls.WebParts.WebPart
015    {
016        private string dataSourceName;
017        private string rtTagName;
018        private string refreshInterval;
019        private string webUrl;
020 
021        /// <summary>
022        /// 构造函数。
023        /// </summary>
024        public KingFactoryTagValueWebPart2()
025        {
026            this.ExportMode = WebPartExportMode.All;
027            this.refreshInterval = "5000";
028 
029        }
030 
031        /// <summary>
032        /// 输出错误信息。
033        /// </summary>
034        /// <param name="writer"></param>
035        /// <param name="errorInfo"></param>
036        private void RenderError(HtmlTextWriter writer, string errorInfo)
037        {
038            string content = "<span><table class="ms-WPBody" style="padding:0px;width:100%;">" +
039                "<tr><td valign="top" style="padding-left:4px;padding-right:4px;"><img src="http://tuqiang9999.blog.163.com/blog//_layouts/1033/images/error.gif" alt="错误信息" /></td>" +
040                "<td width="100%" style="padding-left:4px;padding-right:4px;">" +
041                errorInfo +
042                "</td></tr></table></span>";
043            writer.Write(content);
044        }
045 
046 
047        /// <summary>
048        /// 输出结果
049        /// </summary>
050        /// <param name="writer"></param>
051        protected override void Render(HtmlTextWriter writer)
052        {
053            // 检查网址
054            if (this.webUrl == null || this.webUrl == string.Empty)
055            {
056                RenderError(writer, "错误:请选择网站");
057                return;
058            }
059 
060 
061            // 检查数据源
062            if (this.dataSourceName == null || this.dataSourceName == string.Empty)
063            {
064                RenderError(writer, "错误:请选择数据源");
065                return;
066            }
067 
068            // 检查变量
069            if (this.rtTagName == null || this.rtTagName == string.Empty)
070            {
071                RenderError(writer, "错误:请选择变量");
072                return;
073            }
074 
075            // 刷新间隔
076            if (this.refreshInterval == null || this.refreshInterval == string.Empty)
077                this.refreshInterval = "5000";
078 
079 
080            // 生成输出
081            SPWeb web = SPContext.Current.Web;
082            string content = string.Format("<iframe src="http://tuqiang9999.blog.163.com/blog/{0}?UserName={1}&DataSourceName={2}&TagName={3}&RefreshInterval={4}" width="100%" height="100%"></iframe>",
083                this.webUrl,
084                SPEncode.UrlEncode(web.CurrentUser.LoginName),
085                SPEncode.UrlEncode(this.dataSourceName),
086                SPEncode.UrlEncode(this.rtTagName),
087                this.RefreshInterval);
088            writer.Write(content);
089        }
090 
091 
092 
093        /// <summary>
094        /// 获得编辑界面。
095        /// </summary>
096        /// <returns></returns>
097        public override EditorPartCollection CreateEditorParts()
098        {
099            EditorPartCollection baseParts = base.CreateEditorParts();
100            List<EditorPart> editorParts = new List<EditorPart>(1);
101            EditorPart part = new KingFactoryTagValueEditorPart2();
102            part.ID = this.ID + "_tagValueEditor";
103            part.Title = "KingFactory变量选择"
104            editorParts.Add( part );
105            return new EditorPartCollection(baseParts, editorParts);
106        }
107 
108 
109        [WebDescription ("Web URL"),
110        Category("Miscellaneous"),
111        DefaultValue(""),
112        Personalizable(PersonalizationScope.Shared),
113        WebDisplayName("Web URL"),
114        WebBrowsable(false)]
115        public string WebURL
116        {
117            get { return this.webUrl; }
118            set { this.webUrl = value; }
119        }
120 
121        [WebDescription("Data Source Name"),
122        Category("Miscellaneous"),
123        DefaultValue(""),
124        Personalizable(PersonalizationScope.Shared),
125        WebDisplayName("Data Source Name"),
126        WebBrowsable(false)]
127        public string DataSourceName
128        {
129            get { return this.dataSourceName; }
130            set { this.dataSourceName = value; }
131        }
132 
133 
134        [WebDescription("Tag Name"),
135        Category("Miscellaneous"),
136        DefaultValue(""),
137        Personalizable(PersonalizationScope.Shared),
138        WebDisplayName("Tag Name"),
139        WebBrowsable(false)]
140        public string RtTagName
141        {
142            get { return this.rtTagName; }
143            set { this.rtTagName = value; }
144        }
145 
146 
147        [WebDescription("Refresh Interval"),
148        Category("Miscellaneous"),
149        DefaultValue(""),
150        Personalizable(PersonalizationScope.Shared),
151        WebDisplayName("Refresh Interval"),
152        WebBrowsable(false)]
153        public string RefreshInterval
154        {
155            get { return this.refreshInterval; }
156            set { this.refreshInterval = value; }
157        }
158 
159    }
160}

 

 

    以下为对应的EditorPart的代码:      

001using System;
002using System.Collections.Generic;
003using System.Text;
004using System.Web;
005using System.Web.UI;
006using System.Web.UI.WebControls;
007using System.Web.UI.WebControls.WebParts;
008using Microsoft.SharePoint;
009using Microsoft.SharePoint.Administration;
010 
011namespace KingFactoryTagValueWebPart2
012{
013    public class KingFactoryTagValueEditorPart2 : EditorPart
014    {
015        protected Label Label1;
016        protected Label Label2;
017        protected Label Label3;
018        protected Label Label4;
019        protected Label Label5;
020        protected TextBox refreshInterval;
021        protected TextBox selectedTagName;
022        protected TreeView TagNameView;
023        protected DropDownList webSiteList;
024        protected DropDownList dataSourceList;
025 
026        /// <summary>
027        /// 创建子控件。
028        /// </summary>
029        protected override void CreateChildControls()
030        {
031            base.CreateChildControls();
032 
033            this.Label1 = new Label();
034            this.Label1.Text = "选择网站:";
035            this.Label1.Width = 80;
036            this.Label2 = new Label();
037            this.Label2.Text = "选择数据源:";
038            this.Label3 = new Label();
039            this.Label3.Text = "刷新间隔:";
040            this.Label4 = new Label();
041            this.Label4.Text = "选择变量:";
042            this.refreshInterval = new TextBox();
043            this.selectedTagName = new TextBox();
044            this.TagNameView = new TreeView();
045            this.webSiteList = new DropDownList();
046            this.dataSourceList = new DropDownList();
047            this.dataSourceList.SelectedIndex = -1;
048            this.webSiteList.SelectedIndex = -1;
049            this.webSiteList.AutoPostBack = true;
050            this.webSiteList.SelectedIndexChanged += new EventHandler(webSiteList_SelectedIndexChanged);
051            this.dataSourceList.AutoPostBack = true;
052            this.dataSourceList.SelectedIndexChanged += new EventHandler(dataSourceList_SelectedIndexChanged);
053            this.TagNameView.ImageSet = TreeViewImageSet.XPFileExplorer;
054            this.TagNameView.ShowLines = true;
055            this.TagNameView.EnableClientScript = true;
056            this.TagNameView.SelectedNodeChanged += new EventHandler(TagNameView_SelectedNodeChanged);
057 
058            // 表格控件(布局)
059            Table       table = new Table();
060            table.CellPadding = 0;
061            table.CellSpacing = 0;
062            table.Style.Add(HtmlTextWriterStyle.Height, "190px");
063            table.Style.Add(HtmlTextWriterStyle.Width, "100%");
064 
065 
066            // 第一行
067            TableRow    row     = new TableRow();
068            TableCell   cell1   = new TableCell();
069            TableCell   cell2   = new TableCell();
070            cell1.Style.Add( HtmlTextWriterStyle.TextAlign, "right" );
071            cell1.Controls.Add( this.Label1);
072            cell2.Controls.Add( this.webSiteList );
073            row.Cells.Add( cell1 );
074            row.Cells.Add( cell2 );
075            table.Rows.Add( row );
076 
077            // 第二行
078            row     = new TableRow();
079            cell1   = new TableCell();
080            cell2   = new TableCell();
081            cell1.Style.Add( HtmlTextWriterStyle.TextAlign, "right" );
082            cell1.Controls.Add( this.Label2 );
083            cell2.Controls.Add( this.dataSourceList );
084            row.Cells.Add( cell1 );
085            row.Cells.Add( cell2 );
086            table.Rows.Add( row );
087 
088 
089            // 第三行
090            row     = new TableRow();
091            cell1   = new TableCell();
092            cell2   = new TableCell();
093            cell1.Style.Add( HtmlTextWriterStyle.TextAlign, "right" );
094            cell1.Controls.Add( this.Label3 );
095            cell2.Controls.Add( this.refreshInterval );
096            row.Cells.Add( cell1 );
097            row.Cells.Add( cell2 );
098            table.Rows.Add( row );
099 
100            // 第四行
101            row     = new TableRow();
102            cell1   = new TableCell();
103            cell2   = new TableCell();
104            cell1.Style.Add( HtmlTextWriterStyle.TextAlign, "right" );
105            cell1.Controls.Add( this.Label4 );
106            cell2.Controls.Add( this.selectedTagName );
107            row.Cells.Add( cell1 );
108            row.Cells.Add( cell2 );
109            table.Rows.Add( row );
110 
111            // 第五行
112            row     = new TableRow();
113            cell1   = new TableCell();
114            cell1.ColumnSpan = 2;
115            cell1.RowSpan    = 3;
116            cell1.Controls.Add( this.TagNameView );
117            row.Cells.Add( cell1 );
118            table.Rows.Add( row );
119           
120 
121            // 加入到容器中
122            this.Controls.Add(table);
123        }
124 
125 
126        /// <summary>
127        /// 改变数据源。
128        /// </summary>
129        /// <param name="sender"></param>
130        /// <param name="e"></param>
131        protected void dataSourceList_SelectedIndexChanged(object sender, EventArgs e)
132        {
133            FillTagNameTreeView();
134        }
135 
136 
137        /// <summary>
138        /// 改变站点。
139        /// </summary>
140        /// <param name="sender"></param>
141        /// <param name="e"></param>
142        protected void webSiteList_SelectedIndexChanged(object sender, EventArgs e)
143        {
144            FillDataSourceList();
145        }
146 
147        /// <summary>
148        /// 更改选择的节点。
149        /// </summary>
150        /// <param name="sender"></param>
151        /// <param name="e"></param>
152        protected void TagNameView_SelectedNodeChanged(object sender, EventArgs e)
153        {
154            if (this.TagNameView.SelectedNode.Value != null)
155                this.selectedTagName.Text = this.TagNameView.SelectedNode.Value;
156            else
157                this.selectedTagName.Text = "";
158        }
159 
160        /// <summary>
161        /// 构造变量树节点。
162        /// </summary>
163        /// <param name="item"></param>
164        /// <param name="rootNode"></param>
165        private void PopulateTreeItem(BrowseItemService.Item item, TreeNode rootNode)
166        {
167            TreeNode node = new TreeNode();
168            node.Text = item.DisplayName;
169            if (item.GroupItem)
170                node.Value = null;
171            else
172                node.Value = item.ItemName;
173            rootNode.ChildNodes.Add(node);
174            if (item.GroupItem)
175            {
176                foreach (BrowseItemService.Item childItem in item.Children)
177                {
178                    PopulateTreeItem(childItem, node);
179                }
180            }
181 
182        }
183 
184 
185        /// <summary>
186        /// 填充变量树。
187        /// </summary>
188        private void FillTagNameTreeView()
189        {
190            this.TagNameView.Nodes.Clear();
191            int count = this.TagNameView.Nodes.Count;
192 
193            string webURL = this.webSiteList.SelectedItem.Value;
194            if (webURL == null) return;
195            string dataSourceName = this.dataSourceList.SelectedItem.Value;
196            if (dataSourceName == null) return;
197            try
198            {
199                string serviceURL = webURL + "/WebService/BrowseItemService.asmx";
200                BrowseItemService.BrowseItemService service = new BrowseItemService.BrowseItemService();
201                service.Url = serviceURL;
202                service.WebAuthenticationValue = new BrowseItemService.WebAuthentication();
203                service.WebAuthenticationValue.UserName = SPContext.Current.Web.CurrentUser.LoginName;
204                service.WebAuthenticationValue.Password = "";
205                service.WebAuthenticationValue.ExtendInfo = "";
206                BrowseItemService.Item[] items = service.BrowseItems(dataSourceName, "1", "", true, false);
207                if (items != null && items.Length > 0)
208                {
209                    TreeNode node = new TreeNode();
210                    node.Text = dataSourceName;
211                    node.Value = null;
212                    this.TagNameView.Nodes.Add(node);
213                    foreach (BrowseItemService.Item item in items)
214                        PopulateTreeItem(item, node);
215                }
216 
217            }
218            catch (Exception ex)
219            {
220            }
221        }
222 
223 
224        /// <summary>
225        /// 填充数据源列表。
226        /// </summary>
227        protected void FillDataSourceList()
228        {
229            this.TagNameView.Nodes.Clear();
230            this.dataSourceList.Items.Clear();
231            string webURL = this.webSiteList.SelectedItem.Value;
232            if (webURL == null) return;
233            try
234            {
235                string serviceURL = webURL + "/WebService/AdminService.asmx";
236                AdminService.AdminService service = new AdminService.AdminService();
237                service.Url = serviceURL;
238                service.WebAuthenticationValue = new AdminService.WebAuthentication();
239                service.WebAuthenticationValue.UserName = SPContext.Current.Web.CurrentUser.LoginName;
240                service.WebAuthenticationValue.Password = "";
241                service.WebAuthenticationValue.ExtendInfo = "";
242 
243                AdminService.DataSourceInfo[] infos = service.GetDataSourceList(null);
244                for (int i = 0; i < infos.Length; i++)
245                {
246                    if (!service.SupportInterface(infos[i].Name, "IBrowseItem"))
247                        continue;
248 
249                    if (!service.SupportInterface(infos[i].Name, "IRealtime"))
250                        continue;
251 
252                    this.dataSourceList.Items.Add(infos[i].Name);
253                }
254 
255                if (this.dataSourceList.Items.Count > 0)
256                {
257                    this.dataSourceList.SelectedIndex = 0;
258                    FillTagNameTreeView();
259                }
260            }
261            catch (Exception ex)
262            {
263            }
264        }
265 
266        /// <summary>
267        /// 保存设置。
268        /// </summary>
269        /// <returns></returns>
270        public override bool ApplyChanges()
271        {
272            this.EnsureChildControls();
273            KingFactoryTagValueWebPart2 webpart = this.WebPartToEdit as KingFactoryTagValueWebPart2;
274            if (webpart == null) return false;
275 
276            // 设置webURL
277            if (this.webSiteList.SelectedItem != null)
278                webpart.WebURL = this.webSiteList.SelectedItem.Text + "/XBAP/KingFactoryTagValue.xbap";
279            else
280                webpart.WebURL = null;
281 
282            // 设置数据源
283            if (this.dataSourceList.SelectedItem != null)
284                webpart.DataSourceName = this.dataSourceList.SelectedItem.Text;
285            else
286                webpart.DataSourceName = null;
287 
288            // 设置变量名称
289            if (this.selectedTagName.Text != null)
290                webpart.RtTagName = this.selectedTagName.Text;
291            else
292                webpart.RtTagName = null;
293 
294            // 刷新间隔
295            if (this.refreshInterval.Text != null)
296                webpart.RefreshInterval = this.refreshInterval.Text;
297            else
298                webpart.RefreshInterval = null;
299 
300            return true;
301        }
302 
303        /// <summary>
304        /// 初始化。
305        /// </summary>
306        public override void SyncChanges()
307        {
308            EnsureChildControls();
309            KingFactoryTagValueWebPart2 webpart = this.WebPartToEdit as KingFactoryTagValueWebPart2;
310            if (webpart == null) return;
311 
312            // 枚举网站
313            SPWebServiceCollection webServices = new SPWebServiceCollection(SPFarm.Local);
314            foreach (SPWebService webService in webServices)
315            {
316                foreach (SPWebApplication webApp in webService.WebApplications)
317                {
318                    foreach (SPSite site in webApp.Sites)
319                    {
320                        if (site.Url != null && site.Url != string.Empty)
321                        {
322                            this.webSiteList.Items.Add(site.Url);
323                        }
324                    }
325                }
326            }
327 
328            // 填充数据源
329            if (this.webSiteList.Items.Count > 0)
330            {
331                int selectedIndex = -1;
332                if (webpart.WebURL != null)
333              &nbs,p; {
334                    for (int i = 0; i < this.webSiteList.Items.Count; i++)
335     &n,bsp;              {
336                        if (webpart.WebURL.Contains(this.webSiteList.Items[i].Text))
337                        {
338                            selectedIndex = i;
339                            break;
340                        }
341                    }
342                }
343                if (selectedIndex == -1) selectedIndex = 0;
344                this.webSiteList.SelectedIndex = selectedIndex;
345                FillDataSourceList();
346            }
347 
348            // 设置刷新间隔
349            if (webpart.RefreshInterval != null)
350                this.refreshInterval.Text = webpart.RefreshInterval;
351            else
352                this.refreshInterval.Text = "5000";
353 
354            // 设置变量
355            if (webpart.RtTagName != null)
356                this.selectedTagName.Text = webpart.RtTagName;
357        }
358    }
359}

转载于:https://www.cnblogs.com/liubinurl/archive/2012/06/13/2547285.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值