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

Adding Client Clicked Event disables button events server/client both

1 Answer 117 Views
Button
This is a migrated thread and some comments may be shown as answers.
Jawwad
Top achievements
Rank 1
Jawwad asked on 27 Dec 2014, 06:44 AM
This is my button. Adding onclick event disables

1. the mouseover / mouseout css
2. click event on server side
3. client javascript function is not working

<telerik:RadButton ID="btnEdit" runat="server" Icon-PrimaryIconCssClass="rbEdit" Icon-PrimaryIconLeft="4" Icon-PrimaryIconTop="3" Width="20px" ToolTip="Edit" OnClick="btnEdit_Click" OnClientClicked="return checkId();"></telerik:RadButton>

function checkId() {
            if (document.getElementById("<%=hidPointId.ClientID%>").value == '')
            { return false; }
else
{ return true; }
        }

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 29 Dec 2014, 09:54 AM
Hi Jawwad,

First, the way that you are setting the event handler is incorrect. In the context of controls from our suite, you should set as an event handler only the name of the function:
OnClientClicking="checkId"

If you inspect your browser console with your current implementation you will notice that there is a JavaScript error, due to the way that you are setting the event handler.

Additionally, the OnClientClicked client-side event of the RadButton could not be canceled and generally, a combination of client-side and server-side click event is not recommended.

For your scenario, you should handle the OnClientClicking event, which could be canceled through the args.set_cancel(true) method:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function checkId(sender, args) {
            if (somecondition) {
                args.set_cancel(true);
            }
        }
    </script>
</telerik:RadCodeBlock>
 
<telerik:RadButton ID="btnEdit" runat="server" Icon-PrimaryIconCssClass="rbEdit" Icon-PrimaryIconLeft="4"
    Icon-PrimaryIconTop="3" Width="20px" ToolTip="Edit" OnClick="btnEdit_Click" OnClientClicking="checkId">
</telerik:RadButton>

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Button
Asked by
Jawwad
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or