如何将javascript的值绑定到asp C#中的标签#

时间:2018-01-19 13:20:40

标签: javascript html asp.net

我有一个带有可更改值的Javascript rails滑块,我想将其值绑定到asp标签并在后面的代码中使用,感谢您的帮助。

拉​​布勒:

<asp:Label ID="Lbl1" runat="server" Text="Label" Visible="False"></asp:Label> 

的javascript:

<script type="text/javascript"> 
    $("#appearance7").roundSlider({
        radius: 70,
        width: 8,
        handleSize: "+16",
        handleShape: "dot",
        sliderType: "min-range",
        value: 5,
        max: 10,
        mouseScrollAction: true,
        min: 1
        });
</script>

当前值为&#34; 5&#34;但它可以由用户更改,我想将此值分配给asp标签。

1 个答案:

答案 0 :(得分:2)

&#13;
&#13;
    $("#appearance7").roundSlider({
        radius: 70,
        width: 8,
        handleSize: "+16",
        handleShape: "dot",
        sliderType: "min-range",
        value: 5,
        max: 10,
        mouseScrollAction: true,
        min: 1,
        change: "onValueChange"
        });
        
function onValueChange (e) {
    $("#Lbl1").val(e.value);
}
&#13;
<asp:Label ID="Lbl1" runat="server" Text="Label" Visible="False" ClientIDMode="Static"></asp:Label> 
&#13;
&#13;
&#13;