Adrotator绑定数据库
AdRotator 经常看到的用法是绑定在XML文件上,网上很少有绑定数据库的例子。不过没有关系,AdRotator有DataSourceID属性,也就是跟GridView一样,都可以绑定数据库。
参考文章:
ASP.NET2.0广告管理和显示控件Adrotator的使用
Working around some ASP.NET AdRotator limitations
<%@ control language="VB" classname="Advertisement"%>
<script runat="server">
Private Sub shopAds_AdCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AdCreatedEventArgs)
e.NavigateUrl = "~/Shop.aspx?ProductID=" & e.AdProperties("ProductID")
description.Text = e.AdProperties("Description")
price.Text = e.AdProperties("Price")
End Sub
</script>
<table>
<tr>
<td>
<asp:AdRotator ID="shopAds" Runat="server" DataSourceID="advertisementData" ImageUrlField="ImageUri" OnAdCreated="shopAds_AdCreated" />
</td>
<td>
<asp:Label ID="description" Runat="Server" />
<br />
<asp:Label ID="price" Runat="Server" />
</td>
</tr>
</table>
<asp:ObjectDataSource ID="advertisementData" Runat="server" TypeName="WeFly247.UI.Proxies.PassengerWebService" SelectMethod="GetProducts">
<SelectParameters>
<asp:ProfileParameter Name="cultureName" Type="String" PropertyName="Culture" />
</SelectParameters>
</asp:ObjectDataSource>
<script runat="server">
Private Sub shopAds_AdCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AdCreatedEventArgs)
e.NavigateUrl = "~/Shop.aspx?ProductID=" & e.AdProperties("ProductID")
description.Text = e.AdProperties("Description")
price.Text = e.AdProperties("Price")
End Sub
</script>
<table>
<tr>
<td>
<asp:AdRotator ID="shopAds" Runat="server" DataSourceID="advertisementData" ImageUrlField="ImageUri" OnAdCreated="shopAds_AdCreated" />
</td>
<td>
<asp:Label ID="description" Runat="Server" />
<br />
<asp:Label ID="price" Runat="Server" />
</td>
</tr>
</table>
<asp:ObjectDataSource ID="advertisementData" Runat="server" TypeName="WeFly247.UI.Proxies.PassengerWebService" SelectMethod="GetProducts">
<SelectParameters>
<asp:ProfileParameter Name="cultureName" Type="String" PropertyName="Culture" />
</SelectParameters>
</asp:ObjectDataSource>
参考文章:
ASP.NET2.0广告管理和显示控件Adrotator的使用
Working around some ASP.NET AdRotator limitations
浙公网安备 33010602011771号