2016-04-11 18 views
0

MVC 4 Razor ViewでAjax.BeginFormを使用しています。私は、ブラウザで結果のHTMLをチェックするときMVC4 Ajax.BeginForm routeValuesをHTMLの型名に変換しました

@model EditViewDefinition 
@{ 
    RouteValueDictionary postParams = new RouteValueDictionary(); 
    postParams.Add("entityUid", Model.EntityUid); 
    postParams.Add("entityId", ViewBag.entityId); 
    postParams.Add("viewUid", Model.UID); 
    string viewContainerId = "viewcontent_" + Model.UID.ToString().ToLower() + "_" + ViewBag.entityId.ToString(); 
} 

その後、

using (Ajax.BeginForm("Edit", postParams, new AjaxOptions() { HttpMethod = "Post", OnSuccess = "submitSuccess('" + viewContainerId + "')" })) 
{ 
... 
} 

は今、私が取得:

<form id="form0" 
    action="/View/Edit?Count=3&amp;Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&amp;Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.Object%5D" 
    method="post" 
    data-ajax-success="submitSuccess('viewcontent_fb1a8d4c-fd30-4da4-b11c-bff99f3bb74f_1')" 
    data-ajax-method="Post" 
    data-ajax="true"> 

    ... 
</form> 

はなぜSystem.Collections.Generic.Dictionary%の602を取得しています%2BKeyCollection%5BSystem.String%2CSystem.Object ではなくaction属性の action = "/ View/Edit?entityUid = uid & ja tityId = 1 & viewUid = uid

+0

あなたはちょうど 'var postParams = new {entityUid = Model.EntityUid、entityId = ViewBag.entityId、viewUid = Model.UID}を試したことがありますか? ' –

+0

スティーブンさん、ありがとうございました。ワオ。 – gush

答えて

0

Stephen Mueckeさんのコメントありがとうございます。私はvar postParams = new { entityUid = Model.EntityUid, entityId = ViewBag.entityId, viewUid = Model.UID };を使っていました。

多くのありがとうスティーブン。

関連する問題