Forum Themes:
Welcome !

 Showing ads (eg. Google Adsense) after the first post in a thread

Author Message
Samuel

  • Total Posts : 11853
  • Reward points : 180670
  • Joined: May 23 '01
  • Status: offline
Showing ads (eg. Google Adsense) after the first post in a thread Wed. Oct 29, '08 12:04 PM (permalink)
Sometimes you want to show something only (announcement or ads) to guests, and want it to appear inside a message thread. Usually the place between the first and second messages is a good choice.

What you would want to do is to add the following to the end of ~/App_Templates/Theme_Name/UC/MessageDisplay/ItemTemplate.ascx:

<asp:literal ID="txtforguest" runat="server"    
     visible='<%# (CInt(Context.Items("msgListcount")) = 1 AndAlso MemberInfo.IsGuest) %>'>   
 <div class="item">test test</div></asp:literal>


Notice that I wrap "test test" with a <div class="item">. This is only needed if you use our default theme as I wrap the entire message area with a special style. Without this div the "test test" line will not look good.

Of course, you can change it entirely to show dynamic text (server side VB code or client side javascript) or add a different server control altogether.

This is also a good place for Google Adsense.

The most important thing is the "visible" attribute of the server control:

CInt(Context.Items("msgListcount")) = 1 : this portion tells the ASP.NET engine to only show the server control after the first post

MemberInfo.IsGuest : this portion tells the ASP.NET engine to show the server control only to guests (who are not logged in)
<message edited by Samuel on Thu. May 12, '11 9:46 AM>
ASPPlayground.NET
~ see our Version 4 plans here

 
#1
    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9