I have a web page with an empty div, id="PreAcquisitionDiv" runat="server"
In the C# code-behind, on Page_Load, I build up a table and set it to PreAcquisitionDiv.InnerHtml
My page displays OK. I cause a PostBack, intending to change the data in the table. In the code, the PreAcquisitionDiv.InnerHtml does change, but the table I put there the first time is still displayed on the page instead.
I have seen some warnings about using InnerHtml at all, but the examples of alternatives that I have seen are JavaScript.
I am using IE 8, but I observe the same behavior in Chrome.
Thank you for any suggestions!
For example, this code displays "SomeStuff" when it first displays the page; then still "SomeStuff" after the PostBack even though the InnerHtml was changed.
protected void Page_Load( object sender, EventArgs e )
{
StringBuilder html = new StringBuilder( @"<TABLE BORDER='1' WIDTH='100%'>" );
if( !IsPostBack )
{
html.Append(@"<TR><TD>SomeStuff</TD></TR>" );
}
else
{
html.Append( @"<TR><TD>Some New Stuff</TD></TR>" );
}
html.Append( @"</TABLE>" );
this.PreAcquisitionDiv.InnerHtml = html.ToString( );
}