473,769 Members | 3,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="SomeOt herControl.clic k();">Remove</button>

Unfortunately the ID of SomeOtherContro l 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 5603
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******** ********@TK2MSF TNGP05.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="SomeOt herControl.clic k();">Remove</button>

Unfortunately the ID of SomeOtherContro l 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.ClientI D 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="SomeOt herControl.clic k();">Remove</button>

Unfortunately the ID of SomeOtherContro l 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 SomeOtherContro l 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="<%= SomeOtherContro l.ClientID %>.click();">Re move</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
1959
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 I've created StartDate and EndDate properties, which are basically wrappers around the SelectedDates property from the Calendar control. When I select another date in the Calendar, the page updates normally, but when Page_Load for the content page...
2
3089
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 querystring passed when calling mp_TableMaint (the page is called from an ASP.NET 2.0 Menu control on my index.aspx page). I believe I understand correctly that the Master Page's ASP Content control (named Content1) is, itself, a server side...
5
1955
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 control that depends on a param StoreID, for the UserControl to be visible only if StoreID is in the query string.) How can I access a UserControl in a MasterPage from a Content page? I tried this, and variations thereof, but get errors: ...
3
6441
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 BarLabelText. I now have a contentpage "FooBar.aspx", where "Bar.master" is the master page and in the content section has the control "Foo.ascx".
17
3161
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 pages? Kinda sorta a critical point no? Am I missing something? Rob. P.S. the day I find a book that actually is useful rather than just a
2
7026
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 header. I tried to put the link tag in the Master page, but the classes are not recognized in the Content Page. How do I use a StyleSheet with the Content Page? TIA
7
8730
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 remain the same. I am interested to know your opinions/suggestions in finding an easy way of doing it. In asp one could have something like this:
4
3921
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 these two things, the page flashes everytime my textbox changes and the panel is updated. If I just use a regular textbox along with the Master Page, it works fine. If I use by user control without the Master Pages, it works fine. When I...
4
3995
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: hypTabAccount.InnerText = "blah" Now, what I want is the same in a content page that uses the Master Page. I have a Master Type in my Content page:
1
8487
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 I fix this and display the date into textbox after selecting the date from Calendar.aspx? This Very Urgent .......................... If any body help me out I have given the following Code ******************************
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.