html - When to use Partial view in ASP MVC? -
i have page has 4 hidden div
s, there 4 buttons bring corresponding div
s. instead of writing code on 1 page, have split partial views (so div
s in partial views) e.g.
<div class="hide" id="doctor"> @html.partial("~/views/medical/_doctor.cshtml") </div>
it feels wrong reason this, doesn't it?
i don't see reason why "wrong". if helps reduce complexity of code, helps.
partials typically used following reasons (but not strictly):
- for child actions , ajax requests
- for reuse of common code
- to simplify complex pages
the thing watch out if pass object partial it's model, may not render form fields in correct manner bound on postback. editortemplates for, although if know you're doing can make partials work well.
Comments
Post a Comment