Reputation: 11
i have some LIST controls in my master page to that list i want to add attributes such as href attribute from code behind of master page based on some criteria if he is admin or user etc. i have tried
Control mycontrol=FindControl(v.Item1) ///v.Item1 im getting from database which is actual id of control in my aspx code
mycontrol.Attributes.Add("href","~/sales.aspx")/// this is not working
please help im new to asp.net
Upvotes: 0
Views: 657
Reputation: 915
Just use HTMLAnchor or HTML Control
//Example 1
HtmlAnchor ct = (HtmlAnchor)FindControl("CRM1");
ct.Attributes.Add("href", "~/Test.aspx");
//Example 2
HtmlControl ct2 = (HtmlControl)Page.Master.FindControl("CRM2");
ct2.Attributes.Add("href", "~/Test.aspx");
Just tested. Both worked for me in my Master page
Upvotes: 2