2016-12-11 6 views
1

私は2つのタブを持っていますが、 "Compras"と他の "Fiscal"は、ユーザーが "68"というロールを持っている場合、 "問題は、現状ではタブを開いたときにやっていることです。財政は正しく選択されていますが、Comprasというタブが開きます。カミソリで間違ったタブを開く

私はここでユーザーの許可を確認します。

ViewBag.isFiscal = false; 
        if (Web.Security.CustomPrincipal.CurrentUser().IsAuthenticated) 
        { 
         if (Web.Security.CustomPrincipal.CurrentUser().IsInRole("68")) 
         { 
          ViewBag.isFiscal = true; 
         } 
        } 

そして、ここで私はタブ年度開こう:

<ul class="nav nav-tabs"> 

     <li class="@(ViewBag.isFiscal == false ? "active" : "")"> 
       <a data-toggle="tab" href="#compras" data-etapa="78">Compras</a> 
      </li> 

    <li class="@(ViewBag.isFiscal == true ? "active" : "")"> 
      @if (Model != null && Model.IdTemplate > 0) 
      { 
       <a data-toggle="tab" href="#fiscal" data-etapa="80">Fiscal</a> 
      } 
      else 
      { 
       <a href="javascript:void(0);">Fiscal</a> 
      } 
     </li> 
</ul> 

をしかし、私は役割68を持つユーザーで開いたとき、それは次のように開きます。 enter image description here

それは財政マークされていますフォームの内容はComprasのフォームからのものですが、正しい会計はこれです: enter image description here

Som私は何が不足しているのを知っていますか?

答えて

0

解決策が見つかりました。

Comprasでアクティブまたは財政タグを置くために、私は唯一のタブComprasにアクティブタグを入れていた、そして今、私は検証を行う

<div id="compras"class="tab-pane @((bool)Session["isFiscal"] == false ? "active" : "")"> 
     @*<div id="compras" class="tab-pane active">*@ 
      @using (Html.BeginForm("Index", "Home", FormMethod.Post, new { @class = "form-horizontal form-compras", id = "frmSaveCompras", action = string.Format("{0}/home/index", pathRoot) })) 
      { 
       @Html.Partial("_abaCompra", Model, ViewData) 
      } 
     </div> 
    @if (Model != null && Model.IdTemplate > 0) 
    { 
     <div id="contabil" class="tab-pane"> 
      @using (Html.BeginForm("AbaContabil", "Home", FormMethod.Post, new { @class = "form-horizontal form-contabil", id = "frmSaveContabil", action = string.Format("{0}/home/AbaContabil", pathRoot) })) 
      { 
       @Html.Action("AbaContabil", "home", new { id = Model.IdItem, partial = (bool)ViewBag.partial, hash = (string)ViewBag.hash }) 
      } 
     </div> 

     <div id="fiscal" class="tab-pane @((bool)Session["isFiscal"] == true ? "active" : "")">> 
      @Html.Action("AbaFiscal", "home", new { id = Model.IdItem, partial = (bool)ViewBag.partial, hash = (string)ViewBag.hash }) 
     </div> 
    } 
関連する問題