AdCreatedEventArgs Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public ref class AdCreatedEventArgs sealed : EventArgs
public ref class AdCreatedEventArgs : EventArgs
public sealed class AdCreatedEventArgs : EventArgs
public class AdCreatedEventArgs : EventArgs
type AdCreatedEventArgs = class
inherit EventArgs
Public NotInheritable Class AdCreatedEventArgs
Inherits EventArgs
Public Class AdCreatedEventArgs
Inherits EventArgs
- Inheritance
The following code example demonstrates how to specify and code a handler for the AdCreated event. It gets the URL associated with the advertisement when the AdRotator control gets created and displays it below the control. This example requires the XML file (Ads.xml) listed in the example below.
<%@ Page Language="C#" AutoEventWireup="True" %>
<!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>AdRotator Example</title>
</head>
<script language="c#" runat="server">
void AdCreated_Event(Object sender, AdCreatedEventArgs e)
{
Message.Text=e.NavigateUrl;
}
</script>
<body>
<form id="form1" runat="server">
<h3>AdRotator Example</h3>
<asp:AdRotator id="test1" runat="server"
AdvertisementFile = "~/App_Data/Ads.xml"
Borderwidth="1"
Target="_blank"
OnAdCreated="AdCreated_Event"/><br /><br />
<asp:label id="Message" runat="server"/>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!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>AdRotator Example</title>
</head>
<script language="vb" runat="server">
Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs)
Message.Text=e.NavigateUrl
End Sub
</script>
<body>
<form id="form1" runat="server">
<h3>AdRotator Example</h3>
<asp:AdRotator id="test1" runat="server"
AdvertisementFile = "~/App_Data/Ads.xml"
Borderwidth="1"
Target="_blank"
OnAdCreated="AdCreated_Event"/><br /><br />
<asp:label id="Message" runat="server"/>
</form>
</body>
</html>
The following code example demonstrates how to format the XML file that contains the advertisement information. For more information on the XML file, see the AdvertisementFile property of the AdRotator class.
<Advertisements>
<Ad>
<ImageUrl>image1.jpg</ImageUrl>
<NavigateUrl>http://www.microsoft.com</NavigateUrl>
<AlternateText>Microsoft Main Site</AlternateText>
<Impressions>80</Impressions>
<Keyword>Topic1</Keyword>
<Caption>This is the caption for Ad#1</Caption>
</Ad>
<Ad>
<ImageUrl>image2.jpg</ImageUrl>
<NavigateUrl>http://www.wingtiptoys.com</NavigateUrl>
<AlternateText>Wingtip Toys</AlternateText>
<Impressions>80</Impressions>
<Keyword>Topic2</Keyword>
<Caption>This is the caption for Ad#2</Caption>
</Ad>
</Advertisements>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!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>AdRotator AdCreated Example</title>
</head>
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Create an EventHandler delegate for the method you want to handle the event
// and then add it to the list of methods called when the event is raised.
Ad.AdCreated += new System.Web.UI.WebControls.AdCreatedEventHandler(this.AdCreated_Event);
}
void AdCreated_Event(Object sender, AdCreatedEventArgs e)
{
// Override the AlternateText value from the ads.xml file.
e.AlternateText = "Visit this site!";
}
</script>
<body>
<form id="form1" runat="server">
<h3>AdRotator AdCreated Example</h3>
Notice that the AlternateText property of the advertisement <br />
has been programmatically modified from the value in the XML <br />
file.
<br /><br />
<asp:AdRotator id="Ad" runat="server"
AdvertisementFile = "~/App_Data/Ads.xml"
Borderwidth="1"
Target="_blank"/>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!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>AdRotator AdCreated Example</title>
</head>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
' Create an EventHandler delegate for the method you want to handle the event
' and then add it to the list of methods called when the event is raised.
AddHandler Ad.AdCreated, AddressOf AdCreated_Event
End Sub
Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs)
' Override the AlternateText value from the ads.xml file.
e.AlternateText = "Visit this site!"
End Sub
</script>
<body>
<form id="form1" runat="server">
<h3>AdRotator AdCreated Example</h3>
Notice that the AlternateText property of the advertisement <br />
has been programmatically modified from the value in the XML <br />
file.
<br /><br />
<asp:AdRotator id="Ad" runat="server"
AdvertisementFile = "~/App_Data/Ads.xml"
Borderwidth="1"
Target="_blank"/>
</form>
</body>
</html>
The AdCreated event is raised when the AdRotator control displays an advertisement on the page.
For a list of initial property values for an instance of AdCreatedEventArgs, see the AdCreatedEventArgs constructor.
For more information about handling events, see Handling and Raising Events.
Ad |
Initializes a new instance of the AdCreatedEventArgs class. |
Ad |
Gets a IDictionary object that contains all the advertisement properties for the currently displayed advertisement. |
Alternate |
Gets or sets the alternate text displayed in the AdRotator control when the advertisement image is unavailable. Browsers that support the ToolTips feature display this text as a ToolTip for the advertisement. |
Image |
Gets or sets the URL of an image to display in the AdRotator control. |
Navigate |
Gets or sets the Web page to display when the AdRotator control is clicked. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
To |
Returns a string that represents the current object. (Inherited from Object) |
Product | Versions |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: