displaying html code in a textbox control
displaying html code in a textbox control
am 16.04.2008 13:25:43 von Ned White
Is it possible to insert HTML codes to a textbox control ?
I am reading HTML formated string from sql server but if i assign this value
to Text property of TextBox, the format tags of HTML seems too...
sample string value from database:
Sales Contract
Paragraph 7.
Buyer has the right to examine the goods upon receipt and has ____ days in
which to notify seller of any claim for damages based on the condition,
grade, quality or quality of the goods. Such notice must specify in detail
the particulars of the claim. Failure to provide such notice within the
requisite time period constitutes irrevocable acceptance of the goods.
The string is asked for in a textbox because of the scrollbars of textbox,
Are there any solutions to display html codes in textbox control or any
suitable control for this ...?
Thanks....
Re: displaying html code in a textbox control
am 16.04.2008 14:00:25 von George Ter-Saakov
Do Server.HtmlEncode before assigning this to the Text property....
George.
"Ned White" wrote in message
news:emb8qS7nIHA.2064@TK2MSFTNGP05.phx.gbl...
> Is it possible to insert HTML codes to a textbox control ?
>
> I am reading HTML formated string from sql server but if i assign this
> value to Text property of TextBox, the format tags of HTML seems too...
>
> sample string value from database:
>
> Sales Contract
> Paragraph 7.
> Buyer has the right to examine the goods upon receipt and has ____ days in
> which to notify seller of any claim for damages based on the condition,
> grade, quality or quality of the goods. Such notice must specify in
> detail the particulars of the claim. Failure to provide such notice
> within the requisite time period constitutes irrevocable acceptance of the
> goods.
>
>
> The string is asked for in a textbox because of the scrollbars of textbox,
>
> Are there any solutions to display html codes in textbox control or any
> suitable control for this ...?
>
> Thanks....
>
Re: displaying html code in a textbox control
am 16.04.2008 15:08:01 von rossum
On Wed, 16 Apr 2008 14:25:43 +0300, "Ned White" wrote:
>Are there any solutions to display html codes in textbox control or any
>suitable control for this ...?
As well as George's suggestion, you could use a WebBrowser control and
use its DocumentText property to load your text into it.
rossum
Re: displaying html code in a textbox control
am 16.04.2008 15:32:05 von Ned White
Hi George ,
I am trying this.
TextBox1.Text = Server.HtmlEncode(DT.Rows[0][1].ToString());
But it seems in textbox like that:
<P class=MsoNormal style="MARGIN: 0cm 0cm
0pt"><B><SPAN \r\nstyle="FONT-SIZE:
11pt">Sales Contract <?xml:namespace prefix = o ns =
\r\n"urn:schemas-microsoft-com:office:office"
/><o:p></o:p></SPAN></B></P>\r\n<P
class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN
\r\nstyle="FONT-SIZE:
11pt"><o:p> </o:p></SPAN></B></P>\r\n
but the value is :
\r\nstyle=\"FONT-SIZE: 11pt\">Sales Contract
\r\n\"urn:schemas-microsoft-com:office:office\"
/>
\r\n
0pt\">
11pt\"> \r\n
Re: displaying html code in a textbox control
am 16.04.2008 15:39:44 von Ned White
by the way, I forgot that it is a c# web project and i am trying this on a
web form not a windows form.
Sory for the mistake..
Re: displaying html code in a textbox control
am 16.04.2008 16:43:37 von ignacio.machin
On Apr 16, 9:39=A0am, "Ned White" wrote:
> by the way, I forgot that it is a c# web project and i am trying this on a=
> web form not a windows form.
>
> Sory for the mistake..
Hi,
Good clarification :)
Just a Label, instead. Or a Literal control
Re: displaying html code in a textbox control
am 16.04.2008 17:37:40 von George Ter-Saakov
If you using WebControls then they will do Server.HtmlEncode automaticly.
So TextBox1.Text = DT.Rows[0][1].ToString();
That is why you end up encoding twice.. so becomes <img> and
then becomes &asmp;lt;img>
If you using HtmlControsl they do not do that so you will need
TextBox1.Value = Server.HtmlEncode( DT.Rows[0][1].ToString() );
PS: I wish WebControls did not do encode too...
George.
"Ned White" wrote in message
news:Os3qTZ8nIHA.4716@TK2MSFTNGP06.phx.gbl...
> Hi George ,
>
> I am trying this.
>
> TextBox1.Text = Server.HtmlEncode(DT.Rows[0][1].ToString());
>
> But it seems in textbox like that:
> <P class=MsoNormal style="MARGIN: 0cm 0cm
> 0pt"><B><SPAN \r\nstyle="FONT-SIZE:
> 11pt">Sales Contract <?xml:namespace prefix = o ns =
> \r\n"urn:schemas-microsoft-com:office:office"
> /><o:p></o:p></SPAN></B></P>\r\n<P
> class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><B><SPAN
> \r\nstyle="FONT-SIZE:
> 11pt"><o:p> </o:p></SPAN></B></P>\r\n
>
> but the value is :
>
> \r\nstyle=\"FONT-SIZE: 11pt\">Sales Contract
> = \r\n\"urn:schemas-microsoft-com:office:office\"
> />
\r\n
> 0pt\">
> 11pt\">
\r\n
>
>
>
>
Re: displaying html code in a textbox control
am 16.04.2008 19:26:15 von Ned White
Thanks George,
I use Panel control and
tag combination instead of textbox.
the aspx code:
BorderStyle="Solid" BorderWidth="1px"
ScrollBars="Auto" Style="padding:10px">
and the code-behind part:
ForTheDocs.InnerHtml = Server.HtmlDecode(DT.Rows[0][1].ToString());
Thanks a lot.