Default Button
Got a problem...I have an ascx with a password box and a RadButton on it. When I hit enter in the password box I'm being redirected back to my homepage. So I'm assuming enter is triggering the first menu item, or some other link on my page which navigates back to ~/
So how in the usercontrol can I override that behavior to use the radbutton instead?
<
telerik:RadPageView
ID
=
"passwordPageView"
runat
=
"server"
Selected
=
"true"
DefaultButton
=
"submitButton"
>
<
h3
><
asp:Literal
ID
=
"titleTextLiteral"
runat
=
"server"
Text
=
"Please type in the password provided"
/></
h3
>
<
telerik:RadTextBox
ID
=
"passwordBox"
runat
=
"server"
TextMode
=
"Password"
/>
<
telerik:RadButton
ID
=
"submitButton"
runat
=
"server"
OnClick
=
"OnSubmit_Click"
Text
=
"Go"
UseSubmitBehavior
=
"true"
/>
<
asp:Label
ID
=
"statusLabel"
runat
=
"server"
ForeColor
=
"Red"
/>
<
p
style
=
"margin-top: 10px"
>If believe you should have access, please contact: <
br
/><
a
href
=
"mailto:support@ocfp.on,ca"
>support@ocfp.on.ca</
a
></
p
>
</
telerik:RadPageView
>
Hello Steve,
To achieve this you need to specify exactly which button will be "clicked" when visitor press Enter key, according to which textbox currently has a focus. The solution could be to add onkeydown attribute to textbox (in your case RadTextBox). I've attached a simple control, where I'm using the following code:
TextBox1.Attributes.Add(
"onkeydown"
,
"if(event.which || event.keyCode)if ((event.which == 13) || (event.keyCode == 13)) document.getElementById('"
+Button1.UniqueID+
"').click();return false; else return true; "
);