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

Create slider at run time

2 Answers 53 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Ibrahim Imam
Top achievements
Rank 1
Ibrahim Imam asked on 03 Oct 2007, 09:02 AM
Hello,
i have a problem when creating a rad slider at run time,in my web application i want to add the slider to specific placeholder when the user clicks on a link button
the problem is the slider is only added once, when i try to add the slider again
(as i want to add many sliders when i click on the button) there is an exception raised )
by the way when i use this method to add simple control like text box it is added ok

the add code is as follow
protected void uxLbtnAddOption_Click(object sender, EventArgs e) 
    { 
         aSliders.Add(new RadSlider()); 
       Session["Sliders"] = aSliders;//aSlider is a static arraylist        
 
 
        if (Session["Sliders"] != null
        { 
            ArrayList aContainerSliders = (ArrayList)Session["Sliders"]; 
            foreach (RadSlider slider in aContainerSliders) 
            { 
                uxPholderSliders.Controls.Add(slider); 
                
            } 
        } 
   
    } 



Thank you
Ibrahim Imam

2 Answers, 1 is accepted

Sort by
0
Sophy
Telerik team
answered on 04 Oct 2007, 11:42 AM
Hi Ibrahim Imam,

Thank you for your feedback.

You need to recreate all RadSliders in each postback. Therefore, you should override the OnInit method and put there the desired functionality. I attached a sample application demonstrating how to realize this saving RadSliders in the session. You can view it by yourself in the Default1 page.

There is a better way to have the same functionality if you save RadSliders in the viewstate. Use the Default2 page to see how you can do this.

If something is unclear or you have any other questions, do not hesitate to contact us again.

All the best,
Sophy
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ibrahim Imam
Top achievements
Rank 1
answered on 04 Oct 2007, 12:56 PM
hi sophy
Thanx for your clever clue.it works fine with me, by the way i was recreating all RadSliders in each postback in Pageload event, but when i made this on the onInit it as you described it works ok now
Tags
Slider
Asked by
Ibrahim Imam
Top achievements
Rank 1
Answers by
Sophy
Telerik team
Ibrahim Imam
Top achievements
Rank 1
Share this question
or