I don't know how to apply CSS for a HTML generic control like <UL>
and <LI>
given runat="server"
in ASP.NET. I am finding the <li>
in a master page from a content page. Once I found that control I want to apply CSS.
<ul id="mainMenu" runat="server" style="width:350px;">
<li id="mainHome" runat="server"><a title="Home" href="#" class="home">Home</a></li>
<li id="mainManage" runat="server"><a title="Manage" href="#"
class="manage">Manage</a></li>
<li id="mainEnquiry" runat="server"><a title="Enquiry" href="#"
class="enquiry">Enquiry</a></li>
<li id="mainReport" runat="server"><a title="Report" href="#"
class="report">Reports</a></li>
</ul>
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.
ASP.NET Web pages function as HTML pages at run time. You can therefore use cascading style sheets (CSS) to set the appearance of any elements on the page other than Web server controls.
In HTML, there are the following types of lists: Unordered Lists (<ul>) - The list items are marked with bullets. Ordered Lists (<ol>) - The list items are marked with numbers or letters.
ASP.NET is a free web framework for building great websites and web applications using HTML, CSS, and JavaScript.
Please try this,
ull.Style.Add("background-color", "Red");
Or, I have tested this, will definitely work, please check
ull.Attributes.Add("class", "yourClass");
Edit: To test this solution I have provided you:
make new blank master page and put <ul runat="server" id="ull">
then add a new page and use the above master page.
make findcontrol ul and put in CSS as I have mentioned in the answer.
then run your page, and view source of your HTML page and you will find what you are looking for. Like
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With