Displaying HTMl with htmlGenericControl

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 </strong> of 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?
 
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</strong> of 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
 
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 said:
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</strong> of 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 said:
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 </strong> of 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?

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top