asp.net mvc - Render partial view based on condition -


I have some partial ideas that the user has a certain role

Now, I want to avoid doing this

  & lt;% if (user is in the role) {.. here html happens ..}% & gt;  

I want to be able to do this (at the top of ASX):

  <% this.RenderOnlyForRoles (list of roles)% & Gt;  

Now, in the BasePartialView I have a list of rolls that are populated when called RenderOnlyForRoles.

The problem is that after RenderOnlyForRoles is called .. I can think of all the events :) and I can not stop the rendering of control.

Edit: Does anyone know if other visibilities can support it? Public static zero RenderOnlyForRoles (this HtmlHelper HTML, list & lt; string & gt; roles))

   
 < P> if (check that the user is in the role) {html.RenderPartial (yourview); }}  

Mercy,

Donation


Comments

Popular posts from this blog

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

iphone - How do I make a UIPickerView in a UIActionSheet -