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

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -