パラメータを部分ビューに渡す必要がありますが、どのように見つけられません。引数を部分ビューに渡すC#MVC
基本的に私の問題は次のとおりです。RenameFileAndFolderを別のビューから呼び出し、ユーザーをIndexコントローラページに移動し、_fileTableにパスを渡す必要があります。
コントローラー:
public ActionResult Index(){...}
public ActionResult _fileTable(string path){...} //partial view
[HttpPost]
public ActionResult RenameFileAndFolder(string path, string newName){...}
ビュー:パーシャルビューは、ビュー内で呼び出され
function RenameFileFolder() {
//(...)
$.ajax({
type: "Post",
url: '@Url.Action("RenameFileAndFolder", "ManageFiles")',
data: { path: '@(currentPath)', newName: inputName },
dataType: "json",
traditional: true,
success: function (data) {
document.getElementById("inputNewName").value = "";
//Here how can I say: "go to the index page with the path="X" on the partial view"?
//currently I am doing this but it does not allow me to pass a parameter
window.location.assign("Index");
})
}
:
<div id="tabelaDiv">
@{
Html.RenderAction("_fileTable", Model);
}
</div>
EDIT: メートルでの私の状況鉱石の詳細: 私はそれの中の部分的なビューのオメガでビューベータにいます。次に、私はView alphaに行き、ajaxクエリーでRenameFileFolder()関数を呼び出します。もし成功すれば、View Betaに戻り、パーシャルビューomegaにパラメータを渡したいと思っています。
:あなただけそれが単一部分ビューをレンダリングするのに十分な長持続したい場合は、そのようなViewDataをなどの持続データのための他の方法のいずれかを使用する方が良いかもしれ見る? – Shyju
@Shyjuあなたの答えをありがとう。私は私の見解の中で部分的な見方を呼んでいます。上記の私の編集 – myusername21
を見て、部分ビューのモデルとして 'path'(文字列)の値を渡したいと思いますか? – Shyju