标签:inpu team doc bsp ++ model var 视图 box
volleyballContrallor控制器中的方法的视图
play.cshtml
@model MvcApplication1.Models.volleyball @{ ViewBag.Title = "play"; } <h2>play</h2> @using (Html.BeginForm("add","volleyball","HttpPost")) { @Html.ValidationSummary(true) <fieldset> <legend>volleyball</legend> <div> @Html.Encode("主队名") @Html.TextBoxFor(model => model.nameA) </div> <div> @Html.Encode("客队名") @Html.TextBoxFor(model => model.nameB) </div> <input type="submit" value="开始"/> </fieldset> }
add.cshtml
@model MvcApplication1.Models.volleyball
@{
ViewBag.Title = "add";
}
<style type="text/css">
span
{
font-size:50px;
margin-left:15px;
}
div
{ width:400px;
height:300px;
float:left;
margin-left:200px;
}
div p
{
font-size:30px;
}
</style>
<script type="text/javascript">
function funA()
{
document.getElementById(‘teamA‘).value = 1;
document.getElementById(‘teamB‘).value = "";
}
function funB()
{
document.getElementById(‘teamA‘).value ="";
document.getElementById(‘teamB‘).value = 1;
}
</script>
<h2>add</h2>
@using (Html.BeginForm("index","volleyball","HttpPost"))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>volleyball</legend>
<div>
<p> @Html.Encode(ViewData["nameA"])</p><br />
@Html.TextBoxFor(model => model.nameA, new { @style = "visibility:hidden;" })<br />@*传入的队名*@
<p style="display:none;"> @Html.EditorFor(model => model.teamA)</p>@* 传入那个队伍得分*@
</div>
<div>
<p> @Html.Encode(ViewData["nameB"])</p><br />
@Html.TextBoxFor(model => model.nameB, new { @style = "visibility:hidden;" })<br />
<p style="display:none;"> @Html.EditorFor(model => model.teamB)</p>
</div>
<div style="float:none;">
<input onclick="funA()" type="submit" value="主队加分"/>
<input onclick="funB()" type="submit" value="客队加分"/>
</div>
</fieldset>
}
index.cshtml
@model IEnumerable<MvcApplication1.Models.volleyball> @{ ViewBag.Title = "Index"; var a = 0; } <h2>详细记录</h2> <style type="text/css"> table, td, th { border: thin solid black; border-collapse: collapse; padding: 5px; background-color: lemonchiffon; text-align: left; margin: 10px 0; text-align:center; } </style> <p> @Html.ActionLink("Create New", "Create") </p> <table> <tr> <th> @Html.Encode("第几球") </th> <th> @Html.Encode(ViewData["nameA"]) </th> <th> @Html.Encode(ViewData["nameB"]) </th> <th> @Html.Encode("操作") </th> </tr> @foreach (var item in Model) { a++; <tr> <td> @Html.DisplayFor(modelItem => a) </td> <td> @Html.DisplayFor(modelItem => item.teamA) </td> <td> @Html.DisplayFor(modelItem => item.teamB) </td> <td> @Html.ActionLink("Edit", "Edit", new { id=item.ID }) @Html.ActionLink("Delete", "Delete", new { id=item.ID }) </td> </tr> } </table>
totallContrallor控制器中的方法的视图
play.cshtml
@model MvcApplication1.Models.total @{ ViewBag.Title = "play"; } <h2>play</h2> @using (Html.BeginForm("add", "total", "HttpPost")) { @Html.ValidationSummary(true) <fieldset> <legend>volleyball</legend> <div> @Html.Encode("主队名") @Html.TextBoxFor(model => model.teamA) </div> <div> @Html.Encode("客队名") @Html.TextBoxFor(model => model.teamB) </div> <input type="submit" value="开始"/> </fieldset> }
add.cshtml
@model MvcApplication1.Models.total @{ ViewBag.Title = "add"; } <style type="text/css"> </style> <script type="text/javascript"> var a = 0; var b = 0; var a2 = 0; var b2 = 0; function addA() { var wina = document.getElementById(‘winA‘).innerHTML; var winb = document.getElementById(‘winB‘).innerHTML; var jushu = parseInt(document.getElementById(‘winA‘).innerHTML) + parseInt(document.getElementById(‘winB‘).innerHTML); a++; if (parseInt(winb) < 3 && parseInt(wina) < 3) { if (jushu == 0 && (parseInt(wina) - parseInt(winb) < 3)) { document.getElementById(‘fenA‘).innerHTML = a; if (a >= 25 && (a - b) > 2) { document.getElementById(‘winA‘).innerHTML = parseInt(document.getElementById(‘winA‘).innerHTML) + 1; document.getElementById(‘GFirst‘).value = document.getElementById(‘fenA‘).innerHTML + ":" + document.getElementById(‘fenB‘).innerHTML; document.getElementById(‘fenA‘).innerHTML = 0; document.getElementById(‘fenB‘).innerHTML = 0; a = 0; alert("主队胜利"); } } if (jushu == 1 && (parseInt(wina) - parseInt(winb) < 3)) { document.getElementById(‘fenA‘).innerHTML = a; if (a >= 25 && (a - b) > 2) { document.getElementById(‘winA‘).innerHTML = parseInt(document.getElementById(‘winA‘).innerHTML) + 1; document.getElementById(‘GSecond‘).value = document.getElementById(‘fenA‘).innerHTML + ":" + document.getElementById(‘fenB‘).innerHTML; document.getElementById(‘fenA‘).innerHTML = 0; document.getElementById(‘fenB‘).innerHTML = 0; a = 0; alert("主队胜利"); } } if (jushu == 2 && (parseInt(wina) - parseInt(winb) < 3)) { document.getElementById(‘fenA‘).innerHTML = a; if (a >= 25 && (a - b) > 2) { document.getElementById(‘winA‘).innerHTML = parseInt(document.getElementById(‘winA‘).innerHTML) + 1; document.getElementById(‘GThird‘).value = document.getElementById(‘fenA‘).innerHTML + ":" + document.getElementById(‘fenB‘).innerHTML; document.getElementById(‘fenA‘).innerHTML = 0; document.getElementById(‘fenB‘).innerHTML = 0; a = 0; alert("主队胜利"); } } if (jushu == 3 && (parseInt(wina) - parseInt(winb) < 3)) { document.getElementById(‘fenA‘).innerHTML = a; if (a >= 25 && (a - b) > 2) { document.getElementById(‘winA‘).innerHTML = parseInt(document.getElementById(‘winA‘).innerHTML) + 1; document.getElementById(‘GFourth‘).value = document.getElementById(‘fenA‘).innerHTML + ":" + document.getElementById(‘fenB‘).innerHTML; document.getElementById(‘fenA‘).innerHTML = 0; document.getElementById(‘fenB‘).innerHTML = 0; a = 0; alert("主队胜利"); } } if (jushu == 4 && (parseInt(wina) - parseInt(winb) < 3)) { document.getElementById(‘fenA‘).innerHTML = a; if (a >= 15 && (a - b) > 2) { document.getElementById(‘winA‘).innerHTML = parseInt(document.getElementById(‘winA‘).innerHTML) + 1; document.getElementById(‘GFifth‘).value = document.getElementById(‘fenA‘).innerHTML + ":" + document.getElementById(‘fenB‘).innerHTML; document.getElementById(‘fenA‘).innerHTML = 0; document.getElementById(‘fenB‘).innerHTML = 0; a = 0; alert("主队胜利"); } } } else { document.getElementById(‘GSum‘).value = document.getElementById(‘winA‘).innerHTML + ":" + document.getElementById(‘winB‘).innerHTML; } } function addB() { var wina = document.getElementById(‘winA‘).innerHTML; var winb = document.getElementById(‘winB‘).innerHTML; var jushu = parseInt(document.getElementById(‘winA‘).innerHTML) + parseInt(document.getElementById(‘winB‘).innerHTML); a2++; if (parseInt(winb) < 3 && parseInt(wina)<3) { if (jushu == 0&&(parseInt(winb)-parseInt(wina)<3)) { document.getElementById(‘fenB‘).innerHTML = a2; if (a2 >= 25 && (a2 - b2) > 2) { document.getElementById(‘winB‘).innerHTML = parseInt(document.getElementById(‘winB‘).innerHTML) + 1; document.getElementById(‘GFirst‘).value = document.getElementById(‘fenA‘).innerHTML + ":" + document.getElementById(‘fenB‘).innerHTML; document.getElementById(‘fenB‘).innerHTML = 0; document.getElementById(‘fenA‘).innerHTML = 0; a2 = 0; alert("主队胜利"); } } if (jushu == 1 && (parseInt(winb) - parseInt(wina) < 3)) { document.getElementById(‘fenB‘).innerHTML = a2; if (a2 >= 25 && (a2 - b2) > 2) { document.getElementById(‘winB‘).innerHTML = parseInt(document.getElementById(‘winB‘).innerHTML) + 1; document.getElementById(‘GSecond‘).value = document.getElementById(‘fenA‘).innerHTML + ":" + document.getElementById(‘fenB‘).innerHTML; document.getElementById(‘fenB‘).innerHTML = 0; document.getElementById(‘fenA‘).innerHTML = 0; a2 = 0; alert("主队胜利"); } } if (jushu == 2 && (parseInt(winb) - parseInt(wina) < 3)) { document.getElementById(‘fenB‘).innerHTML = a2; if (a2 >= 25 && (a2 - b2) > 2) { document.getElementById(‘winB‘).innerHTML = parseInt(document.getElementById(‘winB‘).innerHTML) + 1; document.getElementById(‘GThird‘).value = document.getElementById(‘fenA‘).innerHTML + ":" + document.getElementById(‘fenB‘).innerHTML; document.getElementById(‘fenB‘).innerHTML = 0; document.getElementById(‘fenA‘).innerHTML = 0; a2 = 0; alert("主队胜利"); } } if (jushu == 3 && (parseInt(winb) - parseInt(wina) < 3)) { document.getElementById(‘fenB‘).innerHTML = a2; if (a2 >= 25 && (a2 - b2) > 2) { document.getElementById(‘winB‘).innerHTML = parseInt(document.getElementById(‘winB‘).innerHTML) + 1; document.getElementById(‘GFourth‘).value = document.getElementById(‘fenA‘).innerHTML + ":" + document.getElementById(‘fenB‘).innerHTML; document.getElementById(‘fenB‘).innerHTML = 0; document.getElementById(‘fenA‘).innerHTML = 0; a2 = 0; alert("主队胜利"); } } if (jushu == 4 && (parseInt(winb) - parseInt(wina) < 3)) { document.getElementById(‘fenB‘).innerHTML = a2; if (a2 >= 15 && (a2 - b2) > 2) { document.getElementById(‘winB‘).innerHTML = parseInt(document.getElementById(‘winB‘).innerHTML) + 1; document.getElementById(‘GFifth‘).value = document.getElementById(‘fenA‘).innerHTML + ":" + document.getElementById(‘fenB‘).innerHTML; document.getElementById(‘fenB‘).innerHTML = 0; document.getElementById(‘fenA‘).innerHTML = 0; a2 = 0; alert("主队胜利"); } } } else { document.getElementById(‘GSum‘).value = document.getElementById(‘winA‘).innerHTML + ":" + document.getElementById(‘winB‘).innerHTML; } } </script> <h2>计分</h2> <div style="width:300px;height:200px; float:left; margin-left:100px;text-align:center;font-size:20px;"> <p>@Html.Encode(ViewData["teamA"])</p><span>胜局</span><span id="winA">0</span> <p><span id="fenA">0</span></p> </div> <div style="width:300px;height:200px;float:left;text-align:center;font-size:20px;"> <p>@Html.Encode(ViewData["teamB"])</p><span>胜局</span><span id="winB">0</span> <p><span id="fenB">0</span></p> </div> <div style="float:none;margin-left:200px;width:400px;text-align:center;"> <button onclick="addA()">主队加分</button> <button onclick="addB()">客队加分</button> </div> @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <legend>total</legend> <div class="editor-field" style="display:none;"> @Html.EditorFor(model => model.teamA) @Html.EditorFor(model => model.teamB) @Html.EditorFor(model => model.GFirst) @Html.EditorFor(model => model.GSecond) @Html.EditorFor(model => model.GThird) @Html.EditorFor(model => model.GFourth) @Html.EditorFor(model => model.GFifth) @Html.EditorFor(model => model.GSum) </div> <p> <input type="submit" value="保存数据" /> </p> </fieldset> }
@model IEnumerable<MvcApplication1.Models.total> @{ ViewBag.Title = "Index"; } <h2>Index</h2> <style type="text/css"> table, td, th { border: thin solid black; border-collapse: collapse; padding: 5px; background-color: lemonchiffon; text-align: left; margin: 10px 0; text-align:center; } </style> <p> @Html.ActionLink("Create New", "Create") </p> <table> <tr> <th> @Html.Encode("主方队名") </th> <th> @Html.Encode("客方队名") </th> <th> @Html.Encode("第一局") </th> <th> @Html.Encode("第二局") </th> <th> @Html.Encode("第三局") </th> <th> @Html.Encode("第四局") </th> <th> @Html.Encode("第五局") </th> <th> @Html.Encode("总比分") </th> <th> @Html.Encode("操作") </th> </tr> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.teamA) </td> <td> @Html.DisplayFor(modelItem => item.teamB) </td> <td> @Html.DisplayFor(modelItem => item.GFirst) </td> <td> @Html.DisplayFor(modelItem => item.GSecond) </td> <td> @Html.DisplayFor(modelItem => item.GThird) </td> <td> @Html.DisplayFor(modelItem => item.GFourth) </td> <td> @Html.DisplayFor(modelItem => item.GFifth) </td> <td> @Html.DisplayFor(modelItem => item.GSum) </td> <td> @Html.ActionLink("Edit", "Edit", new { id=item.ID }) | @Html.ActionLink("Delete", "Delete", new { id=item.ID }) </td> </tr> } </table>
标签:inpu team doc bsp ++ model var 视图 box
原文地址:http://www.cnblogs.com/ghf1/p/7072045.html