前台
<script> function Copy() { var value = document.getElementById("<%=BodyBox.ClientID %>").innerHTML; var real = value.replace(/<[^>]*>/g, "").replace(/ /g, "").replace(/s+/g, ""); if (real == "") { //alert("real is null"); document.getElementById("<%=BodyBox2.ClientID %>").value = ""; } else { //alert("real is not null: "+real) document.getElementById("<%=BodyBox2.ClientID %>").value = value; } } </script> <div runat="server" class="ms-rtestate-field ms-rtefield"> <div id="BodyBox" runat="server" contenteditable="true" class="ms-rtestate-write ms-rteflags-0 ms-rtestate-field" role="textbox" aria-autocomplete="both" aria-haspopup="true" aria-multiline="true"> </div> </div> <div><asp:Button ID="Button1" runat="server" Text="更新多行文本" OnClientClick="Copy()" OnClick="Button1_Click" /></div> <textarea id="BodyBox2" runat="server"></textarea>
后台
protected void Button1_Click(object sender, EventArgs e) { string value = BodyBox2.Value; genggai(); } private void genggai() { SPListItem li = web.Lists["办理"].GetItemById(int.Parse(Page.Request["ID"]));//实例化要添加的列的值如果部署到别的列表里就更改test2这个列表名 SPListItemCollection listItems = web.Lists["办理"].Items; string value = BodyBox2.Value; foreach (SPListItem list in listItems) { if (list["标题"].ToString() == li["标题"].ToString()) { list["情况"] = value; list.Update(); } } }