asp.net mvc - Partial view inherits from master layout -
i have partial view , int it, there no trace of inheritance layout. whenever want use (render it) inside view, layout gets repeated once view, , once partial view. this post suggests create empty layout. think workaround. there anyway stop loading layout (master layout) partial views. don't understand, why when there no code use master layout, why should loaded. it's creating page in asp.net , seeing inherits master page without having <%@ master ...
directive.
this partial view:
@* recursive category rendering *@ @using backend.models; @{ list<category> categories = new thoughtresultsentities().categories.tolist(); int level = 1; } @rendercategoriesdropdown(categories, level) @helper rendercategoriesdropdown(list<category> categories, int level) { list<category> rootcategories = categories.where(c => c.parentid == null).tolist(); <select id='categorieslist' name='categorieslist'> @foreach (category rootcategory in rootcategories) { <option value='@rootcategory.id' class='level-1'>@rootcategory.title</option> @renderchildcategories(categories, level, rootcategory.id); } </select> } @helper renderchildcategories(list<category> categories, int level, int parentcategoryid) { string padding = string.empty; level++; list<category> childcategories = categories.where(c => c.parentid == parentcategoryid).tolist(); foreach (category childcategory in childcategories) { <option value='@childcategory.id' class='level-@level'>@padding.padright(level, '-') @childcategory.title</option> @renderchildcategories(categories, level, childcategory.id); } level--; }
i able reproduce issue when rendering partial pages through ajax calls.
return view("partialpage")
would accompany layout. have overridden behavior explicitly calling
return partialview("partialpage")
Comments
Post a Comment