tags:

views:

40

answers:

3

Hi I am having command buttons in my Grid like Insert,Update etc.. I customized the grid and add the buttons manually and place the ID's like btnInsert,btnUpdate and so on. The buttons are shown when i click Insert or Update image.

My issue is how can i call the event for the above buttons. I just want to validate inputs before the data is getting saved to DB.Since the buttons are inside the grid, I am finding difficult to call the button event. It is not coming fine. So let me know the possible ways to do so..

I used the below code: $('#btnUpdate').click(function(e)s { alert('checking the fun'); e.preventDefault(); });

I used also Update button's client id,

$('#RadGrid1_ctl00_ctl05_btnUpdate').click(function(e){ //Input validation });

-Thanks

A: 

You could take a look at the jquery documentation page about events: http://docs.jquery.com/Events

You could use one of these with something like: butonname.onclick( function() { //your validation here });

Bloeper
A: 

Is this what you want?

$('#btnInsert').click();

However, this is not the best style. The validation function shoud be a function of its own, then you can call it from the button event handler and other places alike.

Cheers

Tom

Tom Bartel
I used the above related code already but no use it is not getting called.
There is a difference between click() (note: no arguments), which triggers a click event on the element in question, and click(function) with a function argument, that **binds** the function to the click event of the element. You might say: In the first case, something happens immediately, in the latter case, a function is registered for later execution. You have to be clear which one you want.
Tom Bartel
A: 

Can you post some of the HTML for the grid? That would really help us be able to help you.

My guess is that you will want to give all the update buttons a CLASS like btn-update. Then you can use javascript like this:

$(".btn-update").bind('click', function (event) {
  event.preventDefault();
  $btn = event.currentTarget; //$btn will be a jQuery object containing the button that was clicked
  //call validate function
  //send data to server
});
David Radcliffe