Menu Control Help

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi all,

I have added a menu control on my Masetr Page, I added the links that I
wanted to add, Question is I would like some of those links to either not be
visable on certain pages or at the very least not be enabled for navigation
untill the user has gone to a certain page to say log in and then those
links become enabled or visable. I have not been able to figure out how to
refer to the menu control located on the maser page from the other pages in
the site? I am sure it is something easy but I just have not figured out
how to accomplish this yet.

I tried a work around by just adding another menu item on the page i want
the new navigation link to show up on, althoug it works it is not such a
good solution as trying to line it up correctly with the other links etc...

any help would be greatly appreaciated,

Thanks,

Jeff
 
I have not been able to figure out how to refer to the menu control
located on the MasterPage from the other pages in the site?

Menu mnuMaster = (Menu)Master.FindControl("mnuMenu");
 
Hi Mark,

Thanks for the response. Now i guess I will show my lack of knowledge even
further now by saying I do not really understand this

Menu mnuMaster = (Menu)Master.FindControl("mnuMenu");

Here is what I believe I am understanding

Menu mnuMaster - I am creating a new instance of a menu

("mnuMenu"); - This should be the name of the menu control on the master
page

(Menu)Master.FindControl - This is the part that is going to the mater page
to get a copy of the menu control?

Ok so on my Master page I have a menu Control mnuMenu1 and it has 4 menu
items Home; CreateUser ; SearchPage; Contact Us

I am not wanting the SearchPage menu item to visible and/or enabled until
after they go to the CreateUser page

so after successful completion of creating a user name the SearchPage menu
item should become visible and/or enabled

I put the line of code in that you gave as Menu mnuMyNewMenu =
(Menu)Master.FindControl("mnuMenu1");

No errors given there but just trying some thing simple to see if i could
get it working I tried mnuMyNewMenu.Visible = false;

It did not like that, it threw an exception error so I guess I am still not
understanding just how this works to access the menu / menu items.?

Thanks,

Jeff
 
Ok,
I had a typo on the first part, so I am now able to make my whole menu
..visable = false and that works the navigation menu disapears, but I can not
figure out how to get to the menu items such as SearchPage?

in vb i could access the menu item by menu1.Items(2).enabled = false and
that would make the menu item at index 2 disabled but that does not work in
c# is there something that is equivilent?

Thanks, Jeff
 
[please don't top-post]
I had a typo on the first part, so I am now able to make my whole menu
.Visible = false and that works the navigation menu disappears, but I can
not figure out how to get to the menu items such as SearchPage?

In VB i could access the menu item by menu1.Items(2).enabled = false and
that would make the menu item at index 2 disabled but that does not work
in C# is there something that is equivalent?

Menu mnuMaster = (Menu)Master.FindControl("mnuMenu1");
mnuMaster.Items[2].Enabled = false;
 
Mark Rae said:
[please don't top-post]
I had a typo on the first part, so I am now able to make my whole menu
.Visible = false and that works the navigation menu disappears, but I can
not figure out how to get to the menu items such as SearchPage?

In VB i could access the menu item by menu1.Items(2).enabled = false and
that would make the menu item at index 2 disabled but that does not work
in C# is there something that is equivalent?

Menu mnuMaster = (Menu)Master.FindControl("mnuMenu1");
mnuMaster.Items[2].Enabled = false;

Thanks again Mark,

That did the trick, I also found a way by doing this,

Menu mnuMyNewMenu = (Menu)Master.FindControl("mnuMasterNavigation");
mnuMyNewMenu.FindItem("Home").Enabled = false;

and also how to add a link if I want.

MenuItem Test = new MenuItem("Test");
mnuMyNewMenu.Items.Add(Test);
mnuMyNewMenu.FindItem("Test").NavigateUrl = "Default.aspx";

Thanks again for the help!!

Jeff
 
MenuItem Test = new MenuItem("Test");
mnuMyNewMenu.Items.Add(Test);
mnuMyNewMenu.FindItem("Test").NavigateUrl = "Default.aspx";

Or even simpler:

MenuItem Test = new MenuItem("Test");
Test.NavigateUrl = "Default.aspx";
mnuMyNewMenu.Items.Add(Test);
 
Back
Top