質問

I have an adrotator on my Asp.net Master Page

<asp:AdRotator ID="adr" AdvertisementFile="~/Adrotator.xml" Width="180px" Height="200px"
                 runat="server" Target="_self" />

I am using the following jquery for rotating ADS . However it is not able to detect the id of the Adrotator control

    $(document).ready(function () {

            setInterval(function () {
            $("[id$='adr']").load(location.href + "[id$='adr']", "" + Math.random() + "");
        }, 5000);

    });

Note: I already tried using $("[id$='adr']") and $('[id$=\'adr\']') and '#adr'

enter image description here

役に立ちましたか?

解決

try using

 $('#<%=adr.ClientID%>').Load..... 

in asp.net code, use this id selectors: $("#<%= adr.ClientID %>").Load...; for server controls as client id may be changed by asp.net infrastructure

他のヒント

Try

$("[id$='<%=adr.ClientID %>']")

I would suggest that you check the generated html source of the ad rotator. This could give you more insight into how you should write your jQuery.

Or you may use

<asp:AdRotator ID="adr" AdvertisementFile="~/Adrotator.xml" Width="180px" Height="200px"
             runat="server" Target="_self" CssClass="adr" />

and class selector

$(".adr")

Or you may use databind

$("#<%# adr.ClientID %>")

and

Databind();

on page load.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top