Thursday, September 15, 2011

Add Rotator Control In Asp.Net



How to use add rotator
protected System.Web.UI.WebControls.AdRotator AdRotator;
protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;

Namespaces used in this application:

using System.Web.UI.WebControls;
using System.Drawing;
using System.Web.UI.HtmlControls;

Add a Xml File
// XML CODE THAT AS THE DETAILS ABOUT THE ADS
<Advertisements>
    <Ad>
        <ImageUrl>D:\Viv_B-Practice\AdRotator_VT\www.asp.net.gif</ImageUrl>
        <NavigateUrl>http://www.asp.net</NavigateUrl>
        <AlternateText>ASP.NET Logo</AlternateText>
        <Keyword>A</Keyword>
        <Impressions>Technology</Impressions>
        <Caption>This is the caption for Ad#1</Caption>
    </Ad>

    <Ad>
        <ImageUrl>D:\Viv_B-Practice\AdRotator_VT\www.sulekha.com.gif</ImageUrl>
        <NavigateUrl>http://www.sulekha.net</NavigateUrl>
        <AlternateText>www.Sulekha.net</AlternateText>
        <Keyword>S</Keyword>
        <Impressions>Web Site</Impressions>
        <Caption>This is the caption for Ad#2</Caption>
    </Ad>

    <Ad>
        <ImageUrl>D:\Viv_B-Practice\AdRotator_VT\FlashFile.swf</ImageUrl>
        <NavigateUrl>AdRotator.aspx?ad=Widgets
               &target=http://msdn.microsoft.com/widgets/</NavigateUrl>
        <AlternateText>www.neostream.net</AlternateText>
        <Keyword>S</Keyword>
        <Impressions>Flash Site</Impressions>
        <Caption>This is the caption for Ad#2</Caption>
    </Ad>
</Advertisements>

The above shown is the XML code. The above XML template contains the details about each ad that is going to be placed in the web application. You can create an ad list for the AdRotator control in the XML designer using the Ad Rotator Schedule File as the target schema.

The AdRotator Properties

ImageUrl - The URL of the image to display.
NavigateUrl - The URL of the page to navigate to when the AdRotator control is clicked.
AlternateText - The text to display if the image is unavailable.
Keyword - The category of the ad that can be used to filter for specific ads.
Impressions - A numeric value that indicates the likelihood of how often the ad is displayed. The total of all impression values in the XML file may not exceed 2,048,000,000 - 1. All attributes are optional.

The AdRotator Class

Basically, the actual AdRotator class only provides a limited set of properties:

<asp:AdRotator id="controlName" runat="server"
    AdvertisementFile="ads.xml" Target="_self">
</asp:AdRotator>

Here we can see how a placeholder control creates the ad rotator control at runtime dynamically and how it works. The PlaceHolder control enables you to place an empty container control in the page and then dynamically add child elements to it at run time.

// Create an AdRotator control.

AdRotator rotator = new AdRotator();

// Set the control's properties.

rotator.AdvertisementFile = "AdRotatorFiles.xml";

// Add the control to the Controls collection of a

// PlaceHolder control. 

PlaceHolder1.Controls.Add(rotator);

The PlaceHolder web server control enables you to place an empty container control within the page and then dynamically add, remove, or loop through child elements at run time. The control only renders its child elements; it has no HTML-based output of its own. As an example, you might want to have a variable number of buttons appear on a web page, depending on options selected by users. That way, users are not confronted with potentially confusing choices that are either unavailable or not relevant to their individual needs.


AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...