转:http://www.cnblogs.com/fatwhale/archive/2010/02/24/1672633.html

在Visual Studio 2010中,  已经集成了用于SharePoint开发的feature,通过它,我们方便快速的开发部署web part、内容类型、列表、工作流 、BDC等,基本上包含了在SharePoint中所有的开发项目。在这篇文章中,向大家介绍一下如果使用它来快速开发和部署Web Part。
    我使用的是Visual Studio 2010 Ultimate Beta 2版本。

新建一个项目,使用SharePoint 2010下的Visual Web Part模板,如图:

接着,会弹出选择部署站点的窗口,输入站点地址,完成:\

看一下解决方案中默认生成的项目:

我们来做一个非常简单web part,页面上放两个单选按钮,一个叫yaoyao,一个叫Elly,点击在图片控件中切换这俩妞的照片,而照片存放在SharePoint站点Layouts下Images文件夹中,注意,我们是通过Visual Studio2010来上传上去,嘿,这是照片,随便在网上找的两张,太火了~

 

首先,我们在VisualWebPart1UserControl.ascx中添加需要的控件,RadioButtonList和Image,并添加两条item,如下:
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True"
    onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
    <asp:ListItem>YaoYao</asp:ListItem>
    <asp:ListItem>Elly</asp:ListItem>
</asp:RadioButtonList>
<asp:Image ID="imgBeauty" runat="server" />

然后,通过Visual Studio 2010向SharePoint 2010上传图片,右键点击项目,添加,SharePoint “Images” Mapped Folder,如图:

然后,将照片添加到这个文件夹中,添加—添加现有项:


我们再来简单的写一些后台处理代码,在RadioButtonList1_SelectedIndexChanged 事件中:

 

代码
posted on 2013-12-07 19:31  jackljf  阅读(172)  评论(0编辑  收藏  举报