SlideShare a Scribd company logo
ASP.NET AdRotator Control
Definition and Usage 
The AdRotator control is used to display a sequence of ad 
images. 
This control uses an XML file to store the ad information. 
The XML file must begin and end with an 
<Advertisements> tag. Inside the <Advertisements> tag 
there may be several <Ad> tags which defines each ad. 
The AdRotator Control presents ad images each time a user enters or refreshes a webpage. 
When the ads are clicked, it will navigate to a new Web location. Each time the page is loaded 
into the browser, an ad is randomly selected from a predefined list. Previously the predefined 
list means an XML File, which contains the information about the ads to be displayed. But in 
Asp.Net 2.0 we can maintain the list in any data source. In this article, we explained the 
AdRotator control to fetch ads information from both database and XML file, and display those 
ads in randomly with the help of Timer control. You can say it as an AJAX AdRotator Control.
The predefined elements inside the <Ad> tag are listed 
below: 
Element Description 
<ImageUrl> 
Optional. The path to the 
image file 
<NavigateUrl> 
Optional. The URL to link 
to if the user clicks the ad 
<AlternateText> 
Optional. An alternate text 
for the image 
<Keyword> 
Optional. A category for 
the ad 
<Impressions> 
Optional. The display rates 
in percent of the hits
Properties 
Property Description 
. 
N 
E 
T 
AdvertisementFile 
Specifies the path to the XML file 
that contains ad information 
1 
. 
0 
AlternateTextField 
Specifies a data field to be used 
instead of the Alt text for an ad 
2 
. 
0 
ImageUrlField 
Specifies a data field to be used 
instead of the ImageURL 
attribute for an ad 
2 
. 
0 
KeywordFilter 
Specifies a filter to limit ads after 
categories 
1 
. 
0 
NavigateUrlField 
Specifies a data field to be used 
instead of the NavigateUrl 
attribute for an ad 
2 
. 
0 
runat 
Specifies that the control is a 
server control. Must be set to 
"server" 
1 
. 
0 
Target Specifies where to open the URL 
1 
. 
0
5 
Outline 
FlagRotator.aspx 
(3 of 3 ) 
AdRotator image 
Fig. | Web Form that demonstrates the AdRotator 
web control. (Part 3 of 3. ) 
a) 
AlternateText 
displayed in a tool tip 
c) 
b) 
Add an AdRotator control named 
countryRotator. 
Add a XmlDataSource control, which 
supplies the data to the AdRotator 
control. 
Figure (a) shows the first time the page is 
requested, when the Swedish flag is 
randomly chosen. 
In the second request, as shown in Figure 
(b), the French flag is displayed. 
Figure (c) depicts the web page that loads 
when you click the French flag.
AdRotator Example: FlagRotator 
Connecting Data to an AdRotator Control 
• An XmlDataSource references an XML file containing data that will 
be used in an ASP.NET application. 
• To build this example, we first add the XML file 
AdRotatorInformation.xml to the project. 
• Right click the App_Data folder in the Solution Explorer and select 
Add Existing Item…. 
• Next, drag an AdRotator control from the Toolbox to the Web 
Form.
AdRotator Example: FlagRotator 
• From the smart-tag menu, select <New Data Source…> from the 
Choose Data Source drop-down list to start the Data Source 
Configuration Wizard. 
• Select XML File as the data-source type. Set the ID of the control 
to adXmlDataSource. 
• In the next dialog’s Data File section, click Browse… and, in the 
Select XML File dialog, locate and select the XML file you added 
to the App_Data folder.
Examining an XML File Containing Advertisement 
Information 
Any XML document used with an AdRotator control—must contain one 
Advertisements root element. 
Within that element can be as many Ad elements as you need. Each Ad element is 
similar to the following: 
<Ad> 
<ImageUrl>Images/france.png</ImageUrl> 
<NavigateUrl>https://www.cia.gov/library/publications/ 
the-world-factbook/geos/fr.html 
</NavigateUrl> 
<AlternateText>France Information</AlternateText> 
<Impressions>1</Impressions> 
</Ad>
Element ImageUrl specifies the path (location) of the 
advertisement’s image. 
Element NavigateUrl specifies the URL for the web 
page that loads when a user clicks the advertisement. 
The AlternateText element nested in each Ad element 
contains text that displays in place of the image when the 
browser cannot display the image. 
The Impressions element specifies how often a 
particular image appears, relative to the other images. In 
our example, the advertisements display with equal 
probability, because the value of each Impressions 
element is set to 1.
ASP.NET Repeater Control
Data Controls 
ASP.NET comes with two sets of data-aware controls: 
the data-bound and the data source controls. 
Data-bound controls 
These are used to display and edit data. The 
GridView, DataList, ListView, and 
Repeater are all able to display multiple records 
at the same time, whereas the DetailsView and 
the FormView are designed to show a single record 
at a time. The DataPager is used to provide 
paging capabilities to the ListView controls.
Definition and Usage 
 Repeater – It gives you the greatest flexibility in terms 
of the HTML that you output to the browser as the 
control by itself does not add any HTML to the page 
output. The control has no built-in capabilities for the 
paging, sorting and modification of data. It is often used 
when you need precise control over the markup that is 
generated by the control. As such, it’s often used for 
HTML ordered or unordered lists (<ol> and <ul>), etc.
Repeater has 5 inline template to format it: 
1. <HeaderTemplate> 
2. <FooterTemplate> 
3. <ItemTemplate> 
4. <AlternatingItemTemplate> 
5. <SeperatorTemplate> 
6. <AlternatingItemTemplate> 
HeaderTemplate: This template is used for elements that you want to render once before your 
ItemTemplate section. 
FooterTemplate: - This template is used for elements that you want to render once after your 
ItemTemplate section. 
ItemTemplate: This template is used for elements that are rendered once per row of data. It is used to 
display records 
AlternatingItemTemplate: This template is used for elements that are rendered every second row of 
data. This allows you to alternate background colors. It works on even number of records only. 
SeperatorTemplate: It is used for elements to render between each row, such as line breaks.
How to use a Repeater Control? 
Create a new website with name RepeaterControl 
Double click the web.config file and write following code in it:
<connectionStrings> 
<add name="constr" connectionString="initial catalog=puran; data 
source=MCN002; integrated security=sspi"/> 
</connectionStrings> 
Default.aspx file code 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" 
%> 
<!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"> 
<link rel="Stylesheet" type="text/css" href="StyleSheet.css" /> 
<title>Repeater Controls in ASP.NET</title> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div> 
<asp:Repeater ID="RepeatInformation" runat="server"> 
<HeaderTemplate> 
<table class="tblcolor">
<tr> 
<b> 
<td> 
Roll No 
</td> 
<td> 
Student Name 
</td> 
<td> 
Total Fees 
</td> 
</b> 
</tr> 
</HeaderTemplate> 
<ItemTemplate> 
<tr class="tblrowcolor"> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.RollNo")%> 
</td> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.Name")%> 
</td> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.Fees")%> 
</td> 
</tr> 
</ItemTemplate> 
<SeparatorTemplate>
<hr /> 
</td> 
</tr> 
</SeparatorTemplate> 
<AlternatingItemTemplate> 
<tr> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.RollNo")%> 
</td> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.Name")%> 
</td> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.Fees")%> 
</td> 
</tr> 
</AlternatingItemTemplate> 
<SeparatorTemplate> 
<tr> 
<td> 
<hr /> 
</td> 
<td> 
<hr /> 
</td> 
<td> 
<hr /> 
</td> 
</tr> 
</SeparatorTemplate> 
<FooterTemplate> 
<tr> 
<td>
Code behind file code 
using System; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml.Linq; 
using System.Data.SqlClient; 
public partial class _Default : System.Web.UI.Page 
{ 
SqlConnection con; 
SqlCommand cmd = new SqlCommand(); 
protected void Page_Load(object sender, EventArgs e) 
{ 
con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString); 
cmd.Connection = con; 
cmd.CommandText = "select * from student"; 
con.Open(); 
RepeatInformation.DataSource = cmd.ExecuteReader(); 
RepeatInformation.DataBind(); 
con.Close(); 
} 
}
Thanvi

More Related Content

What's hot (20)

Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controls
 
User controls
User controlsUser controls
User controls
 
VB.Net-Controls and events
VB.Net-Controls and eventsVB.Net-Controls and events
VB.Net-Controls and events
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
Css lecture notes
Css lecture notesCss lecture notes
Css lecture notes
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
ASP.NET 10 - Data Controls
ASP.NET 10 - Data ControlsASP.NET 10 - Data Controls
ASP.NET 10 - Data Controls
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Xml http request
Xml http requestXml http request
Xml http request
 
Server Controls of ASP.Net
Server Controls of ASP.NetServer Controls of ASP.Net
Server Controls of ASP.Net
 
JavaScript - Chapter 1 - Problem Solving
 JavaScript - Chapter 1 - Problem Solving JavaScript - Chapter 1 - Problem Solving
JavaScript - Chapter 1 - Problem Solving
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Data controls ppt
Data controls pptData controls ppt
Data controls ppt
 
Aspnet Caching
Aspnet CachingAspnet Caching
Aspnet Caching
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
 
Css notes
Css notesCss notes
Css notes
 
Python GUI Programming
Python GUI ProgrammingPython GUI Programming
Python GUI Programming
 
Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web Application
 

Viewers also liked

ASP.net Image Slideshow
ASP.net Image SlideshowASP.net Image Slideshow
ASP.net Image SlideshowHock Leng PUAH
 
Adrotator in asp
Adrotator in aspAdrotator in asp
Adrotator in aspSireesh K
 
Asp.Net The Data List Control
Asp.Net   The Data List ControlAsp.Net   The Data List Control
Asp.Net The Data List ControlRam Sagar Mourya
 
Session 7 : jstl - Giáo trình Bách Khoa Aptech
Session 7 : jstl  - Giáo trình Bách Khoa AptechSession 7 : jstl  - Giáo trình Bách Khoa Aptech
Session 7 : jstl - Giáo trình Bách Khoa AptechMasterCode.vn
 
RichControl in Asp.net
RichControl in Asp.netRichControl in Asp.net
RichControl in Asp.netBhumivaghasiya
 

Viewers also liked (6)

ASP.net Image Slideshow
ASP.net Image SlideshowASP.net Image Slideshow
ASP.net Image Slideshow
 
Adrotator in asp
Adrotator in aspAdrotator in asp
Adrotator in asp
 
Jstl &amp; El
Jstl &amp; ElJstl &amp; El
Jstl &amp; El
 
Asp.Net The Data List Control
Asp.Net   The Data List ControlAsp.Net   The Data List Control
Asp.Net The Data List Control
 
Session 7 : jstl - Giáo trình Bách Khoa Aptech
Session 7 : jstl  - Giáo trình Bách Khoa AptechSession 7 : jstl  - Giáo trình Bách Khoa Aptech
Session 7 : jstl - Giáo trình Bách Khoa Aptech
 
RichControl in Asp.net
RichControl in Asp.netRichControl in Asp.net
RichControl in Asp.net
 

Similar to AdRotator and AdRepeater Control in Asp.Net for Msc CS

The ActionScript Conference 08, Singapore - Developing ActionScript 3 Mash up...
The ActionScript Conference 08, Singapore - Developing ActionScript 3 Mash up...The ActionScript Conference 08, Singapore - Developing ActionScript 3 Mash up...
The ActionScript Conference 08, Singapore - Developing ActionScript 3 Mash up...marcocasario
 
Overview of MVC Framework - by software outsourcing company india
Overview of MVC Framework - by software outsourcing company indiaOverview of MVC Framework - by software outsourcing company india
Overview of MVC Framework - by software outsourcing company indiaJignesh Aakoliya
 
ASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsRandy Connolly
 
GAC Java Presentation_Server Side Include_Cookies_Filters 2022.ppt
GAC Java Presentation_Server Side Include_Cookies_Filters 2022.pptGAC Java Presentation_Server Side Include_Cookies_Filters 2022.ppt
GAC Java Presentation_Server Side Include_Cookies_Filters 2022.pptCUO VEERANAN VEERANAN
 
331592291-HTML-and-Cascading style sheet
331592291-HTML-and-Cascading style sheet331592291-HTML-and-Cascading style sheet
331592291-HTML-and-Cascading style sheetstephen972973
 
ASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server ControlsASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server ControlsRandy Connolly
 
OBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - TutorialOBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - Tutorialonlinetrainingplacements
 
Detail view in distributed technologies
Detail view in distributed technologiesDetail view in distributed technologies
Detail view in distributed technologiesjamessakila
 
Selectionwidgetwhitepaper 140907120000-phpapp02
Selectionwidgetwhitepaper 140907120000-phpapp02Selectionwidgetwhitepaper 140907120000-phpapp02
Selectionwidgetwhitepaper 140907120000-phpapp02Nigel Abbott
 
DHTML - Dynamic HTML
DHTML - Dynamic HTMLDHTML - Dynamic HTML
DHTML - Dynamic HTMLReem Alattas
 

Similar to AdRotator and AdRepeater Control in Asp.Net for Msc CS (20)

Managing states
Managing statesManaging states
Managing states
 
The ActionScript Conference 08, Singapore - Developing ActionScript 3 Mash up...
The ActionScript Conference 08, Singapore - Developing ActionScript 3 Mash up...The ActionScript Conference 08, Singapore - Developing ActionScript 3 Mash up...
The ActionScript Conference 08, Singapore - Developing ActionScript 3 Mash up...
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Chapter12 (1)
Chapter12 (1)Chapter12 (1)
Chapter12 (1)
 
Overview of MVC Framework - by software outsourcing company india
Overview of MVC Framework - by software outsourcing company indiaOverview of MVC Framework - by software outsourcing company india
Overview of MVC Framework - by software outsourcing company india
 
ASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server Controls
 
Chapter09
Chapter09Chapter09
Chapter09
 
GAC Java Presentation_Server Side Include_Cookies_Filters 2022.ppt
GAC Java Presentation_Server Side Include_Cookies_Filters 2022.pptGAC Java Presentation_Server Side Include_Cookies_Filters 2022.ppt
GAC Java Presentation_Server Side Include_Cookies_Filters 2022.ppt
 
Ch 7 data binding
Ch 7 data bindingCh 7 data binding
Ch 7 data binding
 
data binding.docx
data binding.docxdata binding.docx
data binding.docx
 
331592291-HTML-and-Cascading style sheet
331592291-HTML-and-Cascading style sheet331592291-HTML-and-Cascading style sheet
331592291-HTML-and-Cascading style sheet
 
Android interface elements and controls-chapter8
Android interface elements and controls-chapter8Android interface elements and controls-chapter8
Android interface elements and controls-chapter8
 
ASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server ControlsASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server Controls
 
Asp.net
Asp.netAsp.net
Asp.net
 
OBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - TutorialOBIEE publisher with Report creation - Tutorial
OBIEE publisher with Report creation - Tutorial
 
Chapter 16
Chapter 16Chapter 16
Chapter 16
 
Detail view in distributed technologies
Detail view in distributed technologiesDetail view in distributed technologies
Detail view in distributed technologies
 
The most basic inline tag
The most basic inline tagThe most basic inline tag
The most basic inline tag
 
Selectionwidgetwhitepaper 140907120000-phpapp02
Selectionwidgetwhitepaper 140907120000-phpapp02Selectionwidgetwhitepaper 140907120000-phpapp02
Selectionwidgetwhitepaper 140907120000-phpapp02
 
DHTML - Dynamic HTML
DHTML - Dynamic HTMLDHTML - Dynamic HTML
DHTML - Dynamic HTML
 

Recently uploaded

Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxJisc
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismDeeptiGupta154
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfYibeltalNibretu
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdfCarlosHernanMontoyab2
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfTamralipta Mahavidyalaya
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptxJosvitaDsouza2
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePedroFerreira53928
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativePeter Windle
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationDelapenabediema
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxssuserbdd3e8
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345beazzy04
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPCeline George
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsCol Mukteshwar Prasad
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfjoachimlavalley1
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...Denish Jangid
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 

Recently uploaded (20)

Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Accounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdfAccounting and finance exit exam 2016 E.C.pdf
Accounting and finance exit exam 2016 E.C.pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
NLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptxNLC-2024-Orientation-for-RO-SDO (1).pptx
NLC-2024-Orientation-for-RO-SDO (1).pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 

AdRotator and AdRepeater Control in Asp.Net for Msc CS

  • 2. Definition and Usage The AdRotator control is used to display a sequence of ad images. This control uses an XML file to store the ad information. The XML file must begin and end with an <Advertisements> tag. Inside the <Advertisements> tag there may be several <Ad> tags which defines each ad. The AdRotator Control presents ad images each time a user enters or refreshes a webpage. When the ads are clicked, it will navigate to a new Web location. Each time the page is loaded into the browser, an ad is randomly selected from a predefined list. Previously the predefined list means an XML File, which contains the information about the ads to be displayed. But in Asp.Net 2.0 we can maintain the list in any data source. In this article, we explained the AdRotator control to fetch ads information from both database and XML file, and display those ads in randomly with the help of Timer control. You can say it as an AJAX AdRotator Control.
  • 3. The predefined elements inside the <Ad> tag are listed below: Element Description <ImageUrl> Optional. The path to the image file <NavigateUrl> Optional. The URL to link to if the user clicks the ad <AlternateText> Optional. An alternate text for the image <Keyword> Optional. A category for the ad <Impressions> Optional. The display rates in percent of the hits
  • 4. Properties Property Description . N E T AdvertisementFile Specifies the path to the XML file that contains ad information 1 . 0 AlternateTextField Specifies a data field to be used instead of the Alt text for an ad 2 . 0 ImageUrlField Specifies a data field to be used instead of the ImageURL attribute for an ad 2 . 0 KeywordFilter Specifies a filter to limit ads after categories 1 . 0 NavigateUrlField Specifies a data field to be used instead of the NavigateUrl attribute for an ad 2 . 0 runat Specifies that the control is a server control. Must be set to "server" 1 . 0 Target Specifies where to open the URL 1 . 0
  • 5. 5 Outline FlagRotator.aspx (3 of 3 ) AdRotator image Fig. | Web Form that demonstrates the AdRotator web control. (Part 3 of 3. ) a) AlternateText displayed in a tool tip c) b) Add an AdRotator control named countryRotator. Add a XmlDataSource control, which supplies the data to the AdRotator control. Figure (a) shows the first time the page is requested, when the Swedish flag is randomly chosen. In the second request, as shown in Figure (b), the French flag is displayed. Figure (c) depicts the web page that loads when you click the French flag.
  • 6. AdRotator Example: FlagRotator Connecting Data to an AdRotator Control • An XmlDataSource references an XML file containing data that will be used in an ASP.NET application. • To build this example, we first add the XML file AdRotatorInformation.xml to the project. • Right click the App_Data folder in the Solution Explorer and select Add Existing Item…. • Next, drag an AdRotator control from the Toolbox to the Web Form.
  • 7.
  • 8. AdRotator Example: FlagRotator • From the smart-tag menu, select <New Data Source…> from the Choose Data Source drop-down list to start the Data Source Configuration Wizard. • Select XML File as the data-source type. Set the ID of the control to adXmlDataSource. • In the next dialog’s Data File section, click Browse… and, in the Select XML File dialog, locate and select the XML file you added to the App_Data folder.
  • 9. Examining an XML File Containing Advertisement Information Any XML document used with an AdRotator control—must contain one Advertisements root element. Within that element can be as many Ad elements as you need. Each Ad element is similar to the following: <Ad> <ImageUrl>Images/france.png</ImageUrl> <NavigateUrl>https://www.cia.gov/library/publications/ the-world-factbook/geos/fr.html </NavigateUrl> <AlternateText>France Information</AlternateText> <Impressions>1</Impressions> </Ad>
  • 10. Element ImageUrl specifies the path (location) of the advertisement’s image. Element NavigateUrl specifies the URL for the web page that loads when a user clicks the advertisement. The AlternateText element nested in each Ad element contains text that displays in place of the image when the browser cannot display the image. The Impressions element specifies how often a particular image appears, relative to the other images. In our example, the advertisements display with equal probability, because the value of each Impressions element is set to 1.
  • 11.
  • 12.
  • 14. Data Controls ASP.NET comes with two sets of data-aware controls: the data-bound and the data source controls. Data-bound controls These are used to display and edit data. The GridView, DataList, ListView, and Repeater are all able to display multiple records at the same time, whereas the DetailsView and the FormView are designed to show a single record at a time. The DataPager is used to provide paging capabilities to the ListView controls.
  • 15. Definition and Usage  Repeater – It gives you the greatest flexibility in terms of the HTML that you output to the browser as the control by itself does not add any HTML to the page output. The control has no built-in capabilities for the paging, sorting and modification of data. It is often used when you need precise control over the markup that is generated by the control. As such, it’s often used for HTML ordered or unordered lists (<ol> and <ul>), etc.
  • 16. Repeater has 5 inline template to format it: 1. <HeaderTemplate> 2. <FooterTemplate> 3. <ItemTemplate> 4. <AlternatingItemTemplate> 5. <SeperatorTemplate> 6. <AlternatingItemTemplate> HeaderTemplate: This template is used for elements that you want to render once before your ItemTemplate section. FooterTemplate: - This template is used for elements that you want to render once after your ItemTemplate section. ItemTemplate: This template is used for elements that are rendered once per row of data. It is used to display records AlternatingItemTemplate: This template is used for elements that are rendered every second row of data. This allows you to alternate background colors. It works on even number of records only. SeperatorTemplate: It is used for elements to render between each row, such as line breaks.
  • 17. How to use a Repeater Control? Create a new website with name RepeaterControl Double click the web.config file and write following code in it:
  • 18. <connectionStrings> <add name="constr" connectionString="initial catalog=puran; data source=MCN002; integrated security=sspi"/> </connectionStrings> Default.aspx file code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!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"> <link rel="Stylesheet" type="text/css" href="StyleSheet.css" /> <title>Repeater Controls in ASP.NET</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Repeater ID="RepeatInformation" runat="server"> <HeaderTemplate> <table class="tblcolor">
  • 19. <tr> <b> <td> Roll No </td> <td> Student Name </td> <td> Total Fees </td> </b> </tr> </HeaderTemplate> <ItemTemplate> <tr class="tblrowcolor"> <td> <%#DataBinder.Eval(Container,"DataItem.RollNo")%> </td> <td> <%#DataBinder.Eval(Container,"DataItem.Name")%> </td> <td> <%#DataBinder.Eval(Container,"DataItem.Fees")%> </td> </tr> </ItemTemplate> <SeparatorTemplate>
  • 20. <hr /> </td> </tr> </SeparatorTemplate> <AlternatingItemTemplate> <tr> <td> <%#DataBinder.Eval(Container,"DataItem.RollNo")%> </td> <td> <%#DataBinder.Eval(Container,"DataItem.Name")%> </td> <td> <%#DataBinder.Eval(Container,"DataItem.Fees")%> </td> </tr> </AlternatingItemTemplate> <SeparatorTemplate> <tr> <td> <hr /> </td> <td> <hr /> </td> <td> <hr /> </td> </tr> </SeparatorTemplate> <FooterTemplate> <tr> <td>
  • 21. Code behind file code using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { SqlConnection con; SqlCommand cmd = new SqlCommand(); protected void Page_Load(object sender, EventArgs e) { con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString); cmd.Connection = con; cmd.CommandText = "select * from student"; con.Open(); RepeatInformation.DataSource = cmd.ExecuteReader(); RepeatInformation.DataBind(); con.Close(); } }
  • 22.