Search code examples
c#.neteventsbllpresentation-layer

Should I try to put asp control events into the BLL?


I have recently been learning about Data Access Layers, Business Logic Layers and Presentation Layers, but I still have a few things that aren't quite clear.

I can use the DAL and BLL with the Presentation Layer to get or set information in a database.

But I also thought about asp control events, and how I should implement them.

Should I, for example, try to put a button click event into the BLL or should I just leave it in the aspx code behind file?

And if I should put them into the BLL how would I go about doing this?

I'm not sure how to make an event call a method which is in the BLL, so any advice would be greatly appreciated.


Solution

  • If the event has to do with the business model, then you should create a method in the BLL. If it's a UI type of event, handle it in the code behind. So, for example, if the user clicks a button to calculate the shipping, in the button's click event handler (code behind) call your BLL object's CalculateShipping() method. If, however, you have a button that changes the background color of the page (I couldn't think of a better example) then you would handle that completely in the code behind.