飘遥的Blog

C/C++/.NET
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

SharePoint(WSS)学习(4) 添加ASPX页面

Posted on 2008-11-16 16:12  Zzx飘遥  阅读(1009)  评论(1编辑  收藏  举报
本篇介绍向站点添加ASPX页面。

1.新建工程
模板选择:Visual C# -> SharePoint - > Empty
名称输入SamplePage。


2.添加新建项,选择:Module。

3.向Module中添加ASPX页面,可以吧Sample.txt扩展名改成aspx文件再输入内容。
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    
<title></title>

    
<script type="text/C#" runat="server"> 
       void ShowMessage(object sender, EventArgs e)
        {
            txt1.Text
= "My Page!!";
        } 
    </script>

</head>
<body>
    
<form id="form1" runat="server">
    
<div>
        
<asp:TextBox ID="txt1" runat="server" Width="100"></asp:TextBox>
        
<asp:Button ID="btn1" runat="server" Text="Button" OnClick="ShowMessage" />
    
</div>
    
</form>
</body>
</html>

4.Module.xml内容进行相应的修改。
<?xml version="1.0" encoding="utf-8"?>
<Elements Id="e6ad0016-621c-460b-9de6-0881847edc8c" xmlns="http://schemas.microsoft.com/sharepoint/">
  
<Module Name="SamplePage" Url="MyPath">
    
<!--Url为二级路径-->
    
<File Path="MyPage.aspx" Url="MyPage.aspx" />
    
<!--Path为物理路径名,Url为访问时链接页面名称-->
  
</Module>
</Elements>

5.打开WSP View 窗口,可以看到该Module的内容。(菜单 -> View -> Other Windows -> WSP View)


6.部署:直接F5或从菜单 -> Build -> Deploy Solution。

7设置:
打开Central Administration -> Solution Management 可以看到列表中有simplecalculator.wsp,将其部署到Team Site。
wsp文件格式是个cab文件,用winrar等可以打开看到其内容。

然后打开Team Site,在Bin文件夹下可以看到已加入SamplePage.dll。打开Team Site的功能管理,激活SamplePage。

输入URl:http://localhost/MyPath/MyPage.aspx,页面可以正确执行。


也可以添加后台页代码,后面会用到。

飘遥的BLOG:http://www.cnblogs.com/zxjay/
作者:飘遥(周振兴)