use*_*656 2 c# asp.net textarea
我试图使用以下代码从代码后面获取textarea值.
HtmlTextArea bodytextarea = new HtmlTextArea();
bodytextarea = (HtmlTextArea)(this.FindControl("codearea"));
string txtbod = bodytextarea.Value;
Run Code Online (Sandbox Code Playgroud)
当我调试它时,我得到一个空引用异常,说bodytextarea为null.我必须提到我的textarea不是runat ="server",我不想在服务器端制作它.有帮助吗?
你应该加入runat="server"你的<TextArea id="myTextArea" runat="server" />
像这样你可以直接通过使用textarea的ID来获取代码中的值
如果你不想使用服务器端,那么你必须使用Jquery来获取值并[webmethod]在你的代码中创建一个方法,以便Jquery可以调用该方法传递值
或者干脆 string data = request["codearea"];
| 归档时间: |
|
| 查看次数: |
7209 次 |
| 最近记录: |