How To in EJ 1 ASP.NET MVC Tab
28 Feb 2019 / 1 minute to read
Add a tab item dynamically based on condition
To add tab item dynamically based on condition, we can use the conditional operators to check and add the items within the items property. Refer to the following code.
@{Html.EJ().Tab("defaultTabs").Items(data =>
{
data.Add().ID("reviews").Text("Reviews").ContentTemplate(@<div>@{ Html.RenderPartial("_ReviewList"); }</div>);
if (user == "admin") { // check the condition to load the item in tab
data.Add().ID("calendar").Text("Calendar").ContentTemplate(@<div> @{ Html.RenderPartial("_Calendar"); }</div>);
}
}).ShowRoundedCorner(true).Render();}
In the above code, based on the “user” the second tab will be displayed.
Was this page helpful?
Yes
No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page