Yes, there is a way to do that. But I wonder why you need two master pages. Isn't one enough for you ? If you create to change the look and feel, It is better to play with CSS, Not master page.Anyways, Here is the solution.
Instead of putting code in each page PreInit() event, Put the same code to the master page PreInit() event.Here is MSDN article how to do this.
Working with ASP.NET Master Pages Programmatically[
^]
I hope this helps you well.