Master / Child pages

Posted on 2012-03-29
Last Modified: 2012-03-30
I have a master / child page.  I have a button on the child page.   onClick, it calls a javascript function within the master page.   Is there a way to tie the button on the child page to a button on the master page, so that when the button on the  child page is clicked, it in turn clicks the button on the master page, which in turn would then call the javascript?

I have over 100 child pages, and I'm trying to avoid adding onClick code for every page, and instead have button on the child page automatically tied to a button on the master page
Question by:HLRosenberger
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3

Expert Comment

by:Lalit Chandra
ID: 37783756
yes you can do it easily with jquery. Add the button on every client page and then add small jquery code to bind the click event authomatically which in turn call the master page button.

Suppose you have button on the each client page like below

<input type="text" id="butClient">Click Me Child</input>

Now on master page  there is a button with the following defination
<input type="text" id="butMaster">Click Me  Master</input>

Now simple add the code on the head section of  your Master page to bind the event and initiate the master's button click

$(function()  {
   $("#butClient").click(function() {

Hope you get the idea of doing that.

Author Comment

ID: 37783813
I have never used jquery.  Do I have to download a package?  Do most browsers support it?

Expert Comment

by:Lalit Chandra
ID: 37783936
yes jquery is now supported by many broser like
IE 6.0+, FF 3.6+, Safari 5.0+, Opera, Chrome

For using jquery you can simple use by pasting the following code to in the head section of  your html.

<script type="text/javascript" src=""></script>
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 37784028
Thanks.  How about passing parms on the click?

Expert Comment

by:Lalit Chandra
ID: 37784105
please elaborate your needs in a more detail view.

Author Comment

ID: 37784245
well, what I ultimately want to do is this:  Each child page contains a list of records from a database table.   Each child page is a different table.  I have about 100 child pages, and more to come.   I'm trying to get around adding code behind the buttons on each child page.   I want to pass an integer - primary key - and a string - table name - to Javascript code on the master page.  The  Javascript code uses showModalDialog to open page that allows edit of the database record, using a naming convention that incorporates the table name to generate the URL, and the integer is the record's primary key which is passed as a parm on the URL.

Make sense?
LVL 21

Accepted Solution

masterpass earned 500 total points
ID: 37785224
While Jquery is a viable option, Have a look here .. This will give you a better overview of how to find a control in masterpage from the childpage. In your case, find the button control in the masterpage and get the client ID of the button.

then in the child page load, all you have to do is

btnChild.Attributes.Add("onlick", "javascript to imitate the buttonclick from masterpage and you have the ID of the masterpage button");

hope this helps!

Author Closing Comment

ID: 37786936

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP: Filling Out/Creating a PDF 29 98 figure out error 3 24
window close link 7 33
Stop Git from being my repository 1 21
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question