Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 690913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:29:07+00:00 2026-05-14T02:29:07+00:00

I have an asp.net mvc 2 app. I need to display the same page

  • 0

I have an asp.net mvc 2 app. I need to display the same page to each user. But each user has different rights to the data. IE some can see but not edit some data, some cannot edit nor see the data. Ideally data that cannot be seen nor edited is whitespace on the view. For security reasons I want my viewmodels to be sparse as possible. By that I mean if a field cannot be seen nor edited , that field should not be on the viewmodel. Obviously I can write view for each view model but that seems wasteful. So here is my idea/wishlist

Can I decorate the viewmodel with attributes and hook into a pre render event of the html helpers and tell it to do   instead???

Can I have the html helpers output   for entries not found on the viewmodel??

or

can I easily convert a view built into code then programaticlly build the markup and then put into the render engine to be processed and viewd as html on client side??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:29:08+00:00Added an answer on May 14, 2026 at 2:29 am

    The way you’ve phrased the question, I’m afraid any answer would result in a quite complex view. Deciding which view to display (and which view model to build) dependent on roles of the user is the responsibility of the controller.

    EDIT 1: Response to comment

    Could you do something like this?

    <% if (Model.AllowEdit) { %>
        <%= Html.TextBoxFor(x => x.SomeProperty); %>
    <% } else if (Model.AllowView) { %>
        <%= Html.Encode(Model.SomeProperty) %>
    <% } else { %>
        <span>You may not view this property.</span>
    <% } %>
    

    This could translate into a helper control.

    public static ExtensionsOfHtmlHelper
    {
        public static MvcHtmlString DynamicTextBox(this HtmlHelper html, Func<TModel, object> lambda, bool edit, bool view)
        {
            if (edit)
            {
                return html.TextBoxFor(lambda);
            }
            else if (view)
            {
                return html.LabelFor(lambda);
            }
            else
            {
                return MvcHtmlString.Create("<span>You may not view this value.</span>");
            }
        }
    }
    

    Then, in your view,

    <%= Html.DynamicTextBox(x => x.SomeProperty, Model.AllowEdit, Model.AllowView) %>
    

    Something close-ish to that should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC app and I want to add to each page
I have an interesting situation where I need to deploy an ASP.NET MVC app
I am building a ASP.NET Mvc app. I have a Data model say User
I have an ASP.NET MVC app which has a bootstrapper class that configures log4net
My team has a new Asp.net MVC intranet app. I have been doing some
Currently I have an MvcSiteMap integrated with my ASP.Net MVC app. I need to
In my ASP.Net MVC app, I have the following controllers HomeController ExController ExController has
I have an ASP.NET MVC web app and have a function that I need
In my ASP.NET MVC 3 app I have a page where, after its form
I have an asp.net mvc app running on a local iis website that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.