I’m looking for a way to add some code to execute in all Page_Load events on all pages of my web application, without have to write it in all the pages.
The code must execute before the Page_Load methods on the pages.
Thanks for the attention.
I’m looking for a way to add some code to execute in all Page_Load
Share
You can create one Class let say BasePage.cs, and here you will have one virtual method Page_Load:
Then, in every page where you want to execute this code on PageLoad, make that page to inherit from BasePage and override the PageLoad method, like this:
in file somePage.aspx.cs do this: