473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Displaying HTMl with htmlGenericControl

I have a web page that has a placeholder on it called PlaceHolderText. I
read some html out of the database. The value for my test is:

this is <strong>a test </strongof the html stuff

I read that into a variable that I call htmlData (it's a string)

htmlData = reader["html"].ToString();

Then, after making sure that htmlData is good and all, I do the following
two lines:

HtmlGenericControl ctl = new HtmlGenericControl(@htmlData);
PlaceHolderText.Controls.Add(ctl);

That outta show the data, with the appropriate words bolded. Instead it
shows the following (nothing bolded).

a test of the html stuff>a test of the html stuff>

Going through the debugger the value of htmlData is exactly what I expect it
to be. It gets muddied up by the htmlgenericcontrol

Anybody got a clue for me? Just a hint?

--
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus
Aug 21 '06 #1
2 10047
Rik,
You aren't looking at your Intellisense. When you create an
HtmlGenericControl, it wants a tag name. Then you can set the other
properties (such as InnerHTML). Example:

private void Page_Load(object sender, System.EventArgs e)
{
string s="this is <strong>a test</strongof the html stuff";
HtmlGenericControl ge = new HtmlGenericControl("div");
ge.InnerHtml=s;
this.PlaceHolder1.Controls.Add(ge);
}

BTW, this probably belongs on the ASP.NET newsgroup as it is quite "ASP.NET"
specific.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Rik Brooks" wrote:
I have a web page that has a placeholder on it called PlaceHolderText. I
read some html out of the database. The value for my test is:

this is <strong>a test </strongof the html stuff

I read that into a variable that I call htmlData (it's a string)

htmlData = reader["html"].ToString();

Then, after making sure that htmlData is good and all, I do the following
two lines:

HtmlGenericControl ctl = new HtmlGenericControl(@htmlData);
PlaceHolderText.Controls.Add(ctl);

That outta show the data, with the appropriate words bolded. Instead it
shows the following (nothing bolded).

a test of the html stuff>a test of the html stuff>

Going through the debugger the value of htmlData is exactly what I expect it
to be. It gets muddied up by the htmlgenericcontrol

Anybody got a clue for me? Just a hint?

--
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus

Aug 21 '06 #2
Thank you, Peter, this works great.

I'll try to find the asp.net newsgroup. I didn't see it. You're probably
right that's where it belongs
--
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus


"Peter Bromberg [C# MVP]" wrote:
Rik,
You aren't looking at your Intellisense. When you create an
HtmlGenericControl, it wants a tag name. Then you can set the other
properties (such as InnerHTML). Example:

private void Page_Load(object sender, System.EventArgs e)
{
string s="this is <strong>a test</strongof the html stuff";
HtmlGenericControl ge = new HtmlGenericControl("div");
ge.InnerHtml=s;
this.PlaceHolder1.Controls.Add(ge);
}

BTW, this probably belongs on the ASP.NET newsgroup as it is quite "ASP.NET"
specific.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Rik Brooks" wrote:
I have a web page that has a placeholder on it called PlaceHolderText. I
read some html out of the database. The value for my test is:

this is <strong>a test </strongof the html stuff

I read that into a variable that I call htmlData (it's a string)

htmlData = reader["html"].ToString();

Then, after making sure that htmlData is good and all, I do the following
two lines:

HtmlGenericControl ctl = new HtmlGenericControl(@htmlData);
PlaceHolderText.Controls.Add(ctl);

That outta show the data, with the appropriate words bolded. Instead it
shows the following (nothing bolded).

a test of the html stuff>a test of the html stuff>

Going through the debugger the value of htmlData is exactly what I expect it
to be. It gets muddied up by the htmlgenericcontrol

Anybody got a clue for me? Just a hint?

--
----------------------------------------
Magic is not in the hands of the magician but in the mind of the audience.

Animadverto est verus
Aug 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hawk | last post by:
I have a custom menu control that I am creating using C#. I am rendering HTML from a StringBuilder in my control to add the needed JavaScript to the HTML output. I need to have the JavaScript...
2
by: Linus Martinsson | last post by:
How can I change attribute in html elements from my aspx.cs page? For example if I want to change the src-attribute in an iframe. //Linus
5
by: David Elliott | last post by:
I need a control on a Web Page that can accept an HTML Document and will display it. Any help would be appreciated. Thanks, Dave Here is what I was trying...
3
by: localhost | last post by:
I need to write an XML namespace declaration in my HTML tag. It must be done in the code-behind for the page, I can't edit the .aspx template directly. I need to turn this: <HTML> into...
8
by: Randall Parker | last post by:
I want to generate an HTML tag that will look like: <a href="EquipmentServiceCreate.aspx?serial=X01">Create New Service For X01</a> or on a different instance where the user would be viewing...
2
by: CharlesA | last post by:
Hi folks, I'm using ASP.net with Framework vs 1.1 I'm inheriting from a custom rolled master page class that is just that a class that inherits from web.ui.page but it has no designer associated...
5
by: Rik Brooks | last post by:
I am writing a web application using C#. I've come to the point that I need to display some html text that is stored in a database. Is there a server side control that I can use to show the html?...
2
by: Mike P | last post by:
I have a HTML menu that I want to add some C# code around which will include a variable declaration and an if statement. How do I add this code within my HTML? *If statement here, if true then...
5
by: =?Utf-8?B?ZWdzZGFy?= | last post by:
I had to create a HTML textbox to add the date time but I don't know how to assign the value with asp.net, how can I do that? This is my HTM Textbox code: <input id="txtFechaPlan"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.