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

Masterpage - Only show menu if logged in (authenticated)

4 Answers 513 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Benson Group
Top achievements
Rank 1
Benson Group asked on 17 Jun 2016, 12:38 PM

Good morning,

I started a new ASPX web site application, and chose to use the responsive theme.

What I am trying to do, is only show the nav menu once I am logged in (with session variable, or other suggestion).

I tried using some <% if session[varisset] %> code within the master page, but I get "code blocks are not supported in this content.

I am also trying to code the masterpage.master to have an on load() that would redirect to login.aspx if not authenticated as well, but obviously not to continually redirect there if the web page is already at login.aspx.

could anyone help me out with this? or point me in the right direction?

Let me know if you require more info.

4 Answers, 1 is accepted

Sort by
0
Benson Group
Top achievements
Rank 1
answered on 21 Jun 2016, 12:14 PM

Is anyone able to help me out with this?

At the very least how to put if statements in a telerik code block?
Thanks

0
Nencho
Telerik team
answered on 22 Jun 2016, 07:05 AM
Hello,

You can manage the session variable at server-side in the code-behind of the Master Page that you use. For example, you can handle Page_Load and manage the visibility of the Menu, if the preferred session variable is set to a given value.

As for the Login page redirect - you can implement this directly in your web.config. Please refer to the following thread, where such implementation is described:

http://stackoverflow.com/questions/10955596/how-can-i-have-asp-net-automatically-redirect-non-logged-in-forms-users-to-the-l?answertab=votes#tab-top

Regards,
Nencho
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Benson Group
Top achievements
Rank 1
answered on 23 Jun 2016, 02:46 PM

"You can manage the session variable at server-side in the code-behind of the Master Page that you use. For example, you can handle Page_Load and manage the visibility of the Menu, if the preferred session variable is set to a given value."

 

how exactly would this be done? at the moment, the menu portion is all in the MasterPage.Master (not the .cs page).

would my menu have to be written in the code behind? or? I am just not sure how to do this.

thanks

0
Nencho
Telerik team
answered on 28 Jun 2016, 12:15 PM
Hello,

No, you are not obligated to dynamically create the RadMenu, in order to be able to manage its visibility state, base on a session variable.

In the attachment you can find a sample project, demonstrating a possible variant of implementation.

Regards,
Nencho
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
General Discussions
Asked by
Benson Group
Top achievements
Rank 1
Answers by
Benson Group
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or