简体   繁体   中英

Change Progress Bar width using C# in MVC application

for (i = 0; i < 100; i++) 
{
$('#theprogressbar').attr('aria-valuenow', i).css('width', 100 + '%');
$("#bar").css({ width: i + "%" });
$("#progressWidth").css({ width: i + "%" });
$("#barlabel").html(i + "%");
}

<div id="theprogressbar" class="progress progress-bar " role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100">
    <span class="progress-meter" id="progressWidth">
        <span class="progress-meter-text" id="barlabel"></span>
    </span>
</div>

able to change progress bar width from Javascript. but i need to change progressbar width from controller side using c# now i need to change the progreebar width using c#. please help me. thanks in advance.

You can use AJAX to connect to Controller and return value to change progress bar

        $.ajax({  
            type: "POST",  
            url: '@Url.Action("YourAction")',  
            data: '{std: ' + JSON.stringify(yourdata) + '}',  
            dataType: "json",  
            contentType: "application/json; charset=utf-8",  
            success: function (data) {  
              // Handler change progress bar
              data.Width
            },  
            error: function () {  
                alert("Error while inserting data");  
            }  
        });  

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM