开发者

"partial views" best practices for 'container' divs?

开发者 https://www.devze.com 2022-12-29 01:19 出处:网络
What is the \'best\' way to handle the html markup for partial views? (which are also refreshed using AJAX) The biggest issue I run into is where to place the \'container\' div...

What is the 'best' way to handle the html markup for partial views? (which are also refreshed using AJAX) The biggest issue I run into is where to place the 'container' div...

Consider having a masterpage and a partial view.

(class="" could be interchanged with id="" depending if the partial is guaranteed to be unique, however this isn't really important to the issue i think)

Masterpage:

<div id="place1" class="placeholder">
<!-- render partial -->
</div>

Partial:

<div id="partial1" class="partial">
<!-- content -->
</div>

I feel that something isn't being done right. However I cannot remove the div in the masterpage, because I need that to 'encapsulate' the 开发者_如何学Goresponse from AJAX partial updates. And also I cannot move the div in the partial to the masterpage, because that would require to move 'partial' info to the masterpage...

How do you handle this?


I would say that it terms of the semantic description of what is happening here, of providing good hooks for styling and scripting, and also in terms of general robustness against future uses and changes, that using both divs is the best way to go.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号