This is a migrated thread and some comments may be shown as answers.

OnClientClick

5 Answers 179 Views
Button
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Iron
Kjell asked on 11 May 2012, 08:50 AM

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>

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 May 2012, 07:01 AM
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.
0
Kjell
Top achievements
Rank 1
Iron
answered on 16 May 2012, 06:01 PM
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?
0
Slav
Telerik team
answered on 21 May 2012, 02:28 PM
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.
0
Kjell
Top achievements
Rank 1
Iron
answered on 21 May 2012, 03:06 PM
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>
0
Slav
Telerik team
answered on 24 May 2012, 08:55 AM
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.
Tags
Button
Asked by
Kjell
Top achievements
Rank 1
Iron
Answers by
Shinu
Top achievements
Rank 2
Kjell
Top achievements
Rank 1
Iron
Slav
Telerik team
Share this question
or