asp.net mvc - Share data between two partial views in tab UI -


i've created 2 tabs using jquery ui, , placed 2 partial views in tabs below code.

<div id="tabs"> <ul>     <li><a href="#tab1">tab 1</a></li>     <li><a href="#tab2">tab 2</a></li> </ul> <div id="tab1">    @html.partial("tab1")    </div> <div id="tab2">    @html.partial("tab2") </div>  </div> 

how can share data tab2 partial view tab1 partial view.

thanks, naren

you can't. directly sharing data between partial views no architecture, either. each partial view should exist one distinct purpose , should not interfere or exchange data other ones — in fact, tab1 shouldn't know tab2 exists.

however, store data in model property of view containing 2 partial views , hand on each partial view rendered:

@model somemodel  <div id="tabs">     <ul>         <li><a href="#tab1">tab 1</a></li>         <li><a href="#tab2">tab 2</a></li>     </ul>     <div id="tab1">        @html.partial("tab1", model)     </div>     <div id="tab2">        @html.partial("tab2", model)     </div>     </div> 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -