1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Default Button

Default Button

2 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    06 Dec 2011
    Link to this post
    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>
  2. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    09 Dec 2011
    Link to this post
    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
2 posts, 0 answered