Export (0) Print
Expand All

AdCreatedEventArgs.NavigateUrl Property

Gets or sets the Web page to display when the AdRotator control is clicked.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public string NavigateUrl { get; set; }

Property Value

Type: System.String
The Web page to display when the AdRotator control is clicked. The default value is String.Empty.

Use the NavigateUrl property to specify the Web page to display when the AdRotator control is clicked. A common use for this property is to redirect the navigation, when the AdRotator control is clicked, to a page that can count the number of times the user clicked the advertisement before proceeding to the destination URL.

A separate XML file contains the properties for the displayed advertisement. The AdRotator control automatically sets the NavigateUrl property with the corresponding navigation URL entry in the XML file. This property can also be used to programmatically set the navigation URL.

NoteNote

If you use an advertisement file and specify a relative URL for this property, the URL is relative to the directory that the advertisement file is located in. If you set this property directly with a relative URL, instead of using the advertisement file, the URL is relative to the directory of the page or user control that contains the AdRotator control.

The following code example demonstrates how to programmatically set the NavigateUrl property.

<%@ 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 NavigateUrl Example</title>
<script runat="server">

       void AdCreated_Event(Object sender, AdCreatedEventArgs e) 
       {

          e.NavigateUrl = "http://www.microsoft.com";   

       }      

   </script>

</head>

<body>

   <form id="form1" runat="server">

      <h3>AdCreatedEventArgs NavigateUrl Example</h3>

      <asp:AdRotator id="AdRotator1" runat="server"
           AdvertisementFile = "Ads.xml"
           Target="_newwwindow"
           OnAdCreated="AdCreated_Event"/>

   </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>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft