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

How to enable/disable control inside repeater client-side???

3 Answers 1113 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Giulio
Top achievements
Rank 1
Giulio asked on 03 Oct 2009, 02:47 PM
Hi all, I have an ASP.NET repeater and inside it, some Telerik Web Controls (as shown below)
<asp:Repeater ID="rptAreeScopertura" runat="server"
                    <HeaderTemplate> 
                        <table class="Tabella"
                            <tr> 
                                <th class="CellaIntestazione" style="width: 40px;"
                                    <asp:Label ID="lblSelezionaTitolo" runat="server" /> 
                                </th> 
                                <th class="CellaIntestazione" style="width: 200px;"
                                    <asp:Label ID="lblAreaScoperturaTitolo" runat="server" /> 
                                </th> 
                                <th class="CellaIntestazione" style="width: 80px;"
                                    <asp:Label ID="lblTipoScoperturaTitolo" runat="server" /> 
                                </th> 
                                <th class="CellaIntestazione" style="width: 140px;"
                                    <asp:Label ID="lblTipoServizioInclusoTitolo" runat="server" /> 
                                </th> 
                                <th class="CellaIntestazione" style="width: 350px;"
                                    <asp:Label ID="lblTipoPeriodicitaOffertaTitolo" runat="server" /> 
                                </th> 
                            </tr> 
                    </HeaderTemplate> 
                    <ItemTemplate> 
                        <tr> 
                            <td style="text-align: center;"
                                <input type="checkbox" id="chkProva" value='<%# Eval("IDAreaScopertura") %>' runat="server" 
                                    onclick="toggleTB(this);" /> 
                            </td> 
                            <td> 
                                <asp:Label ID="lblAreaScopertura" runat="server" Text='<%# Eval("AreaScopertura") %>' /> 
                            </td> 
                            <td> 
                                <telerik:RadComboBox ID="rRadComboBoxTipoScopertura" runat="server" /> 
                            </td> 
                            <td> 
                                <telerik:RadComboBox ID="rRadComboBoxTipoServizioIncluso" runat="server" /> 
                            </td> 
                            <td style="text-align: center;"
                                <telerik:RadComboBox ID="rRadComboBoxTipoPeriodicitaOfferta" runat="server" /> 
                                <asp:Label ID="lblOppure" runat="server" /> 
                                <telerik:RadTextBox ID="rRadTextBoxTipoPeriodicitaPersonalizzata" runat="server" /> 
                            </td> 
                        </tr> 
                    </ItemTemplate> 
                    <FooterTemplate> 
                        </table> 
                    </FooterTemplate> 
                </asp:Repeater> 
I would chkProva checkbox to enable/disable all controls inside repeater item.
How can I get it client-side? Is it possible?

I've tried with the following javascript code in the HEAD tags
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
 
        <script type="text/javascript"
 
            function toggleTB(what) { 
                var RadComboBox = $find("<%= rRadComboBoxTipoScopertura.ClientID %>"); 
                RadComboBox.enabled = what.checked; 
            } 
 
        </script> 
 
    </telerik:RadCodeBlock> 

but I get the following errore message at runtime:
Name 'rRadComboBoxTipoScopertura' not declared. 
 
Error in the following code source (Row 11): 
 
Row 9:   
Row 10:             function toggleTB(what) { 
Row 11:                 var RadComboBox = $find("<%= rRadComboBoxTipoScopertura.ClientID %>"); 
Row 12:                 RadComboBox.disable(); 
Row 13:             } 

because (I suppose) it can't find the rRadComboBoxTipoScopertura control inside repeater...

In alternative it could be done server-side with an Ajax Panel solution... but how?

Thanks to all!

Giulio

3 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 07 Oct 2009, 08:02 AM
Hi Giulio,

Try using the following modified JS function.

<script type="text/javascript"
 
        function toggleTB(what) { 
            var combo = $find("<%= rRadComboBoxTipoScopertura.ClientID %>"); 
            if (what.checked == true) { 
                combo.disable(); 
            } 
            else { 
                combo.enable(); 
            } 
        }  
  
    </script> 


Regards,
Paul
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Giulio
Top achievements
Rank 1
answered on 08 Oct 2009, 06:29 AM
Thanks fort your answer, but the problem is the same: the function $find() can't reach a webcontrol if it is inside the repeater.

Is there another way to manage controls inside repeater from javascript code?

Thanks.

GF
0
Princy
Top achievements
Rank 2
answered on 08 Oct 2009, 01:34 PM
Hi Giulio,

You can probably use a global registry to store the nested control's ID and emit script for every server control when an item is added to the global registry. Thereby, on looping over all registered elements and the required controls server ID can be retrieved.
You can check out the following code library which explains on how to access the server controls nested inside templates on the client, to understand better:
Accessing server controls in a grid template on the client

Hope this helps..
Princy.
Tags
General Discussions
Asked by
Giulio
Top achievements
Rank 1
Answers by
Paul
Telerik team
Giulio
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or