-
How to get the current selected advertisement details of AdRotator - in a derived class
Hi all,
Iam in the process of developing a website using ASP.NET, I would
like to use all image based, flash based and applet based ads in his site.
I would like to override the AdRotator component so that the derived class
handles the special cases (flash and applet) but leaves the image ads to the
base class. I couldnt figure out how to get the "current selected
advertisement" selected by the AdRotator from the Advertisement file (so
that i can look for the ad's file extension and do the rendering). If anyone
can help me with this it will be really helpfull to me. Thanking you in
advance.
CreProDes
-
Re: How to get the current selected advertisement details of AdRotator - in a derived class
Hi CreProDes,
"CreProDes" <creprodes@hotmail.com> wrote in message news:3d56224a@10.1.10.29...
> Iam in the process of developing a website using ASP.NET, I would
> like to use all image based, flash based and applet based ads in his site.
> I would like to override the AdRotator component so that the derived class
> handles the special cases (flash and applet) but leaves the image ads to the
> base class. I couldnt figure out how to get the "current selected
> advertisement" selected by the AdRotator from the Advertisement file (so
> that i can look for the ad's file extension and do the rendering). If anyone
> can help me with this it will be really helpfull to me. Thanking you in
> advance.
Interesting. We do an example for our book (see link in signature, below) that
substitutes text-only graphic ads when requested. There's a good marketing sales
point for offering text-based ads: Because they won’t be blocked by ad blocking
software, they should get seen more often--resulting in higher click-through
payments for the site.
We don't do the substitution through a derived class. Instead, we just
temporarily hide the AdRotator control and show a hyperlink control that uses
the content from ad randomly selected by the AdRotator.
The AdRotator control’s AdCreated event fires with each round trip to the
server, after ASP.Net creates the control and before it renders the page. If the
AdvertisementFile property is set, this event occurs following the selection of
a new random banner ad from the file.
Here's the code, which should help you see how to get the currently selected Ad
info:
Private mHideGraphicBanner As Boolean = False
Private Sub Page_Load(ByVal sender As System.Object,_
ByVal e As System.EventArgs)Handles MyBase.Load
'Make sure graphic banner is visible,at least temporarily,
'to force AdCreated event to be triggered every time.
adrGraphicBanner.Visible = True
End Sub
Private Sub adrGraphicBanner_AdCreated(ByVal sender As System.Object,_
ByVal e As System.Web.UI.WebControls.AdCreatedEventArgs)_
Handles adrGraphicBanner.AdCreated
If mHideGraphicBanner Then
'Set Values for and show text banner.
lnkTextBanner.Text = e.AlternateText
lnkTextBanner.NavigateUrl = e.NavigateUrl
lnkTextBanner.Visible = True
adrGraphicBanner.Visible = False
Else
'Show graphic banner.
lnkTextBanner.Visible = False
adrGraphicBanner.Visible = True
End If
'Show optional information about ad sponsor
If CStr(e.AdProperties("Sponsor"))= ""Then
lblSponsor.Visible = False
Else
lblSponsor.Text = "<br/>Sponsored by:<i>"_
&CStr(e.AdProperties("Sponsor"))&"</i>"
lblSponsor.Visible = True
End If
End Sub
Private Sub btnGraphic_Click(ByVal sender As System.Object,_
ByVal e As System.EventArgs)_
Handles btnGraphic.Click,btnText.Click
'Set module level flag to indicate which banner (graphic or text)
'should be displayed by AdCreated event.
Select Case CType(sender,Button).ID
Case "btnGraphic"
mHideGraphicBanner = False
Case "btnText"
mHideGraphicBanner = True
Case Else
'No Change
End Select
End Sub
Hope this helps!
--
Constance Petersen, DevX newsgroup section leader
New look; new content: http://www.smartisans.com/
Hot off the press!
"Programming the Web with Visual Basic .NET"
http://www.bookpool.com/.x/rbaabchtd6/sm/1590590279
--
Please reply in the newsgroup so everyone can benefit
-
Re: How to get the current selected advertisement details of AdRotator - in a derived class
Hi Pete,
Thank you very much for the event handling idea. I have a big
problem at hand, actually the whole project is done in code behind (because
we are using a lot of custom server components and we basically are coders
than designers we thought that would be a good idea). Now since we are doing
everything as pagelets and custom server controls, we also decided to
overload the adrotator for our needs. It would be very helpfull if you can
provide a way to extract the currently selected items details from a adrot
or an abstract idea of accomplishing the same. Again thank you very much for
the reply.
CreProDes
"Constance J. Petersen" <constance@smartisans.com> wrote in message
news:3d568971@10.1.10.29...
> Hi CreProDes,
>
> "CreProDes" <creprodes@hotmail.com> wrote in message
news:3d56224a@10.1.10.29...
> > Iam in the process of developing a website using ASP.NET, I
would
> > like to use all image based, flash based and applet based ads in his
site.
> > I would like to override the AdRotator component so that the derived
class
> > handles the special cases (flash and applet) but leaves the image ads to
the
> > base class. I couldnt figure out how to get the "current selected
> > advertisement" selected by the AdRotator from the Advertisement file (so
> > that i can look for the ad's file extension and do the rendering). If
anyone
> > can help me with this it will be really helpfull to me. Thanking you in
> > advance.
>
> Interesting. We do an example for our book (see link in signature, below)
that
> substitutes text-only graphic ads when requested. There's a good marketing
sales
> point for offering text-based ads: Because they won't be blocked by ad
blocking
> software, they should get seen more often--resulting in higher
click-through
> payments for the site.
>
> We don't do the substitution through a derived class. Instead, we just
> temporarily hide the AdRotator control and show a hyperlink control that
uses
> the content from ad randomly selected by the AdRotator.
>
> The AdRotator control's AdCreated event fires with each round trip to the
> server, after ASP.Net creates the control and before it renders the page.
If the
> AdvertisementFile property is set, this event occurs following the
selection of
> a new random banner ad from the file.
>
> Here's the code, which should help you see how to get the currently
selected Ad
> info:
>
> Private mHideGraphicBanner As Boolean = False
>
> Private Sub Page_Load(ByVal sender As System.Object,_
> ByVal e As System.EventArgs)Handles MyBase.Load
> 'Make sure graphic banner is visible,at least temporarily,
> 'to force AdCreated event to be triggered every time.
> adrGraphicBanner.Visible = True
> End Sub
>
> Private Sub adrGraphicBanner_AdCreated(ByVal sender As System.Object,_
> ByVal e As System.Web.UI.WebControls.AdCreatedEventArgs)_
> Handles adrGraphicBanner.AdCreated
> If mHideGraphicBanner Then
> 'Set Values for and show text banner.
> lnkTextBanner.Text = e.AlternateText
> lnkTextBanner.NavigateUrl = e.NavigateUrl
> lnkTextBanner.Visible = True
> adrGraphicBanner.Visible = False
> Else
> 'Show graphic banner.
> lnkTextBanner.Visible = False
> adrGraphicBanner.Visible = True
> End If
> 'Show optional information about ad sponsor
> If CStr(e.AdProperties("Sponsor"))= ""Then
> lblSponsor.Visible = False
> Else
> lblSponsor.Text = "<br/>Sponsored by:<i>"_
> &CStr(e.AdProperties("Sponsor"))&"</i>"
> lblSponsor.Visible = True
> End If
> End Sub
>
> Private Sub btnGraphic_Click(ByVal sender As System.Object,_
> ByVal e As System.EventArgs)_
> Handles btnGraphic.Click,btnText.Click
> 'Set module level flag to indicate which banner (graphic or text)
> 'should be displayed by AdCreated event.
> Select Case CType(sender,Button).ID
> Case "btnGraphic"
> mHideGraphicBanner = False
> Case "btnText"
> mHideGraphicBanner = True
> Case Else
> 'No Change
> End Select
> End Sub
>
> Hope this helps!
>
> --
> Constance Petersen, DevX newsgroup section leader
> New look; new content: http://www.smartisans.com/
> Hot off the press!
> "Programming the Web with Visual Basic .NET"
> http://www.bookpool.com/.x/rbaabchtd6/sm/1590590279
> --
> Please reply in the newsgroup so everyone can benefit
>
>
-
Re: How to get the current selected advertisement details of AdRotator - in a derived class
"CreProDes" <creprodes@hotmail.com> wrote in message news:3d5744bb@10.1.10.29...
> It would be very helpfull if you can
> provide a way to extract the currently selected items details from a adrot
> or an abstract idea of accomplishing the same.
Check the documentation for the public AdRotator.AdCreated event. It receives
AdCreatedEventArgs, which contains the currently selected ad's properties.
Note e in the code I showed you in the previous message:
Private Sub adrGraphicBanner_AdCreated(ByVal sender As System.Object,_
ByVal e As System.Web.UI.WebControls.AdCreatedEventArgs)_
Handles adrGraphicBanner.AdCreated
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks