ASP.NET MVC3 passing data between primary view and a search view via Ajax link -


i have started learning asp.net mvc3.

i have following scenario. in create view model user can lookup code/description clicking on link (rendered html.actionlink helpers). lookup values retrieved lookup tables in database , presented in separate view. 2 views handled 2 different controllers. when user selects lookup value in latter view value (code+description) should copied create view.

how can data passed between 2 views? not possible due stateless nature of http requests?

i tried ajax link, didn't worked out.

code snippet create view:

<fieldset>     <legend>z-info</legend>      <div class="editor-label">         @html.labelfor(model => model.zzl_u_code)     </div>     <div class="editor-field">         @html.editorfor(model => model.zzl_u_code)         @html.validationmessagefor(model => model.zzl_u_code)     </div>      <div class="editor-label">         @ajax.actionlink("land code test", "index", "domein", new {name = "lan" },              new ajaxoptions {                 httpmethod = "get",                 url = url.action("index", "domein", new {name = "lan" }),                  onbegin = "onbegin",                 onsuccess = "insertcodenaam",                 onfailure = "onfailure",                 oncomplete = "oncomplete"             })     </div> 

when user select code/description following select action called returns json data back.

select action:

public class domeincontroller : controller {     private zzlentities db = new zzlentities();      //     // get: /domein/      public viewresult index(string name)     {         domeinviewmodel model = domeinrepositry.getall(name);         return view(model);     }         get: /domein/select/5      public jsonresult select(int id, string naam)     {         return json(new domcodenaam { codevalue = id, naamvalue = naam }, jsonrequestbehavior.allowget);     } 

are there other solutions possible? can partial views option?

well have 2 options:

  1. just post lookup values , internally redirect first ("create") view, time passing (internally) values chosen user view can rendered chosen values. maybe not fancy easy implement. loose data user have entered first form though, unless post or make 2 step process.
  2. if want use ajax, need update appropriate parts of form in first "create" view on client side, depending on actions of user (i.e. lookup values have chosen).

i bit confused mean "separate view"


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -