Show HTML text in ASP TextBox?

1

I'm trying to show text formatted in HTML in a asp text box and I'm not able to.

For example this formatted text: <font size="6">teste</font> , I would like that when I display this text in text box it is already formatted, it currently appears with tags , as above.

Is there any way through code behind without using eval or bind ?

    
asked by anonymous 03.07.2015 / 00:51

1 answer

0

I believe that what you want is <asp:Literal> , it serves just to display some static text, be HTML or not.

Example:

<form runat="server">
    <asp:Literal id="meuLiteral" runat=server />
</form>

And on your CodeBehind :

protected void Page_Load(object sender, EventArgs e)
{
    meuLiteral.Text = "<font size="6">teste</font>";
    meuLiteral.Mode = LiteralMode.PassThrough; /* sem modificações */        
}

TextBox with CSS

Now if you want a% s of% s, just create a CSS selector :

.textbox
{ 
   font-size: 12px;
}

And in your component:

<asp:TextBox ID="TextBox1" CssClass="textbox" runat="server"></asp:TextBox>

TextBox <asp:textBox> Dynamic

protected void Page_Load(object sender, EventArgs e)
{
    meuTextBox.Font.Size = FontUnit.Large;
}
    
03.07.2015 / 01:29