Hi all

I am very new to ASP.NET and I am still learning the basics and how to use various controls.
I have used the adRotator control and also created the XML File using the coding mentioned below, but when executed in the browser it is showing error message(Which I am posting after the code)

XML FILE:
<?xml version="1.0" encoding="utf-8"?>
<Advertisement>
  <Ad>
    <ImageUrl> images/Logo.gif</ImageUrl>
    <NavigateUrl>http://www.google.co.in</NavigateUrl>
    <AlternateTExt> Main </AlternateTExt>
    <Keyword>LogoImage</Keyword>
  </Ad>
  <Ad>
    <ImageUrl> images/RedBik.gif</ImageUrl>
    <NavigateUrl>http://www.yahoo.co.in</NavigateUrl>
    <AlternateTExt> Main2 </AlternateTExt>
    <Keyword>RedBikImage</Keyword>
  </Ad>
</Advertisement>
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    <asp:AdRotator id="AdRotator1" 
            style="Z-INDEX: 102; LEFT: 32px; 
        POSITION: absolute; TOP: 32px; height: 222px; width: 883px;" 
            runat="server" AdvertisementFile="~/myAds.xml">
            
    </asp:AdRotator>
    </div>
    </form>
</body>
</html>

Please note that I have not written any coding in the file Default.aspx.cs.
The ERROR MESSAGE I am getting in the browser is:

Server Error in '/AdRotatorControl' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.

Details: To enable the details of this specific error message to be viewable on the local server machine, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "RemoteOnly". To enable the details to be viewable on remote machines, please set "mode" to "Off".

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly"/>
    </system.web>
</configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="On" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>

Can any one identify the error and please help me out?

Please help me out!

Thanks in advance!

Recommended Answers

All 6 Replies

hi use and try the following code.. Create a folder images and place logo.jpg and Redbik.jpg in that folder.

source code:

<asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/myAds.xml"
            OnAdCreated="AdRotator1_AdCreated" />

myAds.xml:

<?xml version="1.0" encoding="utf-8" ?>

<Advertisements>

  <Ad>
    <ImageUrl>images\Logo.jpg</ImageUrl>
    <NavigateUrl>http://www.site1.com</NavigateUrl>
    <AlternateText>Site1 Main</AlternateText>
    <Impressions>50</Impressions>
    <Keyword>Product1</Keyword>
  </Ad>

  <Ad>
    <ImageUrl>images\RedBik.jpg</ImageUrl>
    <NavigateUrl>http://www.site2.com</NavigateUrl>
    <AlternateText>Site2 Main Page</AlternateText>
    <Impressions>75</Impressions>
    <Keyword>Product2</Keyword>
  </Ad>

</Advertisements>

Try this and let me know..

Otherwise:
<b>
replace your myAds.xml -><Advertisement> into <Advertisements>

Then you can't get the above error
</b>

The actual error cannot be identified based on this error message. Set the mode attribute to off in the <customErrors> attribute in web.config. It will display detailed error message.

Also check whether any error message is logged in Event Viewer.

I have tested your code.

You have used invalid keyword <Advertisement>. It should be <Advertisements>. 's' is missing.

Hope this will help you.

I have tested your code.

You have used invalid keyword <Advertisement>. It should be <Advertisements>. 's' is missing.

Hope this will help you.

Thanks for your reply.

I am getting the output.
But it is just showing the Main keyword and the Main2 keyword is never shown. Can you please tell me how can i do this? Should I set any property to achieve this?

Can I display the Image instead of the AlternateText?

Please help me out! Thanks in advance!

Firstly, in the properties of adrotator, attach the xml file to 'advertisementfile'. Then the opening and closing tag is Advertisements and not Advertisement. It should work.

Firstly, in the properties of adrotator, attach the xml file to 'advertisementfile'. Then the opening and closing tag is Advertisements and not Advertisement. It should work.

Thanks for your reply!

I have already made that change and the application is working but I am having two ad's as per the xml file (for advertisement) and I have mentioned the image url, the problem is that i am getting the alternate text of the one ad only the alternate text for the second ad is not displayed and also the images for both the ad are not displayed inspite of mentioning the imageurl in the xml file.

Can anybody tell me what is the problem or what changes should I make to perform the desired task?

Thanks in advance!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.