<asp:Panel ID="LoginSubmitPanel" DefaultButton="" runat="server">
<%--Login Control Here--%>
</asp:Panel>
Then add a load event to that panel to look for the unique id of the image button and assign the default action for this panel:
protected void LoginSubmitPanel_Load(object sender, EventArgs e)
{
//Find all the controls we will need
Login SideLogin = (sender as Login);
Control LoginButton = (SideLogin.FindControl("LoginImageButton") as Control);
Panel LoginSubmitPanel = (SideLoginView.FindControl("LoginSubmitPanel") as Panel);
//We need the UniqueName under the proper context
string btn = LoginButton.UniqueID.Remove(0, SideLoginView.UniqueID.Length + 1);
//Assign the correct button as the default action
LoginSubmitPanel.DefaultButton = btn;
}
Now when you hit the enter key in the login control, the login action will be fired. Outside of the login control will follow regular default form submission.
I was about to comment that I have never had that problem when using images for buttons, but then I realized that I'm not even using the login control! That might be why. :)
ReplyDeleteYou are lucky. That control drives me crazy.
ReplyDelete