Define onClientKeyPressed via JavaScript in pageLoad

3 posts, 1 answers
  1. Matt
    Matt avatar
    78 posts
    Member since:
    Mar 2009

    Posted 08 Jun 2015 Link to this post

    How can I add an event handler via JavaScript in pageLoad to handle the keyPress event of a RadComboBox? 

    We create a series of ComboBox controls dynamically based on user preferences.  We want to be able to accept user keystrokes and when they press the Enter key, fire the rrKeyPress event.

    We're unable to define this in our code due to business constraints; it *MUST* be in JavaScript on pageLoad.

    I've tried adding it using the code below, but it didn't work as expected:

    // Loop through controls and attach

    var comboBox = document.getElementById('RadComboBox1');

    Any suggestions?

  2. Answer
    Plamen avatar
    2723 posts

    Posted 10 Jun 2015 Link to this post


    Here is the code that worked correctly at my side:
    <script type="text/javascript">
              function pageLoad() {
                  var combo = $find("<%=RadComboBox1.ClientID%>");
                      function(sender, args) {
              <telerik:RadComboBox runat="server" ID="RadComboBox1">
                      <telerik:RadComboBoxItem Text="aaa" />
                      <telerik:RadComboBoxItem Text="bbb" />
                      <telerik:RadComboBoxItem Text="ccc" />

    Hope this will help you solve the issue.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
  4. Matt
    Matt avatar
    78 posts
    Member since:
    Mar 2009

    Posted 11 Jun 2015 in reply to Plamen Link to this post

    Thanks...worked like a champ!
Back to Top