How to display count number of screen in Bootstrap

Hi Everyone,

I have make a tab menu with the help of bootstrap in my asp.net mvc application.
and i want to display a number of screen(Count) of the under home tab.
and display count in a button name then after number of count.

Here, my code:

@{
    ViewBag.Title = "";
    <script src="~/Scripts/jquery-1.9.1.min.js"></script>
    <link href="~/Content/bootstrap.css" rel="stylesheet" />
    <script src="~/Scripts/bootstrap.min.js"></script>
}
 
<html>
<body>
    <div>
        <ul class="nav nav-tabs" role="tablist">
             <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
</ul>
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="home">
                <br />
                <br />
                <button class="btn btn-primary" type="button">
                    Total Screens
                </button>
                @foreach (var item in ViewBag.scr)
                {
                    <li>@item</li>
                }
            </div>

Please help me.

Thank you.



Last updated:3/28/2016 12:35:08 AM

1 Answers

Anupam Mishra
Anupam Mishra

Hi Sachin,


You use this code: 
<div>
        <ul class='nav nav-tabs' role='tablist'>
             <li role='presentation' class='active'><a href='#home' aria-controls='home' role='tab' data-toggle='tab'>Home</a></li>
            @foreach (var item in ViewBag.scr)
            {
                 <li role='presentation'><a href='#adminpanel' aria-controls='adminpanel' role='tab' data-toggle='tab'>@item</a></li>
            }
        </ul>
        <div class='tab-content'>
            <div role='tabpanel' class='tab-pane active' id='home'>
                <br />
                <br />
                <button class='btn btn-primary' type='button'>
                    Total Screens <span class='badge'>@ViewBag.count</span>
                </button>
                <br />
                <br />
                <br />
                @foreach (var item in ViewBag.scr)
                {
                    <li>@item</li>
                }
            </div>
        </div>
    </div>


In Controller :
ViewBag.count = ScreenList.Count();

Output:



Answer