I am looking to get a TableCell by ID (of type string). The process is similar to getElementById in JavaScript. How will I do that in C#?
For example,
var tb = document.someFunction("jks_build_1"); // this should get JKS-BUILD1
<asp:TableRow runat="server">
<asp:TableCell ID="jks_build_1" BackColor="White" ForeColor="Black">JKS-BUILD1</asp:TableCell>
<asp:TableCell ID="jks_build_2" BackColor="White" ForeColor="Black">JKS-BUILD2</asp:TableCell>
<asp:TableCell ID="jks_build_dev" BackColor="White" ForeColor="Black">JKS-BUILD-DEV</asp:TableCell>
</asp:TableRow>
我不明白您的问题,为什么您不只是打电话给物业。
var t = jks_build_1.Text;
There is likely a better way to go about this, however my first instinct is to Loop through the table row by row, cell by cell at the start of the program and build a dictionary using the ID string of the cells.
When you need to access a cell by ID, just reference that dictionary and you'll have what you need.
I also believe there is a .FindControlById() function or similar that you can call on the table, but that may or may not work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.