Default Button

Posted by Community Admin on 04-Aug-2018 02:51

Default Button

All Replies

Posted by Community Admin on 06-Dec-2011 00:00

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>

Posted by Community Admin on 09-Dec-2011 00:00

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; ");
You need to modify it a bit to suit your control.

Greetings,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed