Create slider at run time

3 posts, 0 answers
  1. Ibrahim Imam
    Ibrahim Imam avatar
    69 posts
    Member since:
    Jul 2007

    Posted 03 Oct 2007 Link to this post

    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. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 04 Oct 2007 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ibrahim Imam
    Ibrahim Imam avatar
    69 posts
    Member since:
    Jul 2007

    Posted 04 Oct 2007 Link to this post

    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
Back to Top