Writing value to a control in Masterpage from a child page.

zachvaldez
zachvaldez used Ask the Experts™
on
I have a label control in my Masterpage and I would like the  text property of tab I click in the child place
assigned to the label in the Masterpage. Please show example.

 <ul class="tabs" id="thistab" runat="server">

                <li class="tab-link current" data-tab="tab-1" id="tab11" data-toggle="tab"><a href="#Person">Personal Info</a></li>

                <li class="tab-link" data-tab="tab-6" id="tab16"><a href="#Info" data-toggle="tab"                <li class="tab-link" data-tab="tab-2" id="tab12"><a href="#Assign" data-toggle="tab" title="Assignment History">Assignment History</a></li>
                <li class="tab-link" data-tab="tab-3" id="tab13"><a href="#Issues" data-toggle="tab" title="Issues">Issues</a>

</ul>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Generally this would be

$('.tab-link a').click(function() {
  // either
  // $('#idoflabel').html($(this).text())); OR
  $('label.label-target').html($(this).text());
});

Open in new window


Change the .label-target to the id of the target label or a class associated with that label
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
Just a note on Master / Child pages. This only has meaning in the context of the server-side C# code. There is no distinction between master and child content once the HTML arrives in the browser - there is just one flat page.

Author

Commented:
Thanks. It's not changing it on click. How would I call this script?
Should you be charging more for IT Services?

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
You don't call it - it is an event handler and as long as you have set it up correctly it should just work.

Bear in mind you also have to
a) Include the jQuery library on your page BEFORE the script
b) The script should be in a document ready block
$(function() {
  $('.tab-link a').click(function() {
    $('label.label-target').html($(this).text());
  });
});

Open in new window


Finally, it is no use telling us it does not work without providing us with information on how you implemented it.

a) You could have forgotten to set up the script so it references the right class / id for the label
b) The script may not be linking to the tabs correctly
c) You may have placed the script outside of a document ready block
d) You may have placed it before the jQuery library
e) You may have forgotten to include the jQuery library
f) You may have made a typo that resulted in a script error - did you check the console (F12) for errors.

These are the things we need to know if we are going to help you.

Author

Commented:
Thanks for explaining a lot of this question. It just show you're expertise in the area
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
You are welcome.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial