This documentation is archived and is not being maintained.

AdCreatedEventArgs.NavigateUrl Property

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

[Visual Basic]
Public Property NavigateUrl As String
[C#]
public string NavigateUrl {get; set;}
[C++]
public: __property String* get_NavigateUrl();
public: __property void set_NavigateUrl(String*);
[JScript]
public function get NavigateUrl() : String;
public function set NavigateUrl(String);

Property Value

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

Remarks

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 automatically sets the NavigateUrl property with the corresponding navigate URL entry in the XML file. This property may also be used to programmatically set the navigate URL.

Note   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.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to programmatically set the NavigateUrl property.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">
   
       Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs) 

          e.NavigateUrl = "http://www.microsoft.com"   
       
       End Sub      

   </script>
 
</head>
 
<body>
 
   <form runat="server">
 
      <h3>AdCreatedEventArgs NavigateUrl Example</h3>
 
      <asp:AdRotator id="AdRotator1" runat="server"
           AdvertisementFile = "Ads.xml"
           Target="_newwwindow"
           OnAdCreated="AdCreated_Event"/>
 
   </form>
 
</body>
</html>

[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">
   
       void AdCreated_Event(Object sender, AdCreatedEventArgs e) 
       {

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

   </script>
 
</head>
 
<body>
 
   <form runat="server">
 
      <h3>AdCreatedEventArgs NavigateUrl Example</h3>
 
      <asp:AdRotator id="AdRotator1" runat="server"
           AdvertisementFile = "Ads.xml"
           Target="_newwwindow"
           OnAdCreated="AdCreated_Event"/>
 
   </form>
 
</body>
</html>

[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">
   
       function AdCreated_Event(sender : Object, e : AdCreatedEventArgs) 
       {

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

   </script>
 
</head>
 
<body>
 
   <form runat="server">
 
      <h3>AdCreatedEventArgs NavigateUrl Example</h3>
 
      <asp:AdRotator id="AdRotator1" runat="server"
           AdvertisementFile = "Ads.xml"
           Target="_newwwindow"
           OnAdCreated="AdCreated_Event"/>
 
   </form>
 
</body>
</html>

[Visual Basic, C#, JScript] The following example demonstrates how to format the XML file that contains the advertisement information. For additional 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>Wing Tip Toys</AlternateText>
 <Impressions>80</Impressions>
 <Keyword>Topic2</Keyword>
 <Caption>This is the caption for Ad#2</Caption> 
 </Ad>
 
</Advertisements>

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

AdCreatedEventArgs Class | AdCreatedEventArgs Members | System.Web.UI.WebControls Namespace | AdRotator | AdRotator.AdvertisementFile | String.Empty

Show: