This is a migrated thread and some comments may be shown as answers.

Drag and click on a slider with items dont work the same

1 Answer 49 Views
This is a migrated thread and some comments may be shown as answers.
Andreas Selling
Top achievements
Rank 2
Andreas Selling asked on 13 Jul 2010, 01:33 PM

I have a slider that works great when I click on it but if I drag the slider to a position it does a postback and the selected slider item always go back to the previous position.

If I drag the slider to a position I want it to be handled just as if I click on a position.

Here is some code:
RadSlider assesmentSlider = (RadSlider)e.Item.FindControl("AssesmentSlider");
            assesmentSlider.ItemType = SliderItemType.Item;
            //the databinding of the slider
            Vklass.IUP.MatrixAssesment assesment = ((Vklass.IUP.MatrixAssesment)e.Item.DataItem);
            assesmentSlider.Items.Add(new RadSliderItem("Inget", ""));
            RadSliderItem sliderItem1 = new RadSliderItem("1", assesment.Text1);
            assesmentSlider.Items.Add(new RadSliderItem("2", assesment.Text2));
            assesmentSlider.Items.Add(new RadSliderItem("3", assesment.Text3));
            assesmentSlider.Items.Add(new RadSliderItem("4", assesment.Text4));
            assesmentSlider.Items.Add(new RadSliderItem("5", assesment.Text5));
            assesmentSlider.ViewStateMode = System.Web.UI.ViewStateMode.Enabled;
            assesmentSlider.AutoPostBack = false;
            //The Javascript
            assesmentSlider.OnClientValueChanged = "OnClientValueChanged" + assesmentSlider.ClientID;
            assesmentSlider.OnClientSlideEnd = "OnClientSlideEnd" + assesmentSlider.ClientID;
            string tb1 = e.Item.FindControl("SelectedAssesmentValue").ClientID;
            string hiddenvalue = e.Item.FindControl("AssesmentText0").ClientID;
            string answered = e.Item.Parent.Parent.FindControl("Answered").ClientID;
            string jsfunction = "function " + assesmentSlider.OnClientValueChanged + "(obj,args){\nvar val = '" + hiddenvalue + "' \n$get('" + tb1 + "').value = $get(val.slice(0, -1)+obj.get_value()).value;\nif(obj.get_value() != '0'){\n $get('" + answered + "').value = 'True';\n }else{ \n$get('" + answered + "').value = 'False';\n }\n$get('UpdateDocument').click()\n}\n"; ;
            string jsfunction2 = "function " + assesmentSlider.OnClientSlideEnd + "(obj,args){\n obj.set_value=obj.get_trackPosition;\n}\n"; ;

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 15 Jul 2010, 01:12 PM
Hi Andreas Selling,
The problem you describe is a result of the code that you execute in the handler for the slideEnd event of RadSlider:

string jsfunction2 = "function " + assesmentSlider.OnClientSlideEnd + "(obj,args){ obj.set_value=obj.get_trackPosition;}";

This code changes the set_value client-side method by replacing it with the get_trackPosition client-side method of the control. As a result, the value of the slider cannot change. In case you remove this code, the slider with behave as expected.

Sincerely yours,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
Andreas Selling
Top achievements
Rank 2
Answers by
Telerik team
Share this question