1. 程式人生 > >ajax.BeginForm非同步提交表單並顯示更新資料

ajax.BeginForm非同步提交表單並顯示更新資料

  1 <!--基本資訊模組-->
  2   2         <div class="profile_box" id="basicInfo">
  3   3             <h2>基本資訊</h2>
  4   4 
  5   5             <%if (ViewData["Basic"] == "1")
  6   6               {%><!--如果基本資訊資料庫中有則顯示資料-->
  7   7             <span class="c_edit"
id="spantest"></span> 8 8 9 9 <div class="basicShow"> 10 10 <span id="spantest1"><%=Model.NAME %> <%=Model.SEX %> <%=Model.EDUCATION_BACKGROUND %> <%=Model.WORK_EXPERIENCE %><br> 11 11 <%
=Model.PHONENUMBER %> <%=Model.EMAIL %> <%=Model.SITUATIONID.SITUATION %> 12 12 <br> 13 13 </span> 14 14 <div class="m_portrait"> 15 15 <div></div> 16 16 <
img width="120" height="120" alt="<%=Model.PHOTONUMBER %>" src="<%=Url.Content("~/style/UserImages/"+Model.PHOTONUMBER) %>"> 17 17 </div> 18 18 <!--改動--> 19 19 <%Html.Action("GetBasicInformation", new AjaxOptions { UpdateTargetId = "basicInfo" }); %> 20 20 <!--改動--> 21 21 </div> 22 22 <!--end .basicShow--> 23 23 <%} %> 24 24 <%else 25 25 { %><!--如果基本資訊資料庫中沒有則顯示完善基本資訊--> 26 26 <div class="basicInformationAdd pAdd" id="basicAdd"> 27 27 完善基本資訊能讓招聘單位更加了解我們哦…<br> 28 28 快來完善基本資訊吧! 29 29 <span id="basicAddspan">新增基本資訊</span> 30 30 </div> 31 31 <!--end .basicInformationAdd--> 32 32 <%} %> 33 33 <div class="basicEdit dn" id="basicEdit"> 34 34 35 35 <%using (Ajax.BeginForm("GetBasicInformation", "Employee", new AjaxOptions { UpdateTargetId = "basicInfo", LoadingElementId = "loading", LoadingElementDuration = 3000, Url = Url.Action("GetBasicInformation"), HttpMethod = "Post" }, new { @class = "profileForm", id = "BasicInformation" })) 36 36 { %> 37 37 //UpdateTargetId:設定HTML元素的ID,從伺服器接收的內容將被插入到該元素中;LoadingElementId:指定HTML元素的ID,這是執行ajax請求其間要顯示的HTML元素 38 38 //LoadingElementDuration:指定動畫的持續時間,用於顯露由LoadingElementId指定的元素,單位為毫秒 39 //Url:設定所請求的伺服器端URL,此項效果:如果未啟用JavaScript,則建立一個回遞給原始動作方法的form元素,確保優雅降級 40 //HttpMethod:請求的http方法 41 39 42 40 <!--<label id="NICKNAME" >姓名</label>--> 43 41 <%=Html.Label("NAME", "姓名")%> 44 42 <div> 45 43 <%=Html.TextBox("NAME","", new { @PlaceHolder = "姓名" })%> 46 44 <!--<input type="text" placeholder="姓名" value="jason" name="name" id="name">--> 47 45 <span class="redstar">*</span><%=Html.ValidationMessage("NAME", new { @class = "ValidationMessage" })%> 48 46 </div> 49 47 50 48 51 49 <%=Html.Label("SEX", "性別")%> 52 50 <div> 53 51 <ul class="profile_radio clearfix reset"> 54 52 55 53 <li class=""><em></em> 56 54 <%=Html.RadioButton("SEX", "")%> 57 55 <!--<input type="radio" checked="checked" name="gender" value="男"> --> 58 56 </li> 59 57 <li class=""><em></em> 60 58 <%=Html.RadioButton("SEX", "")%> 61 59 <!--<input type="radio" name="gender" value="女"> --> 62 60 </li> 63 61 </ul> 64 62 65 63 </div> 66 64 67 65 68 66 <%=Html.Label("EDUCATION_BACKGROUND", "學歷")%> 69 67 70 68 <div> 71 69 <%=Html.DropDownList("EDUCATION_BACKGROUND", new SelectListItem[]{ 72 70 new SelectListItem(){Value="大專",Text="大專"}, 73 71 new SelectListItem(){Value="本科",Text="本科"}, 74 72 new SelectListItem(){Value="碩士",Text="碩士"}, 75 73 new SelectListItem(){Value="博士",Text="博士"}, 76 74 new SelectListItem(){Value="其他",Text="其他"} 77 75 }, new { @class = "profile_select_190 profile_select_normal" })%> 78 76 <span class="redstar">*</span> 79 77 </div> 80 78 <%=Html.Label("WORK_EXPERIENCE", "工作經驗")%> 81 79 <div> 82 80 <%=Html.DropDownList("WORK_EXPERIENCE", new SelectListItem[]{ 83 81 new SelectListItem(){Value="應屆畢業生",Text="應屆畢業生"}, 84 82 new SelectListItem(){Value="1年",Text="1年"}, 85 83 new SelectListItem(){Value="2年",Text="2年"}, 86 84 new SelectListItem(){Value="3年",Text="3年"}, 87 85 new SelectListItem(){Value="4年",Text="4年"}, 88 86 new SelectListItem(){Value="5年",Text="5年"}, 89 87 new SelectListItem(){Value="6年",Text="6年"}, 90 88 new SelectListItem(){Value="7年",Text="7年"}, 91 89 new SelectListItem(){Value="8年",Text="8年"}, 92 90 new SelectListItem(){Value="9年",Text="9年"}, 93 91 new SelectListItem(){Value="10年",Text="10年"}, 94 92 new SelectListItem(){Value="10年以上",Text="10年以上"} 95 93 }, new { @class = "profile_select_190 profile_select_normal" })%> 96 94 <span class="redstar">*</span> 97 95 </div> 98 96 99 97 <%=Html.Label("PHONENUMBER", "手機號碼")%> 100 98 <div> 101 99 <%=Html.TextBox("PHONENUMBER","", new { @PlaceHolder = "手機號碼" })%> 102 100 103 101 <span class="redstar">*</span><%=Html.ValidationMessage("PHONENUMBER", new { @class = "ValidationMessage" })%> 104 102 </div> 105 103 106 104 <%=Html.Label("EMAIL", "聯絡郵箱")%> 107 105 <div> 108 106 <%=Html.TextBox("EMAIL","", new { @PlaceHolder = "接收面試通知的郵箱" })%> 109 107 110 108 <span class="redstar">*</span><%=Html.ValidationMessage("EMAIL", new { @class = "ValidationMessage" })%> 111 109 </div> 112 110 113 111 <%=Html.Label("SITUATIONID", "目前狀態")%> 114 112 <div> 115 113 116 114 <%=Html.DropDownList("SITUATIONID.ID", new SelectListItem[]{ 117 115 new SelectListItem(){Value="1",Text="我目前已離職,可快速到崗"}, 118 116 new SelectListItem(){Value="2",Text="我目前正在職,正考慮換個新環境"}, 119 117 new SelectListItem(){Value="3",Text="我暫時不想找工作"}, 120 118 new SelectListItem(){Value="4",Text="我是應屆畢業生"} 121 119 }, new { @class = "p