Write a Program in C# to create an Advertisement using Ad rotator
Description:
Open Microsoft visual studio
File-> New -> Project -> visual c#->
Program:
.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ads.aspx.cs" Inherits="ads" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="XMLFile.xml"></asp:XmlDataSource>
</div>
</form>
</body>
</html>
Description:
Open Microsoft visual studio
File-> New -> Project -> visual c#->
Program:
.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ads.aspx.cs" Inherits="ads" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="XMLFile.xml"></asp:XmlDataSource>
</div>
</form>
</body>
</html>
aspx.cs file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ads : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
.xml file
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>google.jpg</ImageUrl>
<NavigateUrl>http://www.google.com</NavigateUrl>
<AlternateText>Visit Google.com</AlternateText>
<Impressions>80</Impressions>
<Keyword>search</Keyword>
</Ad>
<Ad>
<ImageUrl>msn.jpg</ImageUrl>
<NavigateUrl>http://www.msn.com</NavigateUrl>
<AlternateText>
Visit MSN.com
</AlternateText>
<Impressions>80</Impressions>
<Keyword>MSN</Keyword>
</Ad>
<Ad>
<ImageUrl>yahoo.jpg</ImageUrl>
<NavigateUrl>http://www.yahoo.com</NavigateUrl>
<AlternateText>
Visit yahoo.com
</AlternateText>
<Impressions>80</Impressions>
<Keyword>yahoo</Keyword>
</Ad>
</Advertisements>
Demo:
Write a Program in C# to create an Advertisement using Ad rotator |
No comments:
Post a Comment