ASP.NET2.0学习8--WebPart部件
2006-08-10 23:37
183 查看
WebPart学习
内容:
功能简介
webpart的五个模式
自定义webpart部件
一、Webpart功能简介
1. 自定义页面内容
2. 自定义页面布局
3. 导入、导出webpart
4. 在不同部件间建立通信
5. 管理和个性化的设置
二、创建Webpart
1. 用现成web控件建立
2. 自定义webpart
继承自WebPart类
重要方法:
public override void RenderControl(HtmlTextWriter writer)
三、WebPart的模式:
WebPartManager1.DisplayMode=WebPartManager.BrowseDisplayMode;
WebPartManager1.DisplayMode=WebPartManager.DesignDisplayMode;
WebPartManager1.DisplayMode = WebPartManager.EditDisplayMode;
WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode;
WebPartManager1.DisplayMode = WebPartManager.ConnectDisplayMode;
对于后四个模式要使用下面的web.config中的个性化配置才能启用
<webParts enableExport="true">
<personalization>
<authorization>
<allow users="gong" verbs="enterSharedScope"/>
</authorization>
</personalization>
</webParts>
1. 浏览模式:
显示部件,不能作其它操作
2. 设计模式
可以删除,拖放部件
3. 编辑模式
可以删除,拖放部件
修改webpart的相关外观、行为和属性
4. 目录模式
支持导入、导出功能,添加webpart控件
在目录模式中可以导出一个webpart
1.设置web.config
<webParts enableExport="true">
<personalization>
<authorization>
<allow users="gong" verbs="enterSharedScope"/>
</authorization>
</personalization>
</webParts>
2.设置webpart控件的ExportMode属性为非None
5. 连接模式
多个webpart间数据的通信
Webpart连接:
1. 设置两个WebPart间的通讯接口
public interface ITestWord
{
string TestText
{
get;
set;
}
}
2. 实现提供者webpart
public class TempWebpart : WebPart,ITestWord
[Personalizable(true),WebBrowsable(true)]
public string TestText //ItestWord接口数据实现
标记提供者函数
[ConnectionProvider("TestWordProvider","TestWordProvider")]
public ITestWord ProvideTest()
{
return this;
}
3. 实现订阅者webpart
public class TestConsumer : WebPart
//标记订阅者函数
[ConnectionConsumer("TestWordConsumer","TestWordConsumer")]
public void GetTest(ITestWord testWord)
4. 界面设置
静态连接:
<asp:WebPartManager ID="WebPartManager1" runat="server">
<StaticConnections>
<asp:WebPartConnection ID="tt1" ProviderID="temp1" ConsumerID="testconsumer1"
ProviderConnectionPointID="TestWordProvider" ConsumerConnectionPointID="TestWordConsumer" />
</StaticConnections>
</asp:WebPartManager>
动态连接:
在<asp:WebPartManager ID="WebPartManager1" runat="server">
</asp:WebPartManager>之间没有内容
下面的设置一样
<asp:WebPartZone ID="WebPartZone3" runat="server">
<ZoneTemplate>
<test:tempwebpart id="temp1" runat="server" />
</ZoneTemplate>
</asp:WebPartZone>
<asp:WebPartZone ID="WebPartZone4" runat="server">
<ZoneTemplate>
<test:testconsumer ID="testconsumer1" runat="server" />
</ZoneTemplate>
</asp:WebPartZone>
内容:
功能简介
webpart的五个模式
自定义webpart部件
一、Webpart功能简介
1. 自定义页面内容
2. 自定义页面布局
3. 导入、导出webpart
4. 在不同部件间建立通信
5. 管理和个性化的设置
二、创建Webpart
1. 用现成web控件建立
2. 自定义webpart
继承自WebPart类
重要方法:
public override void RenderControl(HtmlTextWriter writer)
三、WebPart的模式:
WebPartManager1.DisplayMode=WebPartManager.BrowseDisplayMode;
WebPartManager1.DisplayMode=WebPartManager.DesignDisplayMode;
WebPartManager1.DisplayMode = WebPartManager.EditDisplayMode;
WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode;
WebPartManager1.DisplayMode = WebPartManager.ConnectDisplayMode;
对于后四个模式要使用下面的web.config中的个性化配置才能启用
<webParts enableExport="true">
<personalization>
<authorization>
<allow users="gong" verbs="enterSharedScope"/>
</authorization>
</personalization>
</webParts>
1. 浏览模式:
显示部件,不能作其它操作
2. 设计模式
可以删除,拖放部件
3. 编辑模式
可以删除,拖放部件
修改webpart的相关外观、行为和属性
4. 目录模式
支持导入、导出功能,添加webpart控件
在目录模式中可以导出一个webpart
1.设置web.config
<webParts enableExport="true">
<personalization>
<authorization>
<allow users="gong" verbs="enterSharedScope"/>
</authorization>
</personalization>
</webParts>
2.设置webpart控件的ExportMode属性为非None
5. 连接模式
多个webpart间数据的通信
Webpart连接:
1. 设置两个WebPart间的通讯接口
public interface ITestWord
{
string TestText
{
get;
set;
}
}
2. 实现提供者webpart
public class TempWebpart : WebPart,ITestWord
[Personalizable(true),WebBrowsable(true)]
public string TestText //ItestWord接口数据实现
标记提供者函数
[ConnectionProvider("TestWordProvider","TestWordProvider")]
public ITestWord ProvideTest()
{
return this;
}
3. 实现订阅者webpart
public class TestConsumer : WebPart
//标记订阅者函数
[ConnectionConsumer("TestWordConsumer","TestWordConsumer")]
public void GetTest(ITestWord testWord)
4. 界面设置
静态连接:
<asp:WebPartManager ID="WebPartManager1" runat="server">
<StaticConnections>
<asp:WebPartConnection ID="tt1" ProviderID="temp1" ConsumerID="testconsumer1"
ProviderConnectionPointID="TestWordProvider" ConsumerConnectionPointID="TestWordConsumer" />
</StaticConnections>
</asp:WebPartManager>
动态连接:
在<asp:WebPartManager ID="WebPartManager1" runat="server">
</asp:WebPartManager>之间没有内容
下面的设置一样
<asp:WebPartZone ID="WebPartZone3" runat="server">
<ZoneTemplate>
<test:tempwebpart id="temp1" runat="server" />
</ZoneTemplate>
</asp:WebPartZone>
<asp:WebPartZone ID="WebPartZone4" runat="server">
<ZoneTemplate>
<test:testconsumer ID="testconsumer1" runat="server" />
</ZoneTemplate>
</asp:WebPartZone>
相关文章推荐
- asp.net2.0学习历程 菜鸟到中级程序员的飞跃
- ASP.NET2.0学习5--N层代码示例
- ASP.NET2.0中Gridview中数据操作技巧[学习笔记]
- asp.net2.0学习历程-菜鸟到中级程序员的飞跃-.Net编程教程
- ASP.NET2.0学习7--个性化用户配置
- [学习笔记][ASP.NET2.0][点击asp:Button出现两次提交数据的问题][解决:去掉OnClick或者OnCommand属性]
- ASP.NET2.0学习--N层代码示例
- Asp.net2.0身份验证技术学习入门---创建验证
- asp.net2.0学习历程 菜鸟到中级程序员的飞跃
- asp.net2.0学习指导 菜鸟到中级程序员的飞跃(转)
- ASP.NET2.0学习--2程序架构
- 推荐一些我经常参考的ASP.NET2.0的学习网站
- asp.net2.0 控件开发(学习笔记之二)
- asp.net2.0 控件开发(学习笔记之五)
- ASP.NET2.0---GridView控件学习
- 【转】asp.net2.0学习历程----菜鸟到中级程序员的飞跃
- [摘自MSDN] ASP.Net2.0学习 [1] 母版页 7 : 母版页和内容页中的事件
- [摘自MSDN] ASP.Net2.0学习 [2] 主题 7 :演练:创建用户可选择的主题
- asp.net2.0学习历程 菜鸟到中级程序员的飞跃 转自清清月儿
- asp.net2.0学习历程 菜鸟到中级程序员的飞跃