473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Master page/content page asp control ID's

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.
Jun 11 '06 #1
3 5584
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/
"Frederik Borg" <bo***********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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.

Jun 11 '06 #2
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.

-Brock
http://staff.develop.com/ballen

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.

Jun 11 '06 #3
On Sun, 11 Jun 2006 11:36:03 +0200, Frederik Borg wrote:
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
Jun 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Martijn Saly | last post by:
Hi there, I've created a master page with some controls on it, a Calendar control among others. Now depending on the date(s) selected, the content page needs to be updated. In the masterpage...
2
by: Scott | last post by:
I'm using a master page (mp_TableMaint.aspx) with one Content area (ID: Content1). Content1 contains several usercontrols, which are hidden. The goal is to show the correct control based on the...
5
by: Paul | last post by:
I have a MasterPage that has on it several UserControls (*ascx files). I wish to control the visibility of the controls on the content pages according to some parameter (for example on a user...
3
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
2
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no...
7
by: xkeops | last post by:
Thinking of creating a website, most of the pages will have a general toolbar menu, a content and a footer. The content will be the only one who's gonna change but the rest (header,footer) will...
4
by: Diane Yocom | last post by:
I'm trying to use an Atlas UpdatePanel to just update a label when a text box has changed. The problem is that my textbox is in a user control and I'm using Master Pages - with the combination of...
4
by: Boris Yeltsin | last post by:
OK, on my Master Page I have a control: <a id="hypTabAccount" href="#" runat="server">Account</a> Now, in the code-behind (Root.master.vb) I can refer to it simply thus: ...
1
by: sudip2008 | last post by:
When using the Calendar Popup in a content page of a masterpage the strForName is always set to aspnetForm This breaks this line from working properly window.opener.document.forms...... How can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.