获取并将textarea值插入数据库

时间:2014-02-15 18:48:53

标签: c# html asp.net razor

我的代码是:

      @{
    var updatedabout= Request.Form["updateabout"];
        var db = Database.Open("database3");
if (isPost) {
        var update = db.QuerySingle("UPDATE users SET about = @0 WHERE [E-mail] = @1",updatedabout,WebSecurity.CurrentUserName); 
}}

<form class="horizontal" action="" method="POST">
    <textarea id="updateabout" name="updateabout" rows="5">example</textarea>
<button type="submit">
</form>

我想将用户在文本区域中写入的内容提交给数据库。但我不能让它工作。上面的代码是我到目前为止。

1 个答案:

答案 0 :(得分:0)

Request.Form["updateabout"]; gets value from query string but in your case you have a text area. If you are using javascript try to use 
var updatedabout=document.getElementById('updatedabout').value;