2-7SharePoint webpart 的开发和使用
新建SharePoint空解决方案——>项目添加新项——>Web部件
using System; using System.ComponentModel; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; namespace CusotmPart.WPDemoWebPart { [ToolboxItemAttribute(false)] public class WPDemoWebPart : WebPart { private string url = "http://www.baidu.com"; [WebBrowsable(true)] [WebDisplayName("Url")] [WebDescription("This is Site Url...")] [Category("设置")] [Personalizable(true)] public string myurl { get { return url; } set { url = value; } } Button btn = new Button(); protected override void CreateChildControls() { ChromeType = PartChromeType.None; btn.Text = "Redirect Link"; btn.Click += Btn_Click; this.Controls.Add(btn); } //渲染 protected override void Render(HtmlTextWriter writer) { this.btn.RenderControl(writer); writer.Write("<div><a onclick='runScript()'>runScript</a></div>"); writer.Write("<script type='text/javascript'>function runScript(){ alert('HelloWorld')}</script>"); //writer.Write("<style type='style/css'>"); writer.Write("123456789"); //base.Render(writer); } private void Btn_Click(object sender, EventArgs e) { Page.Response.Redirect(myurl); } } }

web部件库的位置(部署后所在的位置)

修改feature名称

部署的访问 site 网站集 web管理中心(部署后需要激活feature)

feature中的项,webpart一定在feature中的项,vs版本不一样位置不一样

启动站点的修改,部署位置,全局或bin

映射文件夹,自动部署到磁盘,相对应的路径(图片,js,等等)

解决方案的位置,场中管理中心,管理场解决方案

发布解决方案包

命令行添加包

管理中心,场解决方案,部署相应的包

激活功能使用


浙公网安备 33010602011771号