I have a Login control placed inside LoginView control contained within a PANEL. I want to set login button as the default button for this panel. It is not possible in design view to set the default button. So i am trying to set 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 am getting both the controls i.e. Panel and Button but the code generates the following error message -
The DefaultButton of 'Panel1' must be the ID of a control of type IButtonControl.
I have also tried using UniqueID instead of ClientID but still the same problem.
Can anyone help me out, how this error can be rectified? Thanks for sharing your time.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)