AdCreatedEventArgs Classe
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
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
- Herança
Exemplos
O seguinte exemplo de código demonstra como especificar e programar um handler para o AdCreated evento. Recebe o URL associado ao anúncio quando o AdRotator controlo é criado e mostra-o abaixo do controlo. Este exemplo requer o ficheiro XML (Ads.xml) listado no exemplo abaixo.
<%@ 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>
O exemplo de código seguinte demonstra como formatar o ficheiro XML que contém a informação do anúncio. Para mais informações sobre o ficheiro XML, consulte a AdvertisementFile propriedade da AdRotator classe.
<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>
Observações
O AdCreated evento é ativado quando o AdRotator controlo exibe um anúncio na página.
Para obter uma lista de valores das propriedades iniciais de uma instância de AdCreatedEventArgs, consulte o construtor AdCreatedEventArgs.
Para obter mais informações sobre como manipular eventos, consulte Manipulando e gerando eventos.
Construtores
| Name | Description |
|---|---|
| AdCreatedEventArgs(IDictionary) |
Inicializa uma nova instância da AdCreatedEventArgs classe. |
Propriedades
| Name | Description |
|---|---|
| AdProperties |
Obtém um IDictionary objeto que contém todas as propriedades do anúncio do anúncio atualmente exibido. |
| AlternateText |
Recebe ou define o texto alternativo exibido no AdRotator controlo quando a imagem do anúncio não está disponível. Navegadores que suportam a funcionalidade de ToolTips exibem este texto como uma ToolTip para o anúncio. |
| ImageUrl |
Obtém ou define a URL de uma imagem para ser exibida no AdRotator controlo. |
| NavigateUrl |
Obtém ou configura a página Web para mostrar quando o AdRotator controlo é clicado. |
Métodos
| Name | Description |
|---|---|
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual. (Herdado de Object) |
| GetHashCode() |
Serve como função de hash predefinida. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual. (Herdado de Object) |
| MemberwiseClone() |
Cria uma cópia superficial do atual Object. (Herdado de Object) |
| ToString() |
Devolve uma cadeia que representa o objeto atual. (Herdado de Object) |