Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Master / Child pages

Posted on 2012-03-29
8
Medium Priority
?
613 Views
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
0
Comment
Question by:HLRosenberger
  • 4
  • 3
8 Comments
 
LVL 7

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() {
          $("#butMaster").click();
   });
});

Hope you get the idea of doing that.
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 37783813
I have never used jquery.  Do I have to download a package?  Do most browsers support it?
0
 
LVL 7

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="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:HLRosenberger
ID: 37784028
Thanks.  How about passing parms on the click?
0
 
LVL 7

Expert Comment

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

Author Comment

by:HLRosenberger
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?
0
 
LVL 21

Accepted Solution

by:
masterpass earned 2000 total points
ID: 37785224
While Jquery is a viable option, Have a look here

http://msdn.microsoft.com/en-us/library/xxwa0ff0.aspx .. 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!
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 37786936
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
Suggested Courses

783 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