I am supporting a really old legacy application that is about to be taken down which is written in aspx. I have a <div>
element inside a page (Example.aspx) that I am trying to make visible in the code behind (Example.aspx.cs) based on a checkbox checked value. However I keep getting this Cannot get inner content of '' because the contents are not literal
error and thus my div is not being rendered. I referred to this SO post: Cannot get inner content of '' because the contents are not literal which mentions that this will not work on controls that are run on the server i.e runat="server"
. I cannot access the Wordpress url referenced in the one answer from this SO post that was suggested: Cannot get inner HTML - and this one (Cannot manage to change the inner html of a div element) is not applicable to my question.
Example.aspx:
<div id="testID" runat="server"> <!--some content ---></div>
Example.aspx.cs:
protected void checkBoxName_CheckedChanged(object sender, EventArgs e)
{
if(!checkBoxName.Checked)
testID.Visible = true; //The exception is thrown here
}