开发者

How to bind ASP.NET master page and specific event handlers in content page

开发者 https://www.devze.com 2022-12-20 23:59 出处:网络
In the master page I have a container on top of the page, which should hold buttons specific to the content page. In a content page, I have buttons like \"Create\", \"Modify\", etc...

In the master page I have a container on top of the page, which should hold buttons specific to the content page. In a content page, I have buttons like "Create", "Modify", etc... The container in the master page should always be on top, but the buttons will 开发者_如何学编程eventually change with different content. Any idea on how I can bind content page functionality to the one of the master page? Currently I have a panel in the master page and during run time, I attach the button from the content page, but the event handler is not attached and renders only a page reload. Why is that happening?

Thanks for the help!

Branko


Use so technic: you controls implements IProducer interface and your Master page implements IConsumer interface.

IProducer will generate events (commands). Consumer will handle these events. I am using event that has command name (Create, Modify...) and arguments (string). Consumer will process these commands and update view (use Model View Presenter pattern also). Controls can implement IView also. For example, I have a code that does something the ASP.NET MVC does. IView gererates events, Presenter handles them, does something with Model (business layer, or data layer) and updates the view.

Luck.


The easiest way (but not the most flexible) would be to add to your master page a new content placeholder inside the top panel and for each page to provide the buttons it needs along with any scripts and/code behind as a content for that place holder. Of course, that would make it slightly harder to mix page-specific buttons and common ones, but in most scenarios that's not needed anyway as the page-specific controls are grouped together.

0

精彩评论

暂无评论...
验证码 换一张
取 消