'Access html control from server side .aspx.cs

I have a table with a tbody in my aspx with the id fileslist, I need to inject the tr td from the server, the problem is that at runtime aspx changes the name of the id to ctl00_ContentPlaceHolder1_fileslist, this is my code

var html = "";

        foreach (var item in list)
        {
            html += $"<tr>" +
                        $"<td class='row_files'>{item.NAME_DOC}</td>" +
                        $"<td class='row_files'><button class='btn-delete-file' type='button'>Delete</button></td>" +
                    $"</tr>";
        }

        fileslist.InnerHtml = html;

aspx add ctl00_ContentPlaceHolder1_fileslist to the id, How can i solve this? Thanks



Solution 1:[1]

It is default behavior of the framework that all ID's of serverside controls are made unique when rendered. You can override this behavior by adding:

<table id="fileslist" runat="server" ClientIDMode="Static" ... >

Of course you have to make sure yourself then, that no two controls have the same ID.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tim-