Enter Key with Two Login Controls

I’m updating the upload and download parts of an ASP classic website whose main page (that I’m NOT updating) has an “Upload / Download” link that brings the user to a page with two login controls, one for upload and one for download, so I’m trying to keep that same design.

I’m trying to get the Enter key to trigger the correct “Login In” button depending on which login control the user is typing in. Currently it always does the first one on the page.

I’ve found suggestions but many involve buttons and not the login control. I tried using panels and setting the panel default to the ID showing when I inspect the page, but that gave me the error “The DefaultButton of ‘PanlUL’ must be the ID of a control of type IButtonControl.”

I tried converting the login controls to templates, changing the names of the Login In buttons to something unique and but got the same error as above. I suspect because they’re “wrapped” in the login control.

With the controls converted to templates I thought I might be able to set the default button for the form in the TextChanged events in code behind, but I don’t have access to the text boxes in code behind. I’m thinking, again, because they’re “wrapped” in the login controls.

With the controls converted to templates I also tried a JavaScript function in which I was able to get exactly what text box called the function, and I thought I could use this to set the default:

this.Page.Form.DefaultButton = $('#<%= LoginButtonDL.ClientID %>')

But visual studio is telling me that “LoginButtonDL is no declared. It may be inaccessible due to its protection level.” Again, probably because it’s part of the login control.

I also saw this page that seemed to be setting up a function that would selectively call the right button, but in my noob-ness I have no idea where this code would go. In a JavaScript Page load of some sort?

This is my first venture into any web dev so I might be missing something basic. Any help would be very appreciated.

Thanks