Passing value from code-behind to Javascript

后端 未结 5 938
粉色の甜心
粉色の甜心 2021-01-19 03:59

I am using a jQueryUI ProgressBar to show users how much allowed file storage they have used. The percentage is calculated in code-behind and should be passed to Javascript.

5条回答
  •  佛祖请我去吃肉
    2021-01-19 04:27

    since your hidden field is a server control it could be that the ID is getting generated to something other than filesPercentage (probably something like ctl00_ctl00_filesPercentage)

    • You may need to apply the generated client ID to your javascript document.getElementById("<%=filesPercentage.ClientID%>").value;
    • Or use another way of selecting the hidden value, such as $('[hidden's parent element] input[type="hidden"]').val()

    additionally, it looks like progressbar value is expecting a number, so you may need to do value: pct * 1 or value: parseInt(pct)

    http://jsfiddle.net/pxfunc/QyZSs/

提交回复
热议问题