User Control access from code behind problem
I have a user control called adminMenu and I use it in my index.aspx and all is fine, but I need to access a MenuItem in adminMenu and need to change NavigateUrl on the MenuItem. Tried this code with no luck:
MenuItem MaintenanceReports = this.adminMenu.FindItem("MaintenanceReports");
No开发者_运维百科t sure if I should be accessing adminMenu properties from controls code behind, but when I try from controls code behind was not able to access it either, any ideas would be appreciated.
Create a property in the adminMenu user control that return the Menu such as the code below
public Button MyButton
{
get { return this.btnTest; }
}
From the page you can write
this.adminMenu.MyButton.Text = "test";
Problem was MenuItem I was searching for was actually a Sub-MenuItem an I needed to include path.
MenuItem MaintenanceReports = this.adminMenu.FindItem("Reports/MaintenanceReports");
精彩评论