私はmvcが初めてです。私は小さなフォームしか持っていません。フォームを送信すると、フォームを配置したのと同じ場所に部分的なビューがレンダリングされるようにしたいと考えています。
ここで、私たちのページがどのように見えるかをスクリーンショットで示しています。
部分的なビューをレンダリングすると、ページが消えて裸のように表示されます。これが再びスクリーンショットです。
successfully save
フォームを配置したのと同じ場所にメッセージを表示したい。
これが私の完全なコードです。
私のコントローラーコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcPractise.Controllers
{
public class GameController : Controller
{
//
// GET: /Game/
public ActionResult Test()
{
return View();
}
[HttpPost]
public ActionResult Save(string name, string salary, string btnSubmit)
{
//return View("Message");
return PartialView("MyMessage");
}
public ActionResult Index()
{
return View();
}
}
}
フォームデータがある私のメインビューフォーム
@{
ViewBag.Title = "Test";
}
<h2>Hello222</h2>
<div id="mydiv">
@using (Html.BeginForm("Save", "Game", FormMethod.Post, new { @Id = "Form1" }))
{
<table border="0">
<tr>
<td>Name :</td>
<td><input name="name" type="text" /></td>
</tr>
<tr>
<td>Salary :</td>
<td><input name="salary" type="text" /></td>
</tr>
<tr>
<td colspan="2"><input name="btnSubmit" type="submit" value="Save"/></td>
</tr>
</table>
}
</div>
私のパーシャルビューでは、このテキストしかありません
<h2>Successfully Saved</h2>
jqueryを使用せずに何をする必要があるかを教えてください。ありがとう