我不知道如何申请CSS的HTML通用控制像< UL>
和< LI>
给 =服务器
在ASP.NET中。我发现了<李>在从内容页的母版页
。有一次,我发现,控制我想申请CSS。
< UL ID =MAINMENU=服务器的风格=宽度:350像素;>
<李ID =mainHome=服务器><一个标题=首页的href =#级=家与GT;家< / A>< /李>
<李ID =mainManage=服务器><一个标题=管理HREF =#
类=管理>管理< / A>< /李>
<李ID =mainEnquiry=服务器><一个标题=查询的href =#
类=询问和GT;查询及LT; / A>< /李>
<李ID =mainReport=服务器><一个标题=报告的href =#
类=报告>报告< / A>< /李>
< / UL>
解决方案
请试试这个,
ull.Style.Add(背景色,红);
或者说,我已经测试了这一点,肯定会正常工作,请检查
ull.Attributes.Add(类,yourClass);
编辑: 为了测试这个解决方案,我提供你:
请新的空白母版页,并把与LT; UL =服务器ID =ULL>
然后添加一个新的页面,并使用上述母版页。
做的FindControl UL,放在CSS正如我刚才提到的答案。
然后运行你的页面,你的HTML页面中查看源代码,你会发现你在找什么。像
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>
解决方案
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
相关推荐
最新文章