Problem with Button vs. RadButton

2 posts, 0 answers
  1. Robert
    Robert avatar
    198 posts
    Member since:
    Aug 2009

    Posted 11 Jun 2012 Link to this post

    I have an ASP.net button and I set the CssClass to something so that I can use Jquery to select it and force the click event when someone hits the enter key and this works the way I want it to.  The problem is that I am using Telerik skins so when I assign the cssclass the styling on the button goes away.  If I change the button to a RadButton the styling remains even if I set the CssClass to something however my Jquery selector obviously won't work anymore.

    I have to select by class because I won't know the client id of the button because of edit form templates, master page, other containers, etc...

    So how can I either:

    a.) Select the RadButton using Jquery similar to the example below? Or,
    b.) Style the ASP.net button using telerik skins while still assigning a CSSClass so that I can still use this below?


    $(document).keypress(function (event) {
      if (event.keyCode == 13) {
        event.preventDefault();
        $(".submit-button").click();
      } else {
        return true;
      }
    });
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Jun 2012 Link to this post

    Hi Robert,

    Here is the code snippet I tried to achieve your scenario.

    ASPX:
    <telerik:RadButton ID="RadButton1" runat="server" Text="Button" Skin="Hay" CssClass="a">
    </telerik:RadButton>

    CSS:
    <style type="text/css">
      .class
        {
            background-color:Red;
        }
    </style>

    JS:
    <script type="text/javascript">
        $(document).ready(function (event) {
            $(document).keypress(function (event) {
                alert("xfgg");
                if (event.keyCode == 13) {
                    event.preventDefault();
                    $(".class").click();
                } else {
                    return true;
                }
            });
            $(".class").click(function () {
            alert("Handler for .click() called.");
        })
    });
    </script>

    Please provide your full code if it doesn't help.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top