slider inside a repeater control

2 posts, 0 answers
  1. nechmads
    nechmads avatar
    6 posts
    Member since:
    Aug 2007

    Posted 05 Sep 2007 Link to this post

    I have a repeater control that creates for each row a RadSlider and a textbox control.
    I want the text of each text box to change accordingly to the current value of the slider.
    In your demos you show how to do it by calling a JavaScript function that updates the text box. The problem is that in the JavaScript function I don't know the id of the specific text box I want to update (as every row will have different text box with different auto generated ID).

    Basically I need functionality similar to what you get from the BoundControlId property of the Slider Extender in the Ajax control toolkit.
  2. Petio Petkov
    Admin
    Petio Petkov avatar
    825 posts

    Posted 07 Sep 2007 Link to this post

    Hello nechmads,

    I created for you an example where a Repeater control has a RadSlider and a TextBox. When the RadSlider is slided, the value in corresponding TextBox is changed.

    ASPX:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="pages_Slider_Tickets_Repeater_Default" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="rad" %>    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server">  
        <title>Untitled Page</title> 
         
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
        <div> 
        <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">  
            <ItemTemplate> 
                <rad:RadSlider ID="RadSlider1" runat="server" OnClientSlide="changeInput" /> 
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>               
            </ItemTemplate> 
        </asp:Repeater> 
        </div> 
        </form> 
    </body> 
    </html> 
     

    Code-behind:
    using System;  
    using System.Data;  
    using System.Configuration;  
    using System.Collections;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using System.Web.UI.HtmlControls;  
    using Telerik.Web.UI;  
     
    public partial class pages_Slider_Tickets_Repeater_Default : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            string[] data = new String[5] { "a""a""a""a""a" };  
            Repeater1.DataSource = data;  
            Repeater1.DataBind();  
     
        }  
        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)  
        {  
            RadSlider slider1 = (RadSlider)e.Item.FindControl("RadSlider1");  
            slider1.OnClientSlide = "OnClientSlide" + slider1.ClientID;  
                   string tb1 = e.Item.FindControl("TextBox1").ClientID;  
            string jsfunction = "function " + slider1.OnClientSlide + "(obj,args){$get('" + tb1 + "').value = obj.get_Value();}";  
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"Script"+slider1.ClientID,jsfunction,true);  
        }  
    }  
     


    Regards,
    Petio Petkov
    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
Back to Top