Reputation: 3147
I am using Jquery progress bar control on asp.net form to show the percentage of completed work for inspector. Here is the client side function for progress bar.
<script>
$(function () {
$("#progressbar").progressbar({
value: 37
});
});
</script>
<form id="form1" runat="server">
<div id="progressbar"></div>
</form>
Is there any way to set progress bar value from code behind page? Values are read from database.
Upvotes: 0
Views: 5179
Reputation: 67
You may want to try:
ScriptManager.RegisterClientScriptBlock(Me.Page, Me.Page.GetType(), "progressbar", "ShowProgressBar("+ 35 +");", True)
Upvotes: 0
Reputation: 3729
You can use registerstartupscript to inject the script from ASP.NET code behind files.
myScript = "\n<script type=\"text/javascript\" language=\"Javascript\" id=\"EventScriptBlock\">\n";
myScript += "ShowProgressBar(35);"; //35 is dynamic value
myScript += "\n\n </script>";
Page.ClientScript.RegisterStartupScript(this.GetType(), "myKey", myScript, false);
JavaScript Code
function ShowProgressBar(value)
{
$("#progressbar").progressbar({
value: value
});
}
Upvotes: 1
Reputation: 3495
Try below steps
DB
value to hidden field
on page load. like (HiddenFieldID.value="37" // from DB
)hidden field
value to set the value to progress bar in js function as below.$(function () {
$("#progressbar").progressbar({
value: $("#<%= HiddenFieldID.ClientID %>").val();
});
});
Upvotes: 0