using $find with mater pages

  • Thread starter Thread starter kpg
  • Start date Start date
K

kpg

Hi all,

I am using the ajax.net slider control an I added a client side value
changed handler like this:

function pageLoad() {
$find('My_SliderExtender').add_valueChanged(OnValueChange);
}

Works great.

Then I moved my slider into a content placeholder and now the $find
return null - makes sense, becuase the client id has changed.

So I tried multiple techniques to get it to work - all failed.

I tried passing the parent (the content palceholder) to the $find

$find('My_SliderExtender','Content1')
$find('My_SliderExtender',$get('Content1'))


I tried using the client id:

$find('<%= My_SliderExtender.ClientID%>')

I treid using the name observed in the generated html:

$find('ctl001$Content1$My_SliderExtender')


How do I find a control behaviour that is in a content placeholder?

Thanks,
kpg
 
The answer is to use the (real) clientid of the control.

I had tried this but I did it wrong.

so if the clinetid is of the form:

ctl00_<ContentPlaceholderID>_<ControlID>

(note: replace<ContentPlaceholderID> and <ControlID>)

then this works:

var c=$find('ctl00_<ContentPlaceholderID>_<ControlID>');

and so does this:

var c = $find(<%= myControl.ClientID%>);

Which brings up a different question.

My javascript is in an external file, so I can't use the
<%= myControl.ClientID%> directive.

So I created a global javascript var in my master page body
that sets the name of the contentplaceholder prefix
like this:

var cph = 'ctl00_<ContentPlaceholderID>_<ControlID>';

I had tried this:

var cph = '<%= Content.ClientID %>';

but this gave me a syntax error.

Why can't I use the <%= %> for in-line javascript
included in the <boby>?

Thanks,
kpg
 
Back
Top