I'm trying to add href attribute to list controls in master page in the page load function based on the type of person logged in the website.
1.first step is to make a call to database to get name of the form,module of the form(i.e, in which category it belongs), and control id to which form gets added, this result i'm storing in list.
list.Add(new Tuple<string, string, string>(dr["FormName"].ToString(), dr["ModuleName"].ToString(), dr["controlid"].ToString()));
2.now i want to find the control in master page which i have received from the database. and add href attributes to only those id's.
foreach(var v in list)
{
var cont= Page.FindControl(v.Item3);
cont.Attributes.Add("href", "~/" + v.Item2 + "/" + v.Item1);
}
but its not working i don't know how to achieve it. neither i'm able to find the control nor it i can add attributes to it because cont.Attributes.add is not a method.
my aspx code:
<li id="liCRM" runat="server" class="dropdown full-length">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">CRM</a>
<div class="dropdown-menu">
<ul>
<li class="custom-header text-capitalize">
<a href="#"><i class="glyphicon glyphicon-chevron-right"></i>CRM</a></li>
<li class="topmenu"><a id="CRM1" runat="server">Leads / Enquiries</a></li>
<li class="topmenu"><a id="CRM2" runat="server">Tasks / Works</a></li>
i have already tried this :
HtmlAnchor ct = (HtmlAnchor)Page.FindControl(v.Item3);
ct.Attributes.Add("href","~/" + v.Item2.Substring(4) + "/" + v.Item1);
ct is always null. :( please help