如何将值设置为Slider范围,从asp.net后面的代码

时间:2017-08-23 04:45:57

标签: c# jquery asp.net slider

我有这样的代码:

<input type="text" id="amount" runat="server" name="amount" class="adv-search-amount"  style="width:850px"/>

<div id="slider-range" class="rangeslider"></div>


<script type="text/javascript" >
    $("#Button_Filter").click(function () {
        var min = $("#slider-range").slider("option", "values")[0].toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
        var max = $("#slider-range").slider("option", "values")[1].toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
        document.getElementById('TBRangeHargaMin').value = min
        document.getElementById('TBRangeHargaMax').value = max
    });
</script>

我希望将值设置为后面代码的滑块范围。

1 个答案:

答案 0 :(得分:0)

只要您的HTML元素具有runat="server"属性,您就可以在代码中设置任何值或属性:

// Option 1
amount.Attributes.Add("Value", "20");

// Option 2
amount.Value = "20";    

与您的其他元素相同:

TBRangeHargaMin.Attributes.Add("Value", "20");
TBRangeHargaMin.Value = "20";