本文整理汇总了VB.NET中System.Web.UI.WebControls.AdRotator.Render方法的典型用法代码示例。如果您正苦于以下问题:VB.NET AdRotator.Render方法的具体用法?VB.NET AdRotator.Render怎么用?VB.NET AdRotator.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了AdRotator.Render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Render
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomADRotatorRender
Inherits System.Web.UI.WebControls.AdRotator
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
Dim navigateUrl As String = System.String.Empty
Dim imageUrl As String = System.String.Empty
Dim alternateText As String = System.String.Empty
' If the value for the Advertisement File is not empty.
If Me.AdvertisementFile.Length > 0 Then
' Get a random ad.
GetRandomAd(imageUrl, navigateUrl, alternateText)
End If
' Create and render a new HyperLink Web control.
Dim bannerLink As New System.Web.UI.WebControls.HyperLink
Dim key As String
For Each key In Me.Attributes.Keys
bannerLink.Attributes(key) = Me.Attributes(key)
Next key
If Not (Me.ID Is Nothing) AndAlso Me.ID.Length > 0 Then
bannerLink.ID = Me.ClientID
End If
bannerLink.NavigateUrl = navigateUrl
bannerLink.Target = Me.Target
bannerLink.AccessKey = Me.AccessKey
bannerLink.Enabled = Me.Enabled
bannerLink.TabIndex = Me.TabIndex
bannerLink.RenderBeginTag(writer)
' Create and render a new Image Web control.
Dim bannerImage As New System.Web.UI.WebControls.Image
If ControlStyleCreated Then
bannerImage.ApplyStyle(Me.ControlStyle)
End If
bannerImage.AlternateText = alternateText
bannerImage.ImageUrl = imageUrl
bannerImage.ToolTip = Me.ToolTip
bannerImage.RenderControl(writer)
bannerLink.RenderEndTag(writer)
End Sub
Private Sub GetRandomAd(ByRef imageUrl As String, ByRef navigateUrl As String, ByRef alternateText As String)
' Default output parameters values to empty string
imageUrl = System.String.Empty
navigateUrl = System.String.Empty
alternateText = System.String.Empty
' Get the Ads from an XML file.
Dim dataSet As New System.Data.DataSet
Dim physicalPath As String = MapPathSecure(Me.AdvertisementFile)
dataSet.ReadXml(physicalPath, System.Data.XmlReadMode.InferSchema)
' If Ads were found in the XML File.
Dim totalAds As Integer = dataSet.Tables(0).Rows.Count
If totalAds > 0 Then
' Select a random Ad.
Dim randomNumber As New System.Random
Dim selectedAdIndex As Integer = randomNumber.Next(totalAds)
' Output the random Ad's values.
imageUrl = dataSet.Tables(0).Rows(selectedAdIndex).ItemArray(0).ToString()
navigateUrl = dataSet.Tables(0).Rows(selectedAdIndex).ItemArray(1).ToString()
alternateText = dataSet.Tables(0).Rows(selectedAdIndex).ItemArray(2).ToString()
End If
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System.Web.UI.WebControls,代码行数:69,代码来源:AdRotator.Render
注:本文中的System.Web.UI.WebControls.AdRotator.Render方法示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论