If you move the panel inside the login's template:-
<asp:login id="Login2" runat="server" loginbuttontype="Image">
<layouttemplate>
<asp:panel id="Panel1" runat="server" defaultbutton="LoginImageButton">
Then it will work without code.
You can set loginbuttontype="Image" by Image,Link or button.