For ASP.Net, I know I can make a lot of different HTML elements runat="server" so I can do specific things to it from the server, but I'm not able to get a TH to runat="server".
Why not?
example:
<table>
<tr>
<td id="tdMyCell" runat="server"></td>
<th id="thMyCell" runat="server"></th>
</tr>
</table>
but from server side, I'm only able to access the TD. I've tried to two lines below, the first won't compile and the second always returns a null object.
thMyCell.Visible = false;
(this.FindControl("thMyCell") as System.Web.UI.HtmlControls.HtmlTableCell).Visible = false;
Update:
My fault, I copied something and I didn't change it before I posted... it's been fixed in the code
This might be a forehead slapper, but:
Because your th is called "thMyCell", not "thLastColumn"
If your implementation is as straight forward as your example, you should have a problem with this. It doesn't give me any issues, and compiles without any errors.
<table>
<tr>
<th id="test" runat="server"></th>
</tr>
</table>
In the code-behind intellisense picks it up as an HtmlTableCell
, but that shouldn't be a problem:
test.ColSpan = 2;
If this isn't working for you, I would try to isolate it - create a new web form and paste in the markup I have above, then try to access it in the code-behind. Intellisense should pick it up without a problem, and the form should compile just fine.
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.