Reputation: 682
i have this in my controller action in MVC
if (Profileid == User.Identity.Name)
{
ViewBag.Data = true;
}
i want to hide a button or link in my view when this condition is met.how do i go about this in my View. I am using Razor view. thanks
Upvotes: 0
Views: 5181
Reputation: 839
Try: If you want based on ViewBag try this:
@if(ViewBag.Data == true)
{
//Put code here.
}
Or based on ProfileId:
@if(ProfileId == User.Identity.Name)
{
//Put code here.
}
Upvotes: 0
Reputation: 35399
You can do that logic directly in the View
:
@if (Profileid == User.Identity.Name) {
<input type="submit" ... />
}
Upvotes: 2