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

Get control Id from ItemTemplate on client side

4 Answers 244 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Testing
Top achievements
Rank 1
Testing asked on 01 Feb 2014, 11:57 AM
Hi,
On client side  button click event, I want to get control id that are place in Item template of List-view

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 03 Feb 2014, 04:19 AM
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.
0
Testing
Top achievements
Rank 1
answered on 04 Feb 2014, 06:25 AM
thank you its working..
0
valli
Top achievements
Rank 1
answered on 12 May 2017, 11:25 AM

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

0
swarupa
Top achievements
Rank 1
answered on 17 May 2017, 10:53 AM

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

 

Tags
ListView
Asked by
Testing
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Testing
Top achievements
Rank 1
valli
Top achievements
Rank 1
swarupa
Top achievements
Rank 1
Share this question
or