ASP.NET

1. ASP.NET Introduction 2. Comp of .Net Framework 3.5 3. Sys.Req for VS 2008 4. ASP.NET Envrmnt Setup 5. VS2010 Ultimate Sys.Req 6. Installing VS 2010 7. VS 2012 Sys.Req 8. Installing VS Exp 2012 9. Start the VS 2008 10. Application Life Cycle 11. Page Life Cycle 12. Page Life Cycle Events 13. ASP.NET Example 14. Event Handling 15. Default Events 16. Server Side 17. Request Object 18. Response Object 19. Server Controls 20. Server Controls Properties 21. Server Controls Methods 22. HTML Server Controls 23. Client Side 24. ASP.NET Basic Controls 25. TextBox Control 26. CheckBox Controls 27. RadioButton Controls 28. ListBox Control 29. HyperLink Control 30. Image Control 31. BulletedList Control 32. ASP.NET Directives 33. Implements Directive 34. Master Type Directive 35. Page Directive 36. PreviousPage Type 37. Managing State 38. Control State 39. Cookies 40. Query Strings 41. Server-Side State 42. Session State 43. Validation Controls 44. Required FieldValidator 45. Range Validator 46. Compare Validator 47. RegularExpressionValidator 48. Custom Validator 49. Validation Summary 50. Data Source Control 51. AdRotator Control 52. Calendar Control 53. Calendar Control Example 54. Panel Control 55. Panel Control Example 56. Multi Views Control 57. MultiView & View controls 58. MultiView Control Example 59. FileUpload Control 60. FileUpload Control Eg 61. AJAX Control 62. UpdatePanel control 63. UpdateProgress Control 64. Custom Controls 65. Custom Control Eg 66. Personalization 67. Create Simple Profile 68. ADO.NET 69. ADO.NET Objects 70. DataTable 71. DataRow 72. DataColumn 73. Object Example 74. Error Handling 75. Tracing Errors 76. Debugger 77. Security 78. Authentication 79. Authorization 80. LINQ 81. LINQ Query Operators 82. LINQ Example 83. Caching 84. Data Caching 85. Output Caching 86. Object Caching 87. Web Services 88. Create Web Services Eg 89. Web & Machine.config 90. Settings Schema 91. ASP.NET Deployment 92. XCopy Deployment 93. Web Setup Project 94. ASP Interview Part 1 95. ASP Interview Part 2 96. ASP Interview Part 3 97. ASP Interview Part 4 98. ASP Interview Part 5 99. ASP Interview Part 6
Pr.Pg Next Pg

ASP.NET AdRotator Control tutorials

  • The AdRotator control is used to displays an randomly selected advertisement banner on the Web page. The displayed advertisement changes whenever the page refreshes.

  • Advertisement information is stored in a separate XML file. The XML file allows you to maintain a list of advertisements and their associated attributes. Attributes include the path to an image to display, the URL to link to when the control is clicked, the alternate text to display when the image is not available, a keyword, and the frequency of the advertisement. Information in this file is not validated by the AdRotator control.

 

Syntax:

The syntax of AdRotator control is:

<asp:AdRotator AdvertisementFile="url"  AlternateTextField="string" ID="string" ImageUrlField="string"

runat="server"  Target="string|_blank|_parent|_search|_self|_top"  />

 

The Advertisement File:

  • The AdRotatorcontrol uses a separate XML advertisement file to store the advertisement information, such as the location of the image to display and the URL of the page to link to

  • Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. XML is designed to transport and store data.

  • The AdvertisementFile property of the AdRotator control specifies the path to this file.

  • The following table lists the data elements that are predefined for the XML advertisement file.

 

Element

Description

AlternateText

Optional, the text display in place of the image when the image specified by the ImageUrl property is not available

In some browsers, this text also appears as a ToolTip for the advertisement.

Height

The height of the image to be displayed in pixels (optional)

Impressions

A number that indicates the importance of the ad in the schedule of rotation relative to the other ads in the file (optional)

Keyword

Optional, A category for the advertisement

ImageUrl

Optional, Specifies the absolute or relative URL to an image file.

NavigateUrl

Optional, The URL of a page to link to if the user clicks the ad.

Width

The width of the image to be displayed in pixels (optional)

 

  • The properties of the AdRotator class:

  • The below tables shows the list of properties of the AdRotator class:

 

Properties

Description

AdvertisementFile

Sets the path to the XML file that contains advertisement information

AlternateTextField

Sets a data field to use in place of the AlternateText attribute for an advertisement.

DataSourceID

The control Id for retrieves the data.

ImageUrlField

Sets a data field for an advertisement

KeywordFilter

Filter the category keyword for specific types of advertisements in the XML advertisement file.

NavigateUrlField

Specifies a data field to be used instead of the NavigateUrl attribute for an advertisement.

Target

Specify the name of the browser window or frame that displays the contents of the Web page linked to when the AdRotator control is clicked by the user.

ToolTip

Specify the text displayed when the mouse pointer hovers over the Web server control.

 

Example:

Adrotatorfile.xml file code:

 

Following example shows the use of ASP.NET AdRotator Control (XML file):

Sam Sir

 

<?xml version="1.0" encoding="utf-8" ?>

<Advertisements>

<Ad>

<ImageUrl>~/Images/googleimg.jpg</ImageUrl>

<NavigateUrl>http://www.google.com</NavigateUrl>

<AlternateText>Adrotatorexample</AlternateText>

<Impressions>100</Impressions>

<Keyword>Header</Keyword>

<Category>Script</Category>

</Ad>

<Ad>

<ImageUrl>~/Images/twitterimg.jpg</ImageUrl>

<NavigateUrl>http://www.twitter.com/</NavigateUrl>

<AlternateText>Adrotatorexample</AlternateText>

<Impressions>100</Impressions>

<Keyword>Header</Keyword>

<Category>Script</Category>

</Ad>

<Ad>

<ImageUrl>~/Images/yahooimg.jpg</ImageUrl>

<NavigateUrl>http://www.yahoo.com</NavigateUrl>

<AlternateText>Adrotatorexample</AlternateText>

<Impressions>100</Impressions>

<Keyword>Header</Keyword>

<Category>Script</Category>

</Ad>

</Advertisements>

 

 

AdrotatorControlExample.aspx.cs Code:


 

Following example shows the use of ASP.NET AdRotator Control:

Sam Sir

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

public partial class AdrotatorControlExample : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

 

}

}

 

 

 

AdrotatorControlExample.aspx Code:

 

 

Following example shows the use of ASP.NET AdRotator Control:

Sam Sir

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdrotatorControlExample.aspx.cs" Inherits="AdrotatorControlExample" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>cbtSAM ASP.NET AdRotator Control Example</title>

</head>

<body>

<form id="form1" runat="server">

<div>

Adrotator Example<br />

<br />

<asp:AdRotator ID="AdRotator1" runat="server"

Target="_blank" AdvertisementFile="~/Adrotatorfile.xml" />

</div>

</form>

</body>

</html>

Output

 

 

adrotator example

After refreshing the page:

adrotator example

 

Pr.Pg border                                              Next Pg