I apologize for my typos. I am working on proving the concept of a C # ASP.NET MVC application where I need to transfer data between two views when there are no messages and fails. One view launches a modal dialog, and I need a connection between them. We are using jQuery.
I have a view called Charges.cshtml with a data grid. The first column of a datagrid can have a span element or a link element, depending on the property, which will tell if one or more descriptions has a charge. The view is as follows.

If the charge has several descriptions, the user clicks the corresponding description link (in this case description 2), and a modal dialog opens with a description of various descriptions, as shown below.

Now in this modal dialog the user will confirm / select one description. Now I need to close the modal dialog and update the description of the selected ones as below

The tough part here is how to transfer data between the two views. I agree to transmit data through the controller or through javascript.
I tried various ways to transfer the selected charge from Charges.cshtml to the LoadLoanChargeDescriptions method in the LoanCharge controller like json serialize, ViewData, ViewBag, TempData etc., but to no avail. I can pass simple data types such as int, string, float, but not the whole object. I feel that I need to pass CurrentDescription and Descriptions to my controller, and from them I need to go to other parts. I tried passing List of strings, but could not see how to access them in the controller, since in my controller I got a score of 0. I can open a popup window with several UI descriptions (now only added Hello text)
Below are my code snippets
Charges.cshtml
@model ChargeViewModel @using (Html.FAFBeginForm()) { <div> <table> <tbody> <tr > //..... <td> @if(Model.IsMultipleMatch) { var loanCharge = Model as ChargeViewModel; if (loanCharge.IsMultipleMatch == true) { //string vm = @Newtonsoft.Json.JsonConvert.SerializeObject(loanCharge); <span> <a onclick="ShowMatchingDescriptions('@Url.Action("LoadLoanChargeDescriptions", "LoanCharge")','', '920','500')"> @loanCharge.Description </a> </span> } } else { <span>Model.Description</span> } </td> </tr> </tbody> </table> </div> } public class ChargeViewModel { public string Description {get;set;} public bool IsMultipleMatch {get;set;} public List<string> Descriptions {get;set;} } public class LoanChargeController { public ActionResult LoadLoanChargeDescriptions() { // get data here and pass/work on return View("_PartialMultipleMatchPopup", null); } }
In Review.js
function ShowMatchingDescriptions(popUpURL, windowProperties, w, h) { try { var left = (screen.width / 2) - (w / 2); var top = (screen.height / 2) - (h / 2); var properties = windowProperties + "dialogwidth:" + w + "px;dialogheight:" + h + "px;dialogtop:" + top + "px;dialogleft:" + left + "px;scroll:yes;resizable:no;center:yes;title:Matching Lender's Fee;"; $.when( window.showModalDialog(popUpURL, window, properties) ) .then(function (result) { var childWindow = result; }); } catch (err) { alert("Error : " + err) } }
UPDATE 1
I updated my question and posted more details.
Thanks in advance.
UPDATE 2
Please see my solution at the link below.
MVC skip model between parent and child windows