HtmlGenericControl Class
When you try to dynamically change inner content of a HTML control in ASP.Net then something happens. In this article you will see how to change an inner content of HTML control tags like <ul and <li> dynamically using HtmlGenericControl class. Or the HtmlGenericControl is used to control other HTML elements not specified by a specific HTML server control, like <body>, <div>, <span>, <font>, <p>, <ul>, <li> and so on.
Suppose you create a menu with submenu items in HTML. In this situation the inner content of the HTML control tags will not changed. So you can write HTML tags to make that easy as in the following code.
- <ul id="main" class="menu">
- <li><a href="http://www.Home.com">Home</a></li>
- <li><a href="http://WWW.technology.com">Technology</a>
- <ul>
- <li><a href="http://www.c-sharpcorner.com">Android Programing</a></li>
- <li><a href="http://www.c-sharpcorner.com">Android Programing</a></li>
- </ul>
- </li>
- <li><a href="http://www.help.com">Help</a>
- <ul>
- <li><a href="http://www.vbdotnetheaven.com">Contact Us</a></li>
- <li><a href="http://www.dotnetheaven.com">Advertise with us</a></li>
- <li><a href="http://www.microsoft.com">Sitemap</a></li>
- </ul>
- </li>
- </ul>
Press F5 to run it.
Now if you want the inner HTML of <ul> and <li> to be changed you can use the HtmlGenericControl class.
When you create this using SQL Server database the inner content of the HTML control will be changed. The "HtmlGenericControl" class created by declaring the <ul> and <li> elements on the ASP.Net page provides the <ul> and <li> elements with access to the "InnerHtml" property.

Shail SPosted May 3, 2016, 6:30 AM
Rohatash, How can we expand and collapse the child list items when the parent item is clicked. Please help..
G CPosted Apr 14, 2016, 10:42 AM
how to with linq to sql?