I'm having a problem, I've done several tests where I'd like to send a HTML code directly to a label from a C # method, where it would dynamically display the code on the screen. But when I send it, it does not render.
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void FillPage(int size)
{
StringBuilder sb = new StringBuilder();
sb.Append(string.Format(@"<asp:LinkButton ID='LinkButton1' runat='server' OnClick='LinkButton1_Click'><asp:Table ID='tableProd' class='tableProduto' runat='server'>
<asp:TableRow>
<asp:TableCell RowSpan='2' Width='155px'><img src='images/categorias/bebida.png' /></asp:TableCell>
<asp:TableCell Width='550px'>Nome</asp:TableCell>
<asp:TableCell RowSpan='2'>Preço</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Width='550px'><div class='divTexto'><p>Descrição</p></div></asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:LinkButton> "));
lblTexto.Text = sb.ToString();
}
}
But when the code that is sent to the label with the format it does not render on the screen. Only when it is sent this way:
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void FillPage(int size)
{
StringBuilder sb = new StringBuilder();
sb.Append(string.Format(@"<asp:LinkButton ID='LinkButton1' runat='server' OnClick='LinkButton1_Click'><table ID='tableProd' class='tableProduto' runat='server'>
<tr>
<td RowSpan='2' Width='155px'><img src='images/categorias/bebida.png' /></td>
<td Width='550px'>Nome</td>
<td RowSpan='2'>Preço</td>
</tr>
<tr>
<asp:TableCell Width='550px'><div class='divTexto'><p>Descrição</p></div></td>
</tr>
</table>
</asp:LinkButton> "));
lblTexto.Text = sb.ToString();
}
}
Neither does the LinkButton work.
How could you correct this error? Thank you all.