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

slider inside a repeater control

1 Answer 227 Views
Slider
This is a migrated thread and some comments may be shown as answers.
nechmads
Top achievements
Rank 1
nechmads asked on 05 Sep 2007, 12:01 PM
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.

1 Answer, 1 is accepted

Sort by
0
Petio Petkov
Telerik team
answered on 07 Sep 2007, 09:03 AM
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
Tags
Slider
Asked by
nechmads
Top achievements
Rank 1
Answers by
Petio Petkov
Telerik team
Share this question
or