3

My question is somewhat related to this answer - https://stackoverflow.com/a/3458299/1635958.

I am working on Asp.Net MVC 3.0.

I have Page1 where I have many controls. When I click on a Button1, I want the ability to make a list of json objects (lets say List personList ) and send that list to a Controller action. I want the view to be opened as a dialog.

So I am trying something like

var $dialog = $('<div></div>')
    .load("http://localhost:XXXX/Controler1/Action1")
    .dialog({
   autoOpen: false,
   title: "SomeTitle",
   width: 500,
   height: 300
});

$dialog
    .data("personList", personList)
    .dialog('open');

Once I do this, I want the ability to deserialize this data at the controller's side and pass it to a view. Is this doable through this approach? Is there a better approach?

Edit

Requirement is something like this ->
1. Page1 will display a grid of book details.
2. There is an Action column for each row, which is a checkbox
3. User can select the rows he is interested in, and click on a button outside the grid for a specific Action.
4. I should be able to collate data about all the books selected, and pass that data onto a jQuery dialog that gets opened.
5. The jQuery dialog should display the collated data to the user and present him with the ability to take some extra actions.

Edit 2 What is the best practice to have modal dialogs in MVC? I have a view which shows a grid of items. I want to provide the ability of selecting a subset of the rows, clicking a button, and opening a modal dialog with the selected rows for editing the selected rows and doing more actions. What is the best practice to get this done in MVC? When we click the button, if we call a controller, what is the recommended way to pass data to that controller?

Community
  • 1
  • 1
ArunGeorge
  • 495
  • 5
  • 11

1 Answers1

0

I did it this way ->

I created a json object from the first page. Posted it to the controller as an ajax call. The controller renders a view as a result. I capture the response and display it as a jquery UI dialog. Worked for me.

ArunGeorge
  • 495
  • 5
  • 11