using $find with mater pages

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
 
K

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top