1

我问这个问题是为了确保自己理解这个主题。

“在局部视图中使用提交按钮的唯一方法是使用 Ajax 技术提交表单”

4

2 回答 2

3

Well, technically you could do a normal postback from a partial view. But that would tend to defeat the point of a partial:

  1. the entire page would have to be re-loaded, which means the result of the partial-view postback would need to be a complete page.
  2. the partial view's modularity suffers, because the result of its postback falls out of the partial view's scope (ie, the partial view needs to know about the entire current page).

So, it's an irregular thing to do a non-AJAX postback from a partial view. But there are scenarios where it would be useful/appropriate. Consider for example a "login" partial: you may want to post the credentials back to a specific controller/action, and have that action redirect back to the current page. In that case you could reasonably use a non-AJAX form.

于 2012-12-03T19:50:32.183 回答
1

在局部视图中使用提交按钮的唯一方法是使用 Ajax 技术提交表单

你没有说你从哪里得到报价,但这不是真的。

从局部视图提交表单的方式与在主视图中提交表单的方式完全相同。您可以使用自定义字段或通过强类型化您的局部视图来做到这一点。你在哪里挂机?

于 2012-12-03T19:50:09.233 回答