tony_trotter
asked on
Problem Accessing the Button within the Login Control LayOutTemplate
I'm sure there is probably an easy sanswer to this but I'm tired of working on it. Maybe someone out there has a quick answer to this.
I have a login control that exists within a panel. I have converted the Login control to a template and would like to set the LoginButton of the Login control to be the DefaultButton of the panel. Simple . . . .Right? Wrong. I can't seem to make the code find the LoginButton. Here is the code I tried to use. What did I do wrong?
Dim btnLoginButton As New Button
btnLoginButton = Me.loginbox.FindControl("L oginButton ")
pnlBackground.DefaultButto n = "btnLoginButton"
Thanks in Advance.
Tony
I have a login control that exists within a panel. I have converted the Login control to a template and would like to set the LoginButton of the Login control to be the DefaultButton of the panel. Simple . . . .Right? Wrong. I can't seem to make the code find the LoginButton. Here is the code I tried to use. What did I do wrong?
Dim btnLoginButton As New Button
btnLoginButton = Me.loginbox.FindControl("L
pnlBackground.DefaultButto
Thanks in Advance.
Tony
ASKER
Thanks but I'm not sure if this will work for me because the page has a couple other "DefaultButtons". That's why I have the control in a panel, because I want the defaultbutton to be focus sensitive. On this website my "Search" feature is already (and needs to be) the Default page button.
Thank you very much though!
I'm hoping for insight into how to access THAT LoginButton in THAT Login control. Surely, there is a way to do it. Isn't there?
OH!
I guess it would be helpful to let everyone know the error that I get when I use the code in my original message. It is:
"The DefaultButton of 'pnlBackground' must be the ID of a control of type IButtonControl."
Thank you very much though!
I'm hoping for insight into how to access THAT LoginButton in THAT Login control. Surely, there is a way to do it. Isn't there?
OH!
I guess it would be helpful to let everyone know the error that I get when I use the code in my original message. It is:
"The DefaultButton of 'pnlBackground' must be the ID of a control of type IButtonControl."
I have exactly the same issue, have you managed to sort it out yet?
Thanks.
Thanks.
ASKER
No not yet. Still hopeful. I'm sure someone will eventually see this and have an answer. (I hope)
ASKER
I'm increasing the reward on this question. Can anyone help us out here??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked Beautifully!!!!!!
I knew it had to be a simple solution. I just couldn't see it.
Thank you SO much!!!
For anyone else who has had this problem, the following code made the "Enter Key" kick off my button_click event on my Login control when it had focus but still allowed the page default button to work when the login control DID NOT have focus.
Protected Sub loginbox_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles loginbox.Load
Page.Form.DefaultButton = CType(loginbox.FindControl ("LoginBut ton"), Button).UniqueID
End Sub
I knew it had to be a simple solution. I just couldn't see it.
Thank you SO much!!!
For anyone else who has had this problem, the following code made the "Enter Key" kick off my button_click event on my Login control when it had focus but still allowed the page default button to work when the login control DID NOT have focus.
Protected Sub loginbox_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles loginbox.Load
Page.Form.DefaultButton = CType(loginbox.FindControl
End Sub
public void DefaultButton(System.Web.U
{
//Sets default buttons.
System.Text.StringBuilder sScript = new System.Text.StringBuilder(
sScript.Append("<SCRIPT language=\"javascript\">\n
sScript.Append("function fnTrapKD(btn){\n");
sScript.Append(" if (document.all){\n");
sScript.Append(" if (event.keyCode == 13)\n");
sScript.Append(" { \n");
sScript.Append(" event.returnValue=false;\n
sScript.Append(" event.cancel = true;\n");
sScript.Append(" btn.click();\n");
sScript.Append(" } \n");
sScript.Append(" } \n");
sScript.Append("}\n");
sScript.Append("</SCRIPT>\
objTextControl.Attributes.
this.Page.RegisterStartupS
}