在ASP.NET 2.0中使用WebParts
2007-11-07 14:03
429 查看
在asp.net
2.0中使用WebParts
原文地址:http://dotnetslackers.com/articles/aspnet/UsingWebPartsInASPNet20.aspx
[代码下载(有修改)]
作者:Abdul Sami
FROM:/article/4589491.html
介绍
如果说WebParts是web中一个非酷的效果的话,我想没有人会怀疑。WebParts为我们提供了对页中的对象进行拖拽的功能,它也可以在runtime的时候改变对象的标题、边框样式等。在WebParts出现之前,要实现这个功能是一项令人非常头痛的工作,因为我们必须写大量的JavaScrip,还要把页中每个对象的状态保存到数据库中。
WebParts有两个基本的东东
·WebPartManager
·WebPart Zones
if (cmbOptions.SelectedValue == "Design")
else if (cmbOptions.SelectedValue == "Browse")
else if (cmbOptions.SelectedValue == "Catalog")
else if (cmbOptions.SelectedValue == "Edit")
else if (cmbOptions.SelectedValue == "Connect")
string _cssClass = "FrmTxtBox";
[WebBrowsable(), Personalizable(true)]
public string CssClass
protected void Page_Load(Object sender, EventArgs e)
<webParts enableExport="true"></webParts>
然后我们有两种方法可以实现导出功能
设置控件的属性ExportMode的值为All。如果你的控件继承自WebPart就可以这么做,代码如下
<aspSample:CustomWebPart id="Sample" runat="server" ExportMode="All" />
或者在Page_Load里写如下代码
GenericWebPart gwp = WebUserControl2_1.Parent;
gwp.ExportMode = WebPartExportMode.All;
通过导入功能我们就可以增加任何webpart了,图例如下
public interface ITextToPass
public partial class ProviderWebPart : System.Web.UI.UserControl, ITextToPass
[ConnectionConsumer("Text", "TextConsumer")]
public void GetTextTransferInterface(ITextToPass provider)
<connectionStrings>
<clear/>
<add name="LocalSqlServer"
connectionString="data source=127.0.0.1;database=Database1;
user id=sa ;password=sa"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
<authentication mode="Forms" />
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="LocalSqlServer"
applicationName="/CustomConnections" />
</providers>
</membership>
<profile enabled="true" defaultProvider="TableProfileProvider">
<providers>
<clear/>
<add name="TableProfileProvider"
type="Microsoft.Samples.SqlTableProfileProvider"
connectionStringName="LocalSqlServer"
table="asdspnet_Profile"
applicationName="/CustomConnections"/>
</providers>
</profile>
</system.web>
总结
webparts为我们提供了一个在运行时自定义web站点的简单方法。它是从SharePoint中提取出来,并引进到asp.net
2.0中的。我们已经在本文中测试了它的一些基本用法,如使用不同类型的webpart和使用自定义数据库等等。
2.0中使用WebParts
原文地址:http://dotnetslackers.com/articles/aspnet/UsingWebPartsInASPNet20.aspx
[代码下载(有修改)]
作者:Abdul Sami
FROM:/article/4589491.html
介绍
如果说WebParts是web中一个非酷的效果的话,我想没有人会怀疑。WebParts为我们提供了对页中的对象进行拖拽的功能,它也可以在runtime的时候改变对象的标题、边框样式等。在WebParts出现之前,要实现这个功能是一项令人非常头痛的工作,因为我们必须写大量的JavaScrip,还要把页中每个对象的状态保存到数据库中。
WebParts有两个基本的东东
·WebPartManager
·WebPart Zones
if (cmbOptions.SelectedValue == "Design")
else if (cmbOptions.SelectedValue == "Browse")
else if (cmbOptions.SelectedValue == "Catalog")
else if (cmbOptions.SelectedValue == "Edit")
else if (cmbOptions.SelectedValue == "Connect")
string _cssClass = "FrmTxtBox";
[WebBrowsable(), Personalizable(true)]
public string CssClass
protected void Page_Load(Object sender, EventArgs e)
<webParts enableExport="true"></webParts>
然后我们有两种方法可以实现导出功能
设置控件的属性ExportMode的值为All。如果你的控件继承自WebPart就可以这么做,代码如下
<aspSample:CustomWebPart id="Sample" runat="server" ExportMode="All" />
或者在Page_Load里写如下代码
GenericWebPart gwp = WebUserControl2_1.Parent;
gwp.ExportMode = WebPartExportMode.All;
通过导入功能我们就可以增加任何webpart了,图例如下
public interface ITextToPass
public partial class ProviderWebPart : System.Web.UI.UserControl, ITextToPass
[ConnectionConsumer("Text", "TextConsumer")]
public void GetTextTransferInterface(ITextToPass provider)
<connectionStrings>
<clear/>
<add name="LocalSqlServer"
connectionString="data source=127.0.0.1;database=Database1;
user id=sa ;password=sa"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
<authentication mode="Forms" />
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="LocalSqlServer"
applicationName="/CustomConnections" />
</providers>
</membership>
<profile enabled="true" defaultProvider="TableProfileProvider">
<providers>
<clear/>
<add name="TableProfileProvider"
type="Microsoft.Samples.SqlTableProfileProvider"
connectionStringName="LocalSqlServer"
table="asdspnet_Profile"
applicationName="/CustomConnections"/>
</providers>
</profile>
</system.web>
总结
webparts为我们提供了一个在运行时自定义web站点的简单方法。它是从SharePoint中提取出来,并引进到asp.net
2.0中的。我们已经在本文中测试了它的一些基本用法,如使用不同类型的webpart和使用自定义数据库等等。
相关文章推荐
- [翻译]在asp.net 2.0中使用WebParts
- WSSv3 Technical Articles_使用ASP.NET 2.0 Web Parts和Windows SharePoint Services 3.0
- 在asp.net 2.0中使用WebParts
- WSSv3 Technical Articles_使用ASP.NET 2.0 Web Parts和Windows SharePoint Services 3.0
- [翻译]在asp.net 2.0中使用WebParts
- 上接[翻译]在asp.net 2.0中使用WebParts
- asp.net 2.0中使用WebParts
- [翻译]在asp.net 2.0中使用WebParts
- 在asp.net 2.0中使用WebParts(转载)
- [翻译]在asp.net 2.0中使用WebParts 『转』
- 如何在ASP.NET 2.0中使用 Web Parts
- 如何在ASP.NET 2.0中使用Web Parts
- 在asp.net 2.0中使用WebParts
- 使用 ASP.NET 2.0 生成 Web 站点以导航到您的音乐库
- 介绍ASP.NET 2.0 Web Parts框架
- 使用 Web 标准生成 ASP.NET 2.0 Web 站点
- 使用 Web 标准生成 ASP.NET 2.0 Web 站点
- [ASP] asp.net 2.0 中使用web.config存储数据库连接字符串
- Web Application 项目中使用ASP.NET 2.0 Profile
- Asp.net 2.0 - Web Parts学习笔记