Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

asp.net mvc - two nested model properties of same complex type -


i have customer model 2 complex properties "internaladdress" , "publicaddress" both of same model type address.

in view doing following

<h2>internal address</h2> <% renderpartial("address", model.internaladdress);%> <h2>public address</h2> <% renderpartial("address", model.publicaddress);%> 

it gets rendered without exceptions rendered html use same input-names both partialviews...

is there smart way handle situation?

it's you're combining functionality using partial views, since of time address rendered 1 way.

one way display form using mvc2 editorfor , displayfor templates. move partial view form /views/shared/editortemplates/address.ascx (and display-only portion if have 1 /views/shared/displaytemplates/address.ascx).

once that's done, can use 1 of 2 ways.

option 1:

you can edit viewmodel this:

[uihint("address")] public address internaladdress { get; set; }  [uihint("address")] public address publicaddress{ get; set; } 

the uihint tells templating engine use view called "address" in shared/editortemplates folder.

then can use editorfor template in view no modifications:

<%: html.editorfor(model => model.internaladdress) %> 

option 2:

simply specify template's name in editorfor in view:

<%: html.editorfor(model => model.internaladdress, "address") %> 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -