I\'m looking for an ideal way for my input forms to either show as a textbox (editable), label (readonly), or hidden (no access) based on the roles. I know I could have a d
You could have a custom Html Control which checks the user's role and then decide what to do.
I did this with Actionlinks, created Html.ActionLinkSecured
Namespace System.Web.Mvc.Html
{
public static class HtmlHelperExtensions
{
public static string ActionLinkSecured(this HtmlHelper htmlHelper, string linkText, string action, string controller, object routeValues, bool showDisabled)
{
//check if user is logged in or whatever you wanna check
//if ok
return htmlHelper.ActionLink(...);
//else
return linkText
}
}
You can have whatever you want... text, textbox, disabled textbox... :)