Master page/content page asp control ID's

F

Frederik Borg

Hi
I would like to use script to access an asp control client side. The asp
control and script is located in a content page. I use the control's ID
to call it:

<button onclick="SomeOtherControl.click();">Remove</button>

Unfortunately the ID of SomeOtherControl gets changed when using master
pages. It owrks perfect when using regualar flat aspx pages.

Any idears as to how i can set/find the correct ID?

thanks.
 
C

clintonG

We have to use public properties or the FindControl method to reference
controls when using MasterPages. There are a number of examples in replies
in this newsgroup and a fair number of articles that can be found.


<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
 
B

Brock Allen

You must dynamically emit the proper ID in your javascript. To do so you
must ask the control on the server by accessing the Control.ClientID property.
 
E

Erik Funkenbusch

Unfortunately the ID of SomeOtherControl gets changed when using master
pages. It owrks perfect when using regualar flat aspx pages.

Any idears as to how i can set/find the correct ID?

There are several techniques you can use. First, you can use something
like this in your javascript:

<button onclick="<%= SomeOtherControl.ClientID %>.click();">Remove</button>

You can read more here:

http://msdn2.microsoft.com/en-us/3hc29e2a.aspx
 

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

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top