javascript - 单击提交按钮时传递文本区域的值

标签 javascript jquery asp.net html

<textarea id="Comment" type="text" runat="server" rows="7" 
maxlength="2000" />

<input id="SubmitComment" type="button" value="Submit"
onclick="SubmitButton()" /> 

当用户在文本区域中输入数据并单击“提交”按钮时,我希望将数据传递到submitButton(),然后我可以将其发送到Functions.CommentBoxForInvoiceUpdates

function SubmitButton() {
var commentBoxData = $('#Comment').val();
Functions.CommentBoxForInvoiceUpdates(id, Labour, commentBoxData);
        } 

Id 和 Labor 是较早定义的,因此它们工作正常,但是当我通过断点运行“CommentBoxData”时,它显示为未定义。 为什么单击“提交”时会发送评论框中的数据?

感谢您的任何想法

最佳答案

您已用 asp.net 标记。确定您正在使用渲染的 ID?

关于javascript - 单击提交按钮时传递文本区域的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15529363/

相关文章:

javascript - jQuery:使用 .find 和 .addClass

asp.net - 在ASP.NET和ASP.NET MVC中使用url参数实现搜索页面

asp.net - 代码优先迁移是否使用事务?

javascript - 如何在 Mongoose 中定义一个不同于 _id 的主键?

javascript - 自定义管道返回错误。::TypeScript & Angular2

javascript - 选项根据用户的选择逐步显示

jquery - 使用 jquery 将项目添加到列表框

c# - 使用 NewtonSoft - 数组将 JSON 反序列化为 .net 对象

javascript - ShowHide (shID) 一次只显示一个 div?

javascript - 输入 onChange w/React & TypeScript 错误 : jsx no-lambda no-bind