Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
For such a simple HTML text:
HTML
<div class="image-title">Title #0</div>

I wrote the code below:
HTML
HtmlGenericControl htmlAnchor_div2 = new HtmlGenericControl("div");
htmlAnchor_div2.Attributes.Add("class", "image-title");

But I don't know how to add the text 'Title #0' with the HTML control.
Thanks if you can help.
Posted

1 solution

You are almost there:

http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlcontainercontrol.innertext(v=vs.85).aspx[^]

HtmlGenericControl htmlAnchor_div2 = new HtmlGenericControl("div");
htmlAnchor_div2.Attributes.Add("class", "image-title");
htmlAnchor_div2.InnerText = "Title #0";
 
Share this answer
 
Comments
[no name] 7-May-14 15:09pm    
Wonderful! Solution accepted. Thanks.
Manas Bhardwaj 7-May-14 15:27pm    
thx!
Sergey Alexandrovich Kryukov 7-May-14 15:24pm    
5ed.
—SA
Manas Bhardwaj 7-May-14 15:27pm    
thx SA!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900