I have a Login control located inside a LoginView control contained in a PANEL. I want to set the login button as the default button for this panel. It is not possible to set a default button in a design. Therefore, I am trying to install it using code.
Below is the code:
protected void SetDefaultButtonForLoginControl()
{
Login loginCtrl = (Login)LoginView1.FindControl("Login1");
Panel panel1 = (Panel)LoginView1.FindControl("Panel1");
if (loginCtrl != null)
{
Button btn = (Button)loginCtrl.FindControl("btnLogin");
if (btn != null)
{
panel1.DefaultButton = btn.ClientID;
}
}
}
I get both controls, i.e. panel and button, but the code generates the following error message -
DefaultButton 'Panel1' must be the identifier of the IButtonControl control.
I also tried using UniqueID instead of ClientID, but still the same question.
- , ? , .