0

The Timer is defined like this:

<asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="1000" Enabled="false" />

When calling $find("<%= Timer1.ClientID %>")._startTimer(); I'm getting this error:

Microsoft JScript runtime error: Unable to get value of the property '_startTimer': object is null or undefined

and when calling $('#Timer1')._startTimer(); I'm getting this error:

Microsoft JScript runtime error: Object doesn't support property or method '_startTimer'

Any advice will be welcome.

4

1 回答 1

1

Try passing $find() the shorter server-side (or "Component") ID:

$find("Timer1")._startTimer();

You may also be able to use $get() with the ClientID:

$get("<%= Timer1.ClientID %>")._startTimer();

With jQuery, pass it the ClientID as with $get() and use .get(0) to retrieve the DOM Object from the jQuery collection:

$('#<%= Timer1.ClientID %>').get(0)._startTimer();
于 2012-07-18T21:49:51.317 回答