Friday 15 July 2011

c# - Mvc Modal Ajax Form -


My question is same

What I want to achieve is a simple input like the amount of an article , When the user submits hits, all the dialog should be closed and the data should be collected without reloading the entire page.

This partial view is loaded by the form: @model TRUNCATED.Models.AddToCartModel & LT; Script src = "~ / script / jQuery-1.7.1.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "~ / scripts / jquery.validate.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "~ / script / jquery.validate.unobtrusive.min.js" & gt; & Lt; / Script & gt; @Using (HTML.bizform ("adodcast", "order", new ajax option {// Do I need anyone?})) {& Lt; Field & gt; & Lt; Story & gt; AddToCartModel & lt; / Narrative & gt; & Lt; img src = "@ Url.Action (" GetImage "," file ", new {ArticleId = Model.ArticleId}) resize" title = "Artikelbild" style = ": both; width: 300px; height: 200px;" / & Gt; & Lt; Div class = "editor-label" & gt; @HTML LabelFor (model => model .ltd) & lt; / Div & gt; & Lt; Div class = "editor-field" & gt; @ Html.EditorFor (model => model.ArticleId) @ html.ValidationMessageFor (model => model.ArticleId) & lt; / Div & gt; & Lt; Div class = "editor-label" & gt; @html.labelfor (model => volume volume) & lt; / Div & gt; & Lt; Div class = "editor-field" & gt; @html Editor (model = & gt; model suffix) @html. Validation message (model = & gt; model); & lt; / Div & gt; & Lt; P & gt; & Lt; Input type = "submit" value = "add to cart" / & gt; & Lt; / P & gt; & Lt; / Fieldset & gt; }

This dialog is JS:

  $ ("# dialog"). Dialog ({autoOpen: false, resizeable: wrong, width: 350 ( Effect): "eyes", duration: 300}, button: {"off": function () {$ (this) .dialog ("closed");}}}); $ ("ShowDialog"). ("Click", function (e) {$ ('# dialog'). Load (this.href) .dialog ('open'); return false;});   

In this way I open the dialog:

  @ html.ActionLink ("Add to Cart", "AddToCart", New {id = item} ArticleId}, new {@class = "showDialog"}   

in the controller:

  [HttpGet] public ActionResult addToCart as (int id) {return PartialView ( "_AddToCart", new AddToCartModel () {ArticleId = id});} [HttpPost] public ActionResult addToCart Like (AddToCartModel ATM) {if (OrderData.CartItems.Count & gt; 0) atm.Pos = OrderData.CartItems.Max (i = & Gt; i.Pos) + 1; and Attimkpos = 1; Ordrdetakcartaitms.ad (ATM), the returns // do here?}   

New to this and i No clue what I'm doing wrong is here.I was replaced with HML Ajax but this did not change anything.

Though it works, but this is the whole page, just like that Is that sideeffects, reloading sets a Webgrid one back to back and what does not.

< P> I think that instead of using Ajax.BeginForm, you should open BeginForm and call window. Succcess event.
  @ (Ajax. Bangform ( "Action", "controller", a new Ajax option {HttpMethod = "Post", OnSuccess = "CloseWindow ()"}, new {id = "ID" , If you need to add some message to the user, you can apply it in your post action such as    pre>  [Acteepeepiost] public Aekshnrsent Aedtocart (Adtoprmodel ATM) {if (OrderData.CartItems.Count & gt; 0) Attimkpos = Ordrdetakcartaitmskmaks (i = & gt; i. po) + 1; a Returned atm.Pos = 1; OrderData.CartItems.Add (ATM); Returned content ("& lt; p & gt; Item added to cart & lt; / p & gt;"); // Returned by ajax;   

and modify your ajax form with UpdateTargetId. The message will be added to this ID

  @using (Ajax.Benform (" New "id =" form-catalog ", @class =" form ", new" Ajax "option {update tabbed id =" passholder in message ", http method =" post ", onusues =" closevand () "}, new {id =" form-catalog " Viscosity "})) {}    

No comments:

Post a Comment