I see that there were a lot of questions about getting ClientID in ASP.NET, but all the questions I looked did not help for my scenario. I'm a little new to ASP.NET and have problems getting the ClientID DataGrid in JavaScript.
Hope someone in this forum helps me find a way.
On my aspx page, I have a datagrid:
<div class="tblgrid" id="divItems">
<asp:DataGrid ID="dgItems" runat="server" AutoGenerateColumns="False" GridLines="None">
<Columns>
<asp:BoundColumn HeaderText="EmpId" DataField="EmpId">
</asp:BoundColumn>
<asp:BoundColumn HeaderText="F_Name" DataField="F_Name">
</asp:BoundColumn>
<asp:BoundColumn HeaderText="L_Name" DataField="L_Name">
</asp:BoundColumn>
<asp:BoundColumn DataField="City" HeaderText="City">
</asp:BoundColumn>
.....
</Columns>
When I use the following in my JavaScript, it returns the corresponding HTML code for the table in the warning message.
alert(document.getElementById('ct100_PageContent_dgItems').innerHTML);
but when I use the ASP.NET client ID, I get an exception with a null value because it throws a null value.
alert(document.getElementById('<%=dgItems.ClientID %>').innerHTML);
Can anyone help me in this regard.
Thanks in advance.