現時点では、次のコードがあります。
@using (Html.BeginForm("Add", "Review", "Review"))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Review</legend>
<div class="editor-label">
@Html.LabelFor(model => model.TEKST)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.TEKST)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
これにより、localhost:4470/Review/Add?Length=6 に送信されます。実際に必要なのは、次の URL です: localhost:4470/Review/Add?tekst=sdfsdf
長さの代わりに「tekst」をパラメーターとして使用するようにこのコードを変更するにはどうすればよいですか? そして、テキストボックスの内容を値として。
更新:これは私のアクションメソッドです:
public ActionResult Create()
{
return View();
}
public ActionResult Add(string tekst)
{
ViewBag.test = tekst;
return View();
}
Create の View ページで、Add にアクションを送信するテキストボックスまたはテキストエリアを含むフォームが必要です。テキストボックスまたはテキストエリアのコンテンツは、アクション メソッド「Add」のパラメータ「tekst」にある必要があります。
解決策: CD Smith の投稿を参照してください。