문제

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