Get control Id from ItemTemplate on client side

5 posts, 1 answers
  1. Testing
    Testing avatar
    31 posts
    Member since:
    Nov 2013

    Posted 01 Feb 2014 Link to this post

    Hi,
    On client side  button click event, I want to get control id that are place in Item template of List-view
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Feb 2014 in reply to Testing Link to this post

    Hi,

    Please try the following JavaScript to access the ItemTemplate Control from Clientside.

    JavaScript:
    function OnClientClicked(sender, args) {
        var listview = $find('<%= RadListView1.ClientID %>');
        // pass id of the itemtemplate control
        var textbox = $telerik.findControl(listview.get_element().parentNode, "RadTextBox1");
    }

    Thanks,
    Shinu.
  3. Testing
    Testing avatar
    31 posts
    Member since:
    Nov 2013

    Posted 04 Feb 2014 Link to this post

    thank you its working..
  4. valli
    valli avatar
    1 posts
    Member since:
    May 2017

    Posted 12 May Link to this post

    Hi ,
    I have a RadListView which repeats items depending on the number of records retrieved from the database
    I have button,labels and textboxes and a RadAjaxPanel. The RadAjaxPanel contains textboxes and labels.
    On Initial loading, the RadAjaxPanel is invisible.
    In the Javascript code,  "var listview = $find('<%= RadListView1.ClientID %>');" is returning  null.
    My requirement is When I click on the button, the corresponding RadAjaxPanel should be made visible/Invisible(Show/Hide) using Javascript function
    Please help me out.

    I am attaching the code below for reference

    <script type="text/javascript">
    function enablePanel() {
    var listview = $find('<%= RadListView1.ClientID %>');             
     var panel = $telerik.findControl(listview.get_element().parentNode, "RadAjaxPanel1");
    }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div style="align-content: center; margin: auto; width: 900px; position: relative; top: 100px;">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <telerik:RadListView ID="RadListView1" runat="server">
    <ItemTemplate>
    <div style="background-color: lightblue; border: 1px solid black; width: 600px; margin-bottom: 10px;">
    <table>
    <tr>
    <telerik:RadButton ID="RadButton1" runat="server" Text="+" OnClientClicked="enablePanel()"></telerik:RadButton>
    </tr>
    <tr>
    <td>
    <telerik:RadLabel ID="RadLabel1" Text="Notification Number" runat="server"></telerik:RadLabel>
    </td>
    <td>
    <telerik:RadTextBox ID="RadTextBox1" Text='<%# Bind("ItrNotifNumber") %>' runat="server"></telerik:RadTextBox>
    </td>
    <td>
    <telerik:RadLabel ID="RadLabel2" Text="ItrNeId" runat="server"></telerik:RadLabel>
    </td>
    <td>
    <telerik:RadTextBox ID="RadTextBox2" Text='<%# Bind("ItrNotifExchangeId") %>' runat="server"></telerik:RadTextBox>
    </td>
    </tr>
    <tr>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Visible="false">
    <td>
    <telerik:RadLabel ID="RadLabel3" Text="Abr RefKey" runat="server"></telerik:RadLabel>
    </td>
    <td>
    <telerik:RadTextBox ID="RadTextBox3" Text='<%# Bind("AbrRefKey") %>' runat="server"></telerik:RadTextBox>
    </td>
    <td>
    <telerik:RadLabel ID="RadLabel4" Text="Notif Tcd" runat="server"></telerik:RadLabel>
    </td>
    <td>
    <telerik:RadTextBox ID="RadTextBox4" runat="server" Text='<%# Bind("Node") %>'></telerik:RadTextBox>
    </td>
    </telerik:RadAjaxPanel>
    </tr>
    </table>
    </div>
    </ItemTemplate>
    </telerik:RadListView>
    </div>       
        </form>
    </body>
    </html>

    Thanks And Regards,

    Valli

  5. swarupa
    swarupa avatar
    13 posts
    Member since:
    Aug 2016

    Posted 17 May in reply to Shinu Link to this post

    Hi,

    Using the code above I am able to retrieve the RadListView,

    But the code  var textbox = $telerik.findControl(listview.get_element().parentNode, "RadTextBox1"); is returning null.

    Please provide solution.

    Thanks,

    Swarupa

     

Back to Top