asp.net - How to pass clientId of a control in Repeater to JavaScript function? -


i have repeater having 2 columns. in first column have image button on click of calling javascript function.

in second column have label. want pass client id of label javascript function called on click on imagebutton.

<asp:repeater id="rptelements" runat="server"> <itemtemplate> <table width="100%" border="0" cellspacing="0" cellpadding="0">     <tr>         <td>             <table>                     <tr>                         <td id="tdelementtype" runat="server">                            <asp:imagebutton id="imgshow" runat="server" visible="false" onclientclick="return displayelementdetails(this);" />                         </td>                         <td>                            <asp:label id="lblelementdetails" text='<%# eval("elementdetails")%>' runat="server" />             </td>                         </tr>         </table>     </td> </tr> </table> </itemtemplate> </asp:repeater> 

i figured out. added following code javascript function:

function displayelementdetails(obj)             {                 var name = obj.id.substring(0,(obj.name.length)-7) + "lblelementdetails"                 var obj = document.getelementbyid(name);                 obj.style.display = 'none';                 return false;             } 

and set style label control

<asp:label id="lblelementdetails" text='<%# eval("elementdetails")%>' runat="server" style="display:block" /> 

its working now.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -