OnClientClick

6 posts, 0 answers
  1. Kjell
    Kjell avatar
    203 posts
    Member since:
    May 2011

    Posted 11 May 2012 Link to this post

    I use OnClientClick="showNotification();" on a asp:button with this java script. I try to use on same page validate a control with a telerik:RadButton and OnClientClicked, but dont have it to work. Only works with asp:button.
    How to get showNotification work with telerik:RadButton?

    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function showNotification() {
                var notification = $find("<%= RadNotification1.ClientID %>");
                setTimeout(function () {
                    notification.show();
                }, 0);
            }
     
            function CheckIfShow(sender, args) {
                var summaryElem = document.getElementById("<%= ValidationSummary1.ClientID %>");
                var noErrors = summaryElem.style.display == "none";
                args.set_cancel(noErrors);
            }
        </script>
    </telerik:RadScriptBlock>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 May 2012 Link to this post

    Hello,

    Try calling the OnClientClick function as shown below which worked as expected.
    aspx:
    <telerik:RadButton ID="RadButton1" Text="Show" runat="server"  OnClientClicked="OnClientClicked"></telerik:RadButton>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kjell
    Kjell avatar
    203 posts
    Member since:
    May 2011

    Posted 16 May 2012 Link to this post

    Sorry, does not work. The problem is localized to ValidationGroup.
    I use asp:ValidationSummary in telerik:RadNotification. When i set the ValidationGroup in the button and OnClientClick="showNotification();" or OnClientClicked="showNotification();" if i use telerik:RadButton nothing happens.
    Tips on solving the problem?
  5. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 21 May 2012 Link to this post

    Hi Kjell,

    The properties used for attaching a handler to the click client-side event of RadButton are OnClientClicking and OnClientClicked. Note that the handler method is specified only by its name, without brackets:
    OnClientClicked="showNotification"

    Please set the OnClientClicked handler as shown above and your problem will be resolved.

    Feel free to contact us again if you run into more difficulties.

    Regards,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Kjell
    Kjell avatar
    203 posts
    Member since:
    May 2011

    Posted 21 May 2012 Link to this post

    I have try that now, and nothing happens when i click on the radbutton?
    But if i remove ValidationGroup="NyKat" from the radbutton and ValidationGroup="NyKat" from the asp:RequiredFieldValidator it works.
    It not works with ValidationGroup.....
    <telerik:RadButton ID="rbAdd" Text="Add" ValidationGroup="NyKat" OnClientClicked="showNotification" runat="server">
      <Icon SecondaryIconCssClass="rbAdd" SecondaryIconRight="4" SecondaryIconTop="4" />
      </telerik:RadButton>
  7. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 24 May 2012 Link to this post

    Hi Kjell,

    Have you specified the same ValidationGroup to the ValidationSummary control as well?

    Since I am not fully aware of your actual setup, I have prepared a sample page that demonstrates the functionality that you want to achieve. Please use it as a reference for incorporating this feature into your project.

    I hope this helps. Feel free to contact us again if you encounter more difficulties.

    All the best,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017