.net - How to keep state of typed viewmodel objects in partial views? -


hi,

i have typed view in asp.net mvc. keep track on properties of model when thay not connected field(ex textboxfor) have use html.hiddenfor element. makes easy manipulate data , server.

say typed view contains partial view provide bit of model main view, :

<% html.renderpartial("~/views/ad/partial/listsettings.ascx", model.als); %> 

all javascript reading , manipulate als proerpty(complexed object) placed in partial view abel use partial view on other main views.

in partial view have following lines :

<%: html.hiddenfor(c => c.cp) %> <%: html.hiddenfor(c => c.l) %> <%: html.hiddenfor(c => c.ob) %> <%: html.hiddenfor(c => c.st)%> <%: html.hiddenfor(c => c.p)%> 

and works fine read javascript when submitting view settings of these properties not follow service?

i did try place them in main view instead :

<%: html.hiddenfor(c => c.als.cp) %> <%: html.hiddenfor(c => c.als.l) %> <%: html.hiddenfor(c => c.als.ob) %> <%: html.hiddenfor(c => c.als.st)%> <%: html.hiddenfor(c => c.als.p)%> 

and point javascript correct fields if works problem partial view not caontain needs, have implement these hidden filed in every main view partial view placed in?

how handle this?

bestregards

if fields not going modifiable user include hidden field containing id allow fetch them data source. example:

<%= html.hiddenfor(x => x.id) %> 

and id posted controller if wrapped inside form or used javascript , sent along ajax request. inside controller action use id , fetch wherever stored:

[httppost] public actionresult foo(int id) {     var model = _repository.get(id);     ... } 

if properties modifiable use standard input elements such textboxes , dropdownlists allowing user set values , post controller action take updated view model argument.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -