Starr Duskk
asked on
NoUISlider retrieving and populating values from code behind
I am using a NoUISlider in asp.net and want to know how to retrieve the values for the slider. It is a multi-slider, so needs to return the left and right sides.
From what I've determined by reading, I will attach a javascript method to the save button.
Then the javascript will store the values to two hidden elements and I'll use those server side.
Code would look something like this:
I read that it retrieves the values as an array.
How do I retrieve and store the values to the hidden fields?
Also, any suggestions for populating the values on page load with existing values?
Anyone have an existing method?
thanks!
From what I've determined by reading, I will attach a javascript method to the save button.
btnSave.Attributes.Add("onClick", "SaveSlider();return true;")
Then the javascript will store the values to two hidden elements and I'll use those server side.
Code would look something like this:
function SaveSlider() {
var slider = document.getElementById('slider-tooltips');
var values = slider.noUiSlider.get();
// var values = $('#exampleSlider0').noUiSlider('value');
document.getElementById("hdnSlider1").value = values(0);
document.getElementById("hdnSlider2").value = values(1);
}
I read that it retrieves the values as an array.
How do I retrieve and store the values to the hidden fields?
Also, any suggestions for populating the values on page load with existing values?
Anyone have an existing method?
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It says hdnSlider1 on page load.
I found the problem after tracking down that even the retrieval of the hidden field value was erroring in an alert.
I had to set the hidden field as static:
Not the js at all.
Thanks so much and sorry!
I found the problem after tracking down that even the retrieval of the hidden field value was erroring in an alert.
I had to set the hidden field as static:
<asp:HiddenField ID="hdnSlider2" ClientIDMode="Static" runat="server" />
Not the js at all.
Thanks so much and sorry!
ASKER
Thanks so much!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Open in new window
My code looks like this:
Open in new window