Pass parameter to Javascript function from ASP code behind

后端 未结 1 878
醉梦人生
醉梦人生 2021-02-10 19:07

I have a long process and I want to show a user a progress bar where I pass a parameter (percentage) to a Javascript function in my Webform with masterpage.

I have this:

相关标签:
1条回答
  • 2021-02-10 19:25

    Try this way

        string updateProgress = "18%";
        ClientScript.RegisterStartupScript(this.GetType(), "updateProgress", "updateProgress('" + updateProgress + "');", true);
    

    Script AS

       <script type="text/javascript">
        function updateProgress(percentage) {
            document.getElementById("ProgressBar").style.width = percentage;
        }
      </script>
    

    ASPX page

       <div class="progress progress-striped active progress-success" style="height: 43px">
            <div id="ProgressBar" runat="server" class="progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100"
                style="width: 0px;" >
            </div>
        </div>
    
    0 讨论(0)
提交回复
热议问题