Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery Popup from MVC controller
    primarykey
    data
    text
    <p>I’m just starting to explore asp mvc and jquery.</p> <p>I have a simple form that has 2 fields, a Date and an Amount.</p> <p>The behaviour I am trying to achieve is that when the form is submitted, if the record doesn't already exist in my database then add the item. If it does already exist then warn and ask the user for confirmation. If the user proceeds then overwrite the existing record. </p> <p>Here is my Mark Up</p> <pre><code>&lt;% using (Html.BeginForm()) { %&gt; &lt;div&gt; &lt;%:Html.LabelFor(mod =&gt; Model.bal.Date) %&gt; &lt;/div&gt; &lt;div&gt; &lt;%: Html.TextBoxFor(mod =&gt; Model.bal.Date)%&gt; &lt;%:Html.ValidationMessageFor(mod =&gt; Model.bal.Date)%&gt; &lt;/div&gt; &lt;div&gt; &lt;%: Html.LabelFor(mod =&gt; Model.bal.Amount)%&gt; &lt;/div&gt; &lt;div&gt; &lt;%: Html.TextBoxFor(mod =&gt; Model.bal.Amount)%&gt; &lt;%: Html.ValidationMessageFor(mod =&gt; Model.bal.Amount)%&gt; &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Create" /&gt; </code></pre> <p>And here is my controller code</p> <pre><code> [HttpPost] public ActionResult Index(Balance bal) { var dataContext = new DataDataContext(); if (ModelState.IsValid) { // Check if exsists if (dataContext.Balances.ToList().Contains(bal, new BalanceEquality())) { //Exsists, Warn then edit // Add code here to open popup // if Continue then over write exsisting data in db } else { //Not exsist, insert dataContext.Balances.InsertOnSubmit(bal); dataContext.SubmitChanges(); } } compModel myModel = new compModel(); myModel.bal = bal; myModel.allBalances = dataContext.Balances.OrderBy(ball =&gt; ball.Date).ToList(); return View(myModel); } </code></pre> <p>The problem I have is how to display and get the results from a Jquery Popup from within my Controller. </p> <p>I thought about setting a variable in the ViewData collection, but this didn't seem like "best Practice" to me </p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload