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
You can do that logic directly in the View
:
@if (Profileid == User.Identity.Name) {
<input type="submit" ... />
}
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.
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.