获取textarea的在codebehind [英] Get textarea in codebehind

查看:111
本文介绍了获取textarea的在codebehind的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让后面使用以下code从code一个textarea值。

I am trying to get a textarea value from code behind using the following code.

  HtmlTextArea bodytextarea = new HtmlTextArea();
    bodytextarea = (HtmlTextArea)(this.FindControl("codearea"));
    string txtbod = bodytextarea.Value;

当我调试它,我得到一个空引用异常说bodytextarea为空。我不得不提到我的textarea的不=服务器,我不希望把它在服务器端。任何帮助吗?

When i debug it i get a null reference exception saying that bodytextarea is null. I have to mention that my textarea is not runat="server" and i do not want to make it on server side. Any help?

推荐答案

您应该添加 =服务器你的<文本区域ID =myTextArea=服务器/>

这样你就可以直接使用textarea的ID落后只是code值

like this you can directly get the value in code behind just by using the ID of the textarea

如果你不想要使用的服务器端,那么你必须要使用jQuery来获取值,并创建一个 [的WebMethod] 方法在后面让jQuery的你code可以调用方法传递值

And if you dont wanna use server side then you have to use Jquery to get the value and create a [webmethod] method in your code behind so Jquery can call that method passing the value

或只是字符串数据=请求[codeAREA];

这篇关于获取textarea的在codebehind的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆