HTML如何将输入数据传给数据库

时间:2024-10-15 04:31:32

1、利用jQuery获取文本框里的值。<div class="form-group"> &造婷用痃lt;div class="attr">昵称:</div> <div class="val"> <input class="form-control" id="lnicheng" maxlength="20" value="@ViewBag.nicheng" type="text" /> </div> </div> <div class="form-group"> <div class="attr">联系电话:</div> <div class="val"> <input class="form-control" id="ltel" maxlength="11" onkeyup="value=value.replace(/[^0-9]/g,'')" value="@ViewBag.phone" type="text" /> </div> </div>

HTML如何将输入数据传给数据库

2、把获取的数据以参数json格式传给后台代码

HTML如何将输入数据传给数据库

3、ajax调用C#webservice接口执行后台代码把数据存入数据库StringBuilder sb = new StringBuilder(); sb.Append("{"); nicheng = HttpUtility.UrlEncode(nicheng, System.Text.Encoding.UTF8); int result = 0; if (touxiang == "") { string[] arr1 = { "nicheng", "user_id", nicheng, userid }; result = SystemTool.DoSql("2", "huiyuan", arr1); } else { string imgSaveName = jiexi_picture(touxiang, "touxiang"); string[] arr1 = { "mobilePhone", "nicheng", "user_logo", "user_id",tel, nicheng, imgSaveName, userid }; result = SystemTool.DoSql("2", "huiyuan", arr1); } if (result < 1) { sb.Append(string.Format("\"{0}\":{1},", "resultstutas", "false")); sb.Append(string.Format("\"{0}\":\"{1}\"", "resultmessage", "失败")); sb.Append("}"); return sb.ToString(); } else { sb.Append(string.Format("\"{0}\":{1},", "resultstutas", "true")); sb.Append(string.Format("\"{0}\":\"{1}\"", "resultmessage", "成功")); } sb.Append("}"); return sb.ToString();

HTML如何将输入数据传给数据库
HTML如何将输入数据传给数据库
© 手抄报圈