change element in another page asp.net
I have a master page and I want to change his elements from different page. Actually the goal is to create the site management page, it will be possible开发者_JS百科 for example to change a master page menu.
Thanks.
Provide a public method in your MasterPage that changes it's content, for example:
public void changeMenuSource(object dataSource)
{
this.Menu.DataSource = dataSource;
this.Menu.DataBind();
}
Then you can call it from your ContentPages as well as from any UserControl inside of any ContentPage in the following way(YourMasterPage
is the actual type of the MasterPage):
((YourMasterPage)this.Page.Master).changeMenuSource(newDataSource);
I assume your site management uses some kind of database? Store menu (menu nodes) in database (create tables or scheme of tables) and use that as your menu source. On site management page create commands for insert/update menu nodes for specific page, on your pages (or masterpage) create read commands for inserted/updated values and render your menu from source.
Here is example I used it before:
http://aspalliance.com/822_Building_a_Database_Driven_Hierarchical_Menu_using_ASPNET_20
精彩评论