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

[Solved] Cancel grid postback client-side

1 Answer 160 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Polaris431
Top achievements
Rank 1
Polaris431 asked on 09 Jun 2009, 02:56 PM
In my grid I have a FormTemplate and use an ImageButton for both the Update and Canel:

<asp:ImageButton ID="imgUpdate" runat="server" ImageUrl="~/images/Update.gif" ToolTip="Update Record" 
  Style="padding-right: 5px" CommandName="Update" OnClientClick="OnSessionUpdate(this)" /> 
<asp:ImageButton ID="imgCancel" runat="server" ImageUrl="~/images/Cancel.gif" ToolTip="Cancel Editing" 
  CommandName="Cancel" /> 

I want to implement my own client-side validation mechanism. When the user clicks the Update button I use the OnClientClick event to call a function where I validate various controls within the FormTemplate. If the validation determines that the user must enter some data, I want to cancel the grid calling the ItemCommand event on the server-side. I have not found any means by which I can cancel the grid from calling the ItemCommand event (or any other event for that matter).

How can I cancel the grid from doing a postback?

Thanks
Johann

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 11 Jun 2009, 09:59 AM
Hi Polaris431,

You can define your image button's OnClientClick event handler as:

OnClientClick="return OnSessionUpdate(this)"

and if you want to cancel updating simply return false from your javascript function.

Greetings,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Polaris431
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or