Access an HTML control on ASP Master Page from the code behind of a Content Page

旧巷老猫 提交于 2019-12-01 01:23:43

By the way, try

(HtmlGenericControl)currentMenu = (HtmlGenericControl) Master.FindControl("idOfTheLinkToHighlight");
currentMenu.Attributes.Add("class", "selected");

it should work because HtmlGenericControl has also attributes

Was messing around with this for a while as I needed it to be a HTML link. Turns out that you need runat="server" in the e.g.

<head runat="server" id=aHead>

Just for a reference, I needed to do something similar and in order to get it working I added the runat="server" to the body tag (thanks to this thread).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!