asp.net mvc - MVC4 Jquery Popup -


i'm hoping advice on how best achieve following in .net mvc 4.

i have view list of companies on it, simple each through enumeration building html table. each row has button or link, when pressed button / link opens pop-up window. inside pop-up window partial view, containing form add new user posts own method on controller.

what happen form self contained within pop-up , not affect main window until close pop-up , refresh parent window, still able submit new user , persisted within pop-up.

can 1 offer advice.

thanks

i think posting form within dialog using ajax solution.

you take benefits of serialize data of form values next javascript in jquery:

$("#submit-button").click(function (e) {     e.preventdefault();     var form = $("#dialog-form");     var form_collection = form.serialize();     $.post("/controller/action/", form_collection, function (data) {         if (data) {             $("#dialog").close();         } else {             alert("something go wrong!");         }     }); }); 

and in controller:

[authorize] [acceptverbs(httpverbs.post)] public jsonresult action(formcollection form) {     user newuser = new user();     newuser.name = form["name"];     newuser.company = form["company"];     newuser.address = form["address"];      databaseservice.saveorupdate(newuser);      return json(new { response = true, usersaved = newuser }, jsonrequestbehavior.allowget); } 

i hope understand question right!


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -