i had the same problem (login control in page and imagebutton in
masterpage).
the whole asp.net page is usually a form so you have to set the default
button for that main form.
in the Page_Load function of your web page get a reference to the main
form ("form1") which is in master page:
HtmlForm mainform = (HtmlForm)Master.FindControl("form1");
then get a reference to your login button in the login control (convert
your login control in a editable template and you'll see the ID of the
button, however this ID is not directly accessable yet, you have to
search for it with FindControl):
Button loginbtn = (Button)myLoginControl.FindControl("LoginButton");
your main form then wants a unique ID of the default button:
mainform.DefaultButton = loginbtn.UniqueID;
here's the complete code:
protected void Page_Load(object sender, EventArgs e)
{
myLoginControl.Focus();
HtmlForm mainform = (HtmlForm)Master.FindControl("form1");
Button loginbtn =
(Button)myLoginControl.FindControl("LoginButton");
if (mainform != null && loginbtn != null)
{
mainform.DefaultButton = loginbtn.UniqueID;
}
}
Visit new version of this Blog
Do you mean when you input the username and password, press the enter key on keyboard, the login.aspx just refresh and you still doesn't get login
Posted by Ahmad Sheikh at Friday, August 24, 2007Labels: asp.net
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment