This is a migrated thread and some comments may be shown as answers.

Event after menu loaded in master page

6 Answers 383 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Bernie
Top achievements
Rank 1
Bernie asked on 02 Jul 2020, 02:57 AM

I'm looking for a server side event that will fire after the menu has been rendured in the master page but before control is passed to the main page. So effectively before OnLoad. 

 

Any suggestions? 

The application is translating a website built with MS tools and they filter the menu system based on the logged in user on the computer. 

 

Thanks!

6 Answers, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 06 Jul 2020, 02:15 PM

Hello Bernie,

If you set the Visible property of the MenuItem, then it will never be rendered on the client. 

With that said, even if you set the .Visible property of the items in any PageLoad event, the Item will not be sent to the client.

Regards,
Peter Milchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Bernie
Top achievements
Rank 1
answered on 06 Jul 2020, 02:19 PM

That would be fine. That's the objective of the code. Only show the menu items the user is allowed to see.

My question is, is there an event that fires at the end of the master page but before the child page starts

 

 

 

 

 

0
Peter Milchev
Telerik team
answered on 06 Jul 2020, 02:37 PM

Hello Bernie,

The ContentPage's Page_Load is fired before the MasterPage's Page_Load. After the MasterPage's Page_Load is fired the RadMenu's OnLoad event is fired (the menu is in the MasterPage).

  1. Page_Load from ContentPage
  2. Master Page_Load
  3. RadMenu Load from Master
  4. ContentPage Page_LoadComplete
With that said, I am not quite sure why such an event is needed and why another event is not used. For example, the PreRender event of the MasterPage can also be used to set the Visible=false property of the menu items and they will still be not rendered.

Regards,
Peter Milchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Bernie
Top achievements
Rank 1
answered on 06 Jul 2020, 02:52 PM

"... I am not quite sure why such an event is needed ..."

I'm refactoring someone else's code. They have the menu modification code in every page on the website. I'd like to move that code to the Master page so it only appears once. That code needs to be run after the menus are instantiated, but still in the Master page. Hence the need for some event that I can hook.

Thank you for the list of operation;

1. Page_Load from ContentPage
2. Master Page_Load
3, RadMenu Load from Master
4, ContentPage Page_LoadComplete

I'm looking for an event to hook between items 3 and 4.

 

 

 

0
Peter Milchev
Telerik team
answered on 06 Jul 2020, 03:05 PM

Hello Bernie,

As the MasterPage does not have a Page_LoadComplete event, you can either use the Page_Load of the MasterPage itself or the Page_PreRender of the MasterPage.

As you can see, the RadMenu's Load event is after the ContentPage's Load event, you can use this event also. 

Regarding the events between the inner control's Load event and the ContentPage's LoadComplete, I am not quite there is such an event.

Regards,
Peter Milchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
1
Bernie
Top achievements
Rank 1
answered on 06 Jul 2020, 04:03 PM

In case anyone comes along that needs this. I found that Page_PreRender does the job for me. It fires after all the controls on the master page are instantiated but obviously before it renders. A couple of good references on master and content page events are;

https://www.c-sharpcorner.com/blogs/sequence-of-events-in-master-and-content-pages1

https://www.red-gate.com/simple-talk/dotnet/asp-net/asp-net-master-pages-tips-and-tricks/

https://odetocode.com/articles/450.aspx

 

Tags
Menu
Asked by
Bernie
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Bernie
Top achievements
Rank 1
Share this question
or