62,269
社区成员
发帖
与我相关
我的任务
分享
<!--这个是原来的Textarea 运行在服务器端 -->
<textarea id="content" name="content" runat="server" rows="20" style="width:60%"></textarea>
<br />
<br />
<button runat="server" id="_Submit" onserverclick="_Submit_ServerClick">=提交=</button>
<!------>
<!--在输出页面时 在标签中写入了一些字-->
<textarea name="content" id="content" rows="20" style="width:60%">fjiwjofgiejrigjoierjgeg
gjieorjgoierjg
该留言被主人在2009-1-17 23:37:32编辑过
textarea>
<!---->
protected void _Submit_ServerClick(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection(
ConfigurationManager.ConnectionStrings["default"].ConnectionString);
SqlCommand cmd = connection.CreateCommand();
cmd.CommandText = "Update GuestBook SET CONTENT=@1 WHERE ID=@2";
cmd.Parameters.Add(new SqlParameter("@1", SqlDbType.Text));
cmd.Parameters[0].Value =
content.InnerHtml.Replace("\n","<br />") + "<br /><br /><div style=\"font-style:inherit; text-align:right;\">该留言被主人在"+DateTime.Now.ToString()+"编辑过</div>";
cmd.Parameters.Add(new SqlParameter("@2", SqlDbType.Int));
cmd.Parameters[1].Value = msgId;
connection.Open();
cmd.ExecuteNonQuery();
cmd.Dispose();
connection.Close();
connection.Dispose();
Response.Write("<script>window.location.href='GuestBook.aspx'</script>");
}