C# asp.net : 从 textarea 获取值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16296695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
asp.net : Get the value from textarea
提问by sankara pandian
i am creating one form for image upload drag and drop through jquery.
我正在创建一种通过 jquery 进行图像上传拖放的表单。
when i dragged one image to aspx form, that time that image preview and title ( textarea ) and desc ( textarea ) created to aspx page.
当我将一张图像拖到 aspx 表单时,该图像预览和标题( textarea )和 desc ( textarea )创建到 aspx 页面。
after entered the title and desc, it is saved to database when i click save button.
输入标题和描述后,当我单击保存按钮时,它会保存到数据库中。
i couldn't get the textarea control in c# (code behind ) ?
我无法在 c# 中获得 textarea 控件(代码隐藏)?
textarea does not added directly to aspx page. it is is dynamically added through jquery so????
textarea 不会直接添加到 aspx 页面。它是通过jquery动态添加的,所以???
in jquery textarea added
在 jquery textarea 中添加
<textarea id="txtImagename1" runat="server" rows="1" cols="50"></textarea>
code behind
背后的代码
HtmlTextArea txtImageupload = (HtmlTextArea)(frm.FindControl("txtImagename1"));
string imagename = txtImageupload.Value;
采纳答案by Kapil Khandelwal
Try
尝试
Request.Form["txtImagename1"]
No need of runat="server"
不需要 runat="server"
Also, add name="txtImagename1"
另外,添加 name="txtImagename1"
<textarea id="txtImagename1" name="txtImagename1" rows="1" cols="50"></textarea>
回答by Suave Nti
Add nameattribute to the Dynamic control :
name向动态控件添加属性:
<textarea id="txtImagename1" name="txtImagename1" runat="server" rows="1" cols="50">
</textarea>
from your codebehind :
从你的代码隐藏:
Request.Form["txtImagename1"]
回答by Htin Aung
TextBox txtImageName = (TextBox)Page.FindControl("txtImagename1");
string strFromTextArea = txtImageName.Text;
Note :
笔记 :
- "Page" should be container of your textarea control. If your textarea is in panel, use your panel object instead of Page.
- Multiple lines textbox control is textarea in HTML control.
- “页面”应该是你的 textarea 控件的容器。如果您的 textarea 在面板中,请使用您的面板对象而不是页面。
- 多行文本框控件是 HTML 控件中的文本区域。

