2016-03-27 10 views
1

新規ユーザーの登録時に、登録とログインのリンクを非表示にしたい。これは、「登録がほぼ完了しました。メールを確認してメールアドレスを確認してください」と表示されます。現在のビューに基づいて_LoginPartial.cshtmlの登録とログインリンクを非表示にするMVC 5

以下は、権限のないユーザーの「else文」です。 View _LoginPartialが挿入されていると判断できる場合は、登録ユーザーのリンクを非表示にすることができます。現在

else 
{ 
    <ul class="nav navbar-nav navbar-right" style="background-color:darkblue;"> 
     <li>@Html.ActionLink("Register", "Register", "Account", routeValues: new { @returnUrl = "/StoreMaster/Stores/PickLocation" }, htmlAttributes: new { id = "registerLink", style = "color:white;" })</li> 


     <li>@Html.ActionLink("Log in", "Login", "Account", routeValues: new { @returnUrl ="/StoreMaster/Stores/PickLocation"}, htmlAttributes: new { id = "loginLink", style = "color:white;" })</li> 
    </ul> 
} 

私は入れたい: 「ビュー== thisViewNameは、これらのリンクを非表示にした場合、」

答えて

1

をビューに名前を取得し、状態でそれを使用することができます下図のように:このことができます

@{ 
    var pageName = ViewContext.RouteData.Values["Action"].ToString(); 
} 

@if (pageName != "DisplayEmail") 
{ 
    <div class="navbar-collapse collapse" style="background-color:darkblue;"> 

    <ul class="nav navbar-nav"> 
     <li>@Html.ActionLink("Latest", "Latest", "Stores", routeValues: null, htmlAttributes: new { @style = "color:white;" })</li> 
     <li>@Html.ActionLink("HowTo", "HowTo", "Shuttles", routeValues: null, htmlAttributes: new { @style = "color:white;" })</li> 
     <li>@Html.ActionLink("Contact Us", "ContactUsPublic", "Stores", routeValues: null, htmlAttributes: new { @style = "color:white;" })</li> 
     @*<li>@Html.ActionLink("Pick something", "PickSomething", "Stores", routeValues: null, htmlAttributes: new { @style = "color:white;" })</li>*@ 
    </ul> 
    } 

    @Html.Partial("_LoginPartial") 

    </div> 
} 

希望...

+0

は私の答えを参照してください。あなたが私のものと一致するようにそれを編集すれば、私はあなたを受け入れます。または閉じる – JustJohn

+0

私は自分の答えを更新しました。ありがとう:) –

+0

はい。本当にありがとう! – JustJohn

関連する問題