Display HTML text in ASP Textbox?

Asked

Viewed 1,481 times

1

I’m trying to show a text formatted in HTML in a asp text box and I’m not getting.

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

Is there any way through the code behind unused eval or bind?

  • You want your textbox (ex.: <input type="text" />) is formatted (CSS)?

  • I’m using <asp:TextBox>, I want the contents to be automatically formatted. I use AjaxTooKit to the HTMLEditorExtender.

  • Sorry, I don’t think I can help. I can only change the general CSS.

  • All I wanted was for asp text box showed the formatted text and not the tags.

1 answer

0


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

Example:

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

And in his 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 one <asp:textBox> really, just create a css selector:

.textbox
{ 
   font-size: 12px;
}

And in its component:

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


Textbox FontSize Dynamic

protected void Page_Load(object sender, EventArgs e)
{
    meuTextBox.Font.Size = FontUnit.Large;
}
  • It worked, but there’s some way to put information like that textbox?

  • @Chiraggeiantilal If you want to use one TextBox for the user to type and change the font size just create a CSS class

  • Default user uses the HtmlEditorExtender of AjaxToolKit, hence the formatting is never predefined.

  • @Chiraggeiantilal Update my answer, see if any answers.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.