我有第一個表單中的用戶名和密碼,並以另一種形式檢索密碼,其中我想要第一個表單中的第一個表單提交的第二個表單中的userame。如何在另一個表單中提交表單值提交
@model Network.Models.LoginDetail
<script type="text/javascript">
</script>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<p>
Please enter your user name and password. @Html.ActionLink("Register", "Register") if you don't have an account.
</p>
@using (Html.BeginForm("Index","Student",FormMethod.Post)) {
<div>
<fieldset>
<legend>Account Information</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Username)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Username)
@Html.ValidationMessageFor(model => model.Username)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Password)
@Html.ValidationMessageFor(model => model.Password)
</div>
<p>
<input type="submit" value="Log in" style="width: 200px"/>
</p>
@ViewBag.Message
</fieldset>
</div>
}
@using (Html.BeginForm("RetrievePassword","Student",FormMethod.Post)) {
<p>
Forgot password? <input type="submit" onclick="updateUsername();"value="Click Here" style="width: 150px"/> Entering your username to retrieve your password.
</p>
@Html.HiddenFor(model => model.Username)
}
我們如何實現這一目標,我嘗試在javascript中捕獲隱藏字段中的用戶名,但不工作。 或者可以在窗體內形成用於實現此目的。 請提供解決方案。
感謝,
Michaeld
JavaScript是可能的方式來做到這一點。讓我們看看你的JavaScript。 – Jasen 2013-04-25 17:46:24
嗨Jasen,謝謝你的輸入document.getElementById('username')。value = document.getElementById('Username')。value;工作我試圖改變隱藏價值編號名稱 – michaeld 2013-04-25 17:51:43