下拉框的使用:
<tr> <th>设计风格:</th> <td> <select name="DesignStyle" class="select"> <option value="1" @(Html.ValueFor(m => m.StayGrade).ToString() == "1" ? "selected" : "")>网红ins风</option> <option value="2" @(Html.ValueFor(m => m.StayGrade).ToString() == "2" ? "selected" : "")>中式风</option> <option value="3" @(Html.ValueFor(m => m.StayGrade).ToString() == "3" ? "selected" : "")>日式风</option> <option value="4" @(Html.ValueFor(m => m.StayGrade).ToString() == "4" ? "selected" : "")>工业风</option> <option value="5" @(Html.ValueFor(m => m.StayGrade).ToString() == "5" ? "selected" : "")>北欧风</option> <option value="6" @(Html.ValueFor(m => m.StayGrade).ToString() == "6" ? "selected" : "")>小清新风</option> </select> </td> </tr>
单选按钮:
<tr> <th>人脸检票支持:</th> <td> <label> <input type="radio" name="FaceChecking" value="1" @(Html.ValueFor(m => m.FaceChecking).ToString() == "1" ? "checked" : "")> 支持人脸检票(<span class="tips_gray">仅限于有人脸检票设备的景区勾选</span>) <input type="radio" name="FaceChecking" checked="checked" value="0" @(Html.ValueFor(m => m.FaceChecking).ToString() == "0" ? "checked" : "")>不支持人脸检票 </label> </td> </tr>
多选按钮:
<tr> <th>角色:</th> <td> <input type="checkbox" name="Role" value="0" @(!string.IsNullOrEmpty(Model.Role) && Model.Role.IndexOf("0") >-1?"checked":"") /> 平台 <input type="checkbox" name="Role" value="1" @(!string.IsNullOrEmpty(Model.Role) && Model.Role.IndexOf("1") > -1 ? "checked" : "") /> 运营商 <input type="checkbox" name="Role" value="2" @(!string.IsNullOrEmpty(Model.Role) && Model.Role.IndexOf("2") > -1 ? "checked" : "") /> 供应商 <input type="checkbox" name="Role" value="3" @(!string.IsNullOrEmpty(Model.Role) && Model.Role.IndexOf("3") > -1 ? "checked" : "") /> 分销商 </td> </tr>
2:
<tr> <th>通知字段:</th> <td> <div class="sys_agent_per"> <ul> <li><label><input type="checkbox" name="NoticeField" value="OrderID" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "OrderID") ? "checked" : "")>订单号</label></li> <li><label><input type="checkbox" name="NoticeField" value="UserName" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "UserName") ? "checked" : "")>姓名</label></li> <li><label><input type="checkbox" name="NoticeField" value="Mobile" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "Mobile") ? "checked" : "")>手机号码</label></li> <li><label><input type="checkbox" name="NoticeField" value="CardID" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "CardID") ? "checked" : "")>身份证号码</label></li> <li><label><input type="checkbox" name="NoticeField" value="Address" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "Address") ? "checked" : "")>配送地址</label></li> <li><label><input type="checkbox" name="NoticeField" value="Email" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "Email") ? "checked" : "")>电子邮箱</label></li> <li><label><input type="checkbox" name="NoticeField" value="ProductName" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "ProductName") ? "checked" : "")>产品名称</label></li> <li><label><input type="checkbox" name="NoticeField" value="PlayTime" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "PlayTime") ? "checked" : "")>出行日期</label></li> <li><label><input type="checkbox" name="NoticeField" value="Number" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "Number") ? "checked" : "")>订单数量</label></li> <li><label><input type="checkbox" name="NoticeField" value="Memo" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "Memo") ? "checked" : "")>订单备注</label></li> <li><label><input type="checkbox" name="NoticeField" value="ConferPrice" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "ConferPrice") ? "checked" : "")>签约价</label></li> <li><label><input type="checkbox" name="NoticeField" value="TotalConferPrice" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "TotalConferPrice") ? "checked" : "")>签约价小计</label></li> <li><label><input type="checkbox" name="NoticeField" value="Price" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "Price") ? "checked" : "")>分销价</label></li> <li><label><input type="checkbox" name="NoticeField" value="TotalPrice" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "TotalPrice") ? "checked" : "")>分销价小计</label></li> <li><label><input type="checkbox" name="NoticeField" value="SalePrice" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "SalePrice") ? "checked" : "")>零售价</label></li> <li><label><input type="checkbox" name="NoticeField" value="TotalSalePrice" @(TravelB2B.Core.Utils.Tools.NoticeFieldChecked(Model.NoticeField, "TotalSalePrice") ? "checked" : "")>零售价小计</label></li> </ul> </div> </td> </tr>
共用方法: public static bool NoticeFieldChecked(string[] noticeField, string field) { return NoticeFieldChecked(Array2String(noticeField), field); }
#region 数组转化成逗号隔开的字符串 /// <summary> /// 数组转化成逗号隔开的字符串 /// </summary> /// <param name="arr"></param> /// <returns></returns> public static string Array2String(string[] arr) { return Array2String(arr, ","); } public static string Array2String(string[] arr, string splitChar) { if (arr != null) { StringBuilder sb = new StringBuilder(); if (arr != null) { for (int i = 0; i < arr.Length; i++) { sb.Append(arr[i]); if (i + 1 < arr.Length) sb.Append(splitChar); } } return sb.ToString(); } return string.Empty; } #endregion
public static bool NoticeFieldChecked(string noticeField, string field) { if (string.IsNullOrEmpty(noticeField)) { noticeField = "OrderID,UserName,Mobile,ProductName,PlayTime,Number"; } if (!noticeField.StartsWith(",")) noticeField = "," + noticeField; if (!noticeField.EndsWith(",")) { noticeField += ","; } return noticeField.IndexOf("," + field + ",") > -1; }
MODEL: public String[] NoticeField { get; set; }
实体: public string NoticeField{get;set;}
Info.NoticeField = TravelB2B.Core.Utils.Tools.Array2String(this.NoticeField);
保存代码:if (Info.NoticeField != TravelB2B.Core.Utils.Tools.Array2String(this.NoticeField)) { sb.Append("NoticeField的值由" + Info.NoticeField + "改为" + this.NoticeField + "<br>"); Info.NoticeField = TravelB2B.Core.Utils.Tools.Array2String(this.NoticeField); } 保存后数据库值为:OrderID,UserName,Mobile,ProductName,PlayTime,Number
原文地址:https://www.cnblogs.com/hugeboke/p/11611845.html
时间: 2024-11-12 13:53:17