MVC database additions and deletions (Razor) view (2)

Source: Internet
Author: User
Tags actionlink

   (i) main Page
@using mvcapplication1.models; @model List<student>@{Layout=NULL;}<! DOCTYPE html>"Viewport"Content="Width=device-width"/> <title>Index</title> <style type="Text/css">. tbhead {background-Color:navy; Text-Align:center; Color:white; Font-Weight:bold; }. tbrow1 {text-Align:center; Background-color: #FFFFcc; }. tbrow2 {text-Align:center; Background-color: #ccFFFF; } </style>"Tbstu"Width="100%"cellpadding="4"cellspacing="1"Border="0"> <trclass="Tbhead"> <td> Study number </td> <td> name </td> <td> sex </td> <td> Birthdays </td> <td> classes </td> <td> actions </td> </tr> @{ intI=0; foreach(Student SinchModel) { if(i%2==0) { <trclass="Tbrow1"> <td>@s.Sno</td> <td>@s.Sname</td> <td>< IMG src="@ (s.ssex=="Man" ? "Images/nan.png":"Images/nv.png")"/> </td> <td>@s.sbirthday.value.tolongdatestring (). ToString () </td> <td>@s.Class</td> <td> @* <a href="/home/xiugai/@s.sno"> Modify </a>*@ @Html. ActionLink ( "Modify", "Xiugai", "Home", new {Id=s.sno},null) @* <a href="/home/delete/@s.sno"onclick="return confirm (' Confirm delete @s.sname? ')"> Delete </a>*@ @Html. ActionLink ( "Delete", "delete", "Home", new {id = S.sno}, new {onclick= "return confirm (' OK to delete? ') '})</td> </tr> } Else { <trclass="Tbrow2"> <td>@s.Sno</td> <td>@s.Sname</td> <td>< IMG src="@ (s.ssex=="Man" ? "Images/nan.png":"Images/nv.png")"/></td> <td>@s.sbirthday.value.tolongdatestring (). ToString () </td> <td>@s.Class</td> <td>@Html. ActionLink ("Modify", "Xiugai", "Home", new {Id=s.sno}, NULL) @Html. actionl Ink ("Remove", "delete", "Home", new {id = S.sno}, new {onclick= "return confirm (' OK to delete? ') '})</td> </tr>} i++; } } </table> <form action="/home/zengjia"Method="Post"> <input type="Submit"Value="Add"/> </form> </div></body>

   (b) Modification of the page

@using mvcapplication1.models; @model student @{Layout=NULL;}<! DOCTYPE html>"Viewport"Content="Width=device-width"/> <title>xiugai</title> <style type="Text/css">. UU {List-Style:none; } </style>"F1"Name="F1"action="/home/update"Method="Post"> @{ if(model!=NULL) { <ulclass="UU"><li> No.: @*<input type= "text" name= "Sno" readonly= "readonly" value= "@s.sno"/>*@ @Html. Textboxfor (p = P.sno, new {}) </li> <li> name: @Html. Textboxfor (P=>p.sname) </li> <li> Gender: @Html. Radiobuttonfor (P=>p.ssex, "male") male @Html radiobuttonfor (p=>p.ssex, "female") female </li> <li> Birthdays: @Html. Textboxfor (p=>p.sbirthday) </li> <li& gt; class: @Html. Textboxfor (p=>p.class) </li></ul> <input type="Submit"Name="Submit"Value="Update"/> } } </form> <form action="/home/tiaozhuan"Method="Post"> <input type="Submit"Value="Back to homepage"/> </form> </div></body>
   (iii) additional pages

@using mvcapplication1.models; @model student@{Layout=NULL;}<! DOCTYPE html>"Viewport"Content="Width=device-width"/> <title>zengjia</title>"F1"Name="F1"action="/home/add"Method="Post"> <ulclass="UU"><li> No.: @Html. Textboxfor (p=>p.sno) </li> <li> name: @Html. Textboxfor (p=>p.sname) </ li> <li> Gender: @Html. Radiobuttonfor (p = p.ssex, "male") male @Html. Radiobuttonfor (P=>p.ssex, "female") female < ;/li> <li> Birthdays: @Html. Textboxfor (p=>p.sbirthday) </li> <li> class: @Html. Text Boxfor (p=>p.class) </li></ul> <input type="Submit"Name="Submit"Value="Add"/> </form> <form action="/home/tiaozhuan"Method="Post"> <input type="Submit"Value="Back to homepage"/> </form> </div></body>

   (d) Error display interface
@{Layout=NULL;}<! DOCTYPE html>"Viewport"Content="Width=device-width"/> <title>chucuo</title>"/home/tiaozhuan"Method="Post"> <input type="Submit"Value="Back to homepage"/> </form> </div></body>

MVC Database Additions and deletions (Razor) view (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.