tags:

views:

54

answers:

1

Hi Guys,
I have a Delete button on Edit Form Mode.
I want to send the whole form data to the controller when this button is clicked in Edit mode.

I have a ViewModel on View which has data in it and displayed to user with input fields. Now if user clicks Delete then this whole data needs to be sent to controller.

This is my delete method in Controller

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Delete(CustomerVM customerVM)
    {
         //Delete logic here..
    }

What i have done is when user clicks delete button then i use below jquery to post whole data but it gives me error 'Stack overflow at line:0'

<button name="Delete" onclick="$.post('/Customer/Delete',this); return false;" type="button">Delete</button>

Do anyone have any idea how can i accomplish this thing?

Thanks,

A: 

I got one way of accomplishing it and its this

button name="Delete" onclick="$.post('/Customer/Delete',$(\"form\").serialize()); return false;" type="button">Delete</button>

this way i am getting the Form data on server.

But is this the best practice. I mean are there any better approach then using JQuery to accomplish this task?

Thanks,

Huzefa