KEy points:
1. LEft menu for different users
2. using sitemaster with userControls
i need to take sitemaster and webform usercontrols and content pages can anyone help me with that im helpless idk about usercontrols
Loading
KEy points:
1. LEft menu for different users
2. using sitemaster with userControls
i need to take sitemaster and webform usercontrols and content pages can anyone help me with that im helpless idk about usercontrols
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jefferson S. MottaRank #207 · 11.7K reputationPosted Nov 1, 2023, 1:51 AM EDT
You're working on a web application and would like to implement a login functionality with role-based navigation (e.g., different left menus for different users) using a Master Page and User Controls in ASP.NET. Let me guide you through the process step by step.
1. Create a new ASP.NET Web Application:
2. Setup the Database:
3. Create the Master Page:
4. Create Login Page:
5. Implementing User Controls:
6. Role-Based Left Menu:
7. Content Pages:
8. Securing Pages:
User Controls in ASP.NET are reusable components used across multiple pages. Here's a step-by-step guide to create two different menus using User Controls:
Step 1: Creating the User Controls
Create the First Menu User Control:
MenuAdmin.ascxor something relevant.Create the Second Menu User Control:
MenuUser.ascxor something relevant.Step 2: Populating the Menus
Step 3: Using the User Controls in the Master Page
Step 4: Displaying the Menus Based on User Roles
protected void Page_Load(object sender, EventArgs e) { if (User.IsInRole("Admin")) { MenuAdmin.Visible = true; MenuUser.Visible = false; } else if (User.IsInRole("User")) { MenuAdmin.Visible = false; MenuUser.Visible = true; } }Step 5: Running Your Application
Code Sample in Master Page:
In the body or any placeholder, use the registered user control tags:
Adjust the visibility of the menus in the code-behind based on the user roles or any other conditions you wish to apply. This way, you get reusable menu components to manage and modify separately.