Change master page controls from content page

Hi,

 I have a master page with tabs menu ("primarynav"), and I want the 'selected' tab, meaning the one that suits the specific content page, to appear as selected.

The way I did it is adding this code to the content page:

<script type="text/javascript">

document.body.onload = function()

{

document.getElementById('HelpTab').outerHTML = "<LI class=\"selected\" id=HelpTab onclick=SetHelpTab(); _extended=\"true\"><A href=\"Help.aspx\" _extended=\"true\">Help</A> "

}

</script>

 (the 'selected' property affects the appearance .Is there a better, more generic way to do it with master page? Maybe add a generic code to the master page and call it from content pages? How can I do that?

 

Thanks

0
platinium
4/14/2008 9:08:32 AM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

1 Replies
678 Views

Similar Articles

[PageSpeed] 12

Hi,

Do you use the ASP.Net menu control?

You can set its DynamicSelectedStyle and StaticSelectedStyle to make it selected.

You can access menu control in the content page, like below:

        Menu menu =  (Menu)this.Master.FindControl("Menu1");
        menu.DynamicSelectedStyle.CssClass = "selected";

Hope it helps.


Amanda Wang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Amanda
4/16/2008 11:03:28 AM
Reply:

Similar Artilces:

Content controls have to be top-level controls in a content page or a nested master page that references a master page.
Why in the world am I getting this error? The solutions I have seen either don't apply or don't work.  Here is my master page code:<%@ Master Language="C#" AutoEventWireup="false" CodeFile="TechLMSMasters/MainSide.master.cs" Inherits="MainSide" %> <%@ Register TagPrefix="usercontrol" TagName="Search" Src="~/library/uc/Search.ascx" %> <%@ Register TagPrefix="usercontrol" TagName="UserName" Src="~/library/uc/UserNameDisplay.ascx" %><!DOCTYPE html PUBLI...

ERROR Content controls have to be top-level controls in a content page or a nested master page that references a master page.
This all used to work until about 5 minutes ago. Did I change something? For some reason I am now getting this error: Content controls have to be top-level controls in a content page or a nested master page that references a master page. What I have:  I have a masterpage inside of a directory. That directory is a first level directory with its own web.config file....The whole thing is protected by the web.config file above it (in the main public directory). That main public directory has a masterpage as well. I am not currently linking the two masterpages together becuase...

Error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.
when I make a directory on my root, and in that directory I put a masterpage and a web form ... I get always an error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.   Does somebody know what the problem is ? Is it possible you can't set a masterpage in a directory ... ?Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) i've founded ... I had to nest my masterpage ...Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) Hi Joeri Pansaerts, I am receiving the same error as the one posted her...

content page changing master page controls
So I have a master page.  It consists of a banner and a set of ImageButtons that run down the left side of the screen that serve as the navigation bar of my site.  At the first page, most buttons have their visibility set to false.The user logs in using forms authentication, and it is my desire to set the visibility to true on buttons based on login information. So, I set the ImageButtons up with public properties. For example:  public ImageButton MPHomeButton { get { return HomeButton; } set { HomeButton = value; } } Then, when I authenticate the user I  ...

Problem to use TreeView Control in a 'content page' This Error Occur "Only Content controls are allowed directly in a content page that contains Content controls."
hi I am trying to use the TreeView Control inside the content page (Page that has a master page is a content page). On compiling the project I got the following ASP.Net runtime error: "Only Content controls are allowed directly in a content page that contains Content controls."B@b@R J Issue resolved. I was putting script tag in the content page that is not allowed. when remove the script from content page problem is resolved.B@b@R J...

Show content in both Master Page ContentPlaceholder AND Content Page Content control
I note that by default or rendering rules, when you add content/controls to the Content Page ASP:Content control matched to a Master Page ContentPlaceholder, any content/controls in the matching Master Page ContentPlaceholder is not displayed. Is there a setting that can be made to merge or show both content/controls in the Master Page ContentPlaceholder and content/controls in the matching Content Page Content control? Thanks         Don't think so. If you specify a content control in your page then whatever is in there displays and anything in the...

Need to access a Label Control on the Master Page from a user control attached to a content page
Hello all, I have a master page (say  site.master)  with a status Label in it. I have a content page ( say content.aspx)  that has a user control (say usercontrol.ascx). One of the Button Click Events in the usercontrol.ascx needs to pass on some text onto the status label on the masterpage(LabelStatusMsg) and display it. I have been able to do this directly off a content page (content.aspx) by using the following code (VB)  on the master page <%@ MasterType virtualpath="~/site.master" %> and Dim mpLabel As Label = CType(Master.FindControl("LabelStatusMsg"),...

Content controls are allowed only in content page that references a master page.
HiI'm getting the above error with my application.Basically I had a master file and then some page files referencing the master file.In the page files I had some ajax controls so had :<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><atlas:ScriptManager ID="ScriptManager1" runat="server"></atlas:ScriptManager>in them.but when I try adding an ajax control to the master file and putting the above code in, it shows the error messagewhy would this be?thanks!  Make sure you have prop...

Control of the page and the controls on a page
I am building a web app that has some pages that are public and some that are only available based on subscription. Could someone explain the best way (infrastructure wise) how to control whether a server control is visible or enabledand how to control whether a page is viewable or not based on the user and whether or not the user is logged in (or not). If a user is not logged in I would like some controls to be visible but disabled. I also have to control the URL's in case a person learnsthe URL and tries to type it in. My question is more towards how to do this database wise. I am u...

convertion from page to content page or from user control to content page
Hi, I have converted an asp.net 1.1 application to 2.0.  Now what I am looking for some enhancement.  I added a master page and now I want to add other pages as content pages. but those pages which I am converting into content have some user control. Now either I can convert those user control to content pages ( which i want to look for if it is possible),  Or I am thinking i shouldn't convert those user control to content pages cause they might be just good. So looking for some of those people opinion who have worked through this so can I get opinion here please.thanks&nb...

Using controls from pages, master pages, and user controls
How would I structure my site in this scenario: I'd like to use a dropdownlist all over my site, sometimes in a regular page, sometimes in a master page, and sometimes in a user control.  I wish to bind its events programmatically, so normally I would just put that in the codebehind.  However, I notice a lot of code duplication because I have to declare the control in everywhere, in my base page (which all my pages inherit from), in my base master page (which all my master pages inherit from) and in my base user control (which all my user controls inherit from).How should I be...

Error:Content controls are allowed only in content page that references a master page?!!
 Hello All I have a web application, it is working well in localost without any error but when I upload it to the host it show me the error below:Any suggestion? I have not seen this error beforePlease any helpRegards, Server Error in '/' Application. Content controls are allowed only in content page that references a master page. Description: Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code. Ex...

error: Content controls are allowed only in content page that references a master page.
 I have a website that uses a masterpage. most of my users have no problem; but few get the error bellow. I was never able to duplicate the error.   ex.message: Content controls are allowed only in content page that references a master page.Stack trace:    at System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection)   at System.Web.UI.Page.get_Master()   at System.Web.UI.Page.ApplyMasterPage()   at System.Web.UI.Page.ProcessRequestMain(Boolean in...

i have 3 pages student information , i filled two pages ,then go to 3rd page . First Two pages iam having 100 controls.how to store that controls and how to send these controls into 3rd page in ?
i have 3 pages student information , i filled two pages ,then go to 3rd page . First Two pages iam having 100 controls.how to store that controls and how to send these controls into 3rd page in ?  There are a number of ways storing values. Check out: http://msdn2.microsoft.com/en-us/library/75x4ha6s.aspxhttp://www.csharphelp.com/archives/archive207.html Thanks,Karan~ Remember To Mark The Post(s) That Helped You As The ANSWER ~ Hi, Welcome to asp.net forums. Now as far as your requirements goes, the first thing that strikes me is that 100 controls are way too many to kee...

Web resources about - Change master page controls from content page - asp.net.navigation-controls

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Apple’s iOS 9.3 preview page hints at possible Control Center toggle to enable Night Shift
... If you head to the iOS 9.3 preview page on Apple Canada’s website , you can see that there’s an option to enable Night Shift from Control Center ...

#TBT: The Time Ad Age Went All-In for Gun Control
"Can there be any doubt anywhere that violence and contempt for law and order are doing their rotten best to tear American society apart? "Can ...

New Night Shift mode in iOS 9.3 could have its own Control Center toggle
In all likelihood, youll be able to toggle the new Night Shift mode in iOS 9.3 right from Control Center. It came from Canada At least thats ...

Simple free app alerts you when a program (or hacker) takes control of your webcam
... can take over your webcam without you knowing about it. That's right, malware, hackers or even government agencies like the NSA can take control ...

Cruz control: take a look at his puppet master
Cruz control by digby If you read nothing else today, read this Bloomberg article about Ted Cruz's top benefactor, the certifiably looney tunes ...

Run on Italy's Third Largest Bank? Capital Controls or Bail-Ins Next? Why Take Chances?
... "brilliant" comeback? Not a single fundamental problem with Italy, the ECB, the euro, or Europe in general has been fixed. Capital Controls ...

AlunaGeorge share "I'm In Control" ft. Popcaan
... last year to preview material off the followup to their 2013 debut Body Music, and now the first single is here. It's called "I'm In Control" ...

A guy made a remote control airplane using the fan from an old wall heater
... and old heater in his house when he realized that the blower motor inside of it could work a lot like a jet engine — so he made a remote control ...

3 Animal Control Workers Suspended After Dog Left In Van For 5 Days
Three Chicago Animal Care and Control workers responsible for leaving a dog in a van for five days have been suspended, even though the city’s ...

Resources last updated: 1/22/2016 2:58:34 AM