AdCreatedEventArgs.AlternateText Propriedade
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.
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.
public:
property System::String ^ AlternateText { System::String ^ get(); void set(System::String ^ value); };
public string AlternateText { get; set; }
member this.AlternateText : string with get, set
Public Property AlternateText As String
Valor de Propriedade
O texto é exibido em vez da imagem publicitária caso a imagem não esteja disponível. O valor predefinido é Empty.
Exemplos
O exemplo de código seguinte demonstra como definir programaticamente a AlternateText propriedade.
<%@ 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>AdCreatedEventArgs AlternateText Example</title>
<script runat="server">
void AdCreated_Event(Object sender, AdCreatedEventArgs e)
{
e.AlternateText = "New Alternate Text Value";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<h3>AdCreatedEventArgs AlternateText Example</h3>
<asp:AdRotator id="AdRotator1" runat="server"
AdvertisementFile = "Ads.xml"
Target="_newwwindow"
OnAdCreated="AdCreated_Event"/>
</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>AdCreatedEventArgs AlternateText Example</title>
<script runat="server">
Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs)
e.AlternateText = "New Alternate Text Value"
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<h3>AdCreatedEventArgs AlternateText Example</h3>
<asp:AdRotator id="AdRotator1" runat="server"
AdvertisementFile = "Ads.xml"
Target="_newwwindow"
OnAdCreated="AdCreated_Event"/>
</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>
Observações
Use a AlternateText propriedade para especificar o texto a mostrar caso a imagem especificada na ImageUrl propriedade não esteja disponível. Em navegadores que suportam a funcionalidade ToolTips, este texto também aparece como uma ToolTip para o anúncio.
Um ficheiro XML separado contém as propriedades do anúncio exibido. O AdRotator controlo define automaticamente a AlternateText propriedade com a correspondente entrada de texto alternativa no ficheiro XML. Esta propriedade também pode ser usada para definir programaticamente o texto alternativo.