【发布时间】:2010-07-22 16:01:07
【问题描述】:
问题
我有 Telerik TabControl,每个选项卡内容都是部分视图。当请求为 GET 时,一切正常:
//
// GET: /ProductVersion/Translations
public ActionResult Translations(Guid id)
{
VersionEditTabViewModel model = CreateTranslationsViewModel(id);
return PartialView("Translations", model);
}
现在的问题是,在某些选项卡上,我有一个表单,其中包含触发提交事件的控件。
[HttpPost]
public ActionResult Translations(Guid id)
{
FormCollection formCollection = new FormCollection(Request.Form);
string message = string.Empty;
int languageId = int.Parse(formCollection["TranslationsLanguageList"]);
string action = formCollection["TranslationAction"];
if(action == Constants.translation_save)
{
_translationModel.SaveTranslations(formCollection);
message = "Translation information saved";
}
else if (action == Constants.translation_language_changed)
{
/*
PROBLEM: causes whole page to render, not partial
*/
return PartialView("Translations", model);
}
return RedirectToAction( ... updates the complete page not only partial ...);
}
我的问题是:如何从 POST 方法渲染部分内容?因为现在使用该源代码选项卡内容将加载到整个页面,而不是选项卡内。
解决方案
我不得不将 DIV 放在 Ajax.Form 之外,而且我在 DropDownList 上的提交也不正确。我所做的是我用 Id 创建了隐藏的提交按钮,然后我使用 jQuery 来执行它的点击事件。
【问题讨论】: