【发布时间】:2016-12-06 13:35:15
【问题描述】:
Java Script 在使用 ASP.NET C# 的内容页面中不起作用,我正在尝试计算下面多行文本框的字符是字符计数代码。 低于错误。
加载资源失败:服务器响应状态为 404 (Not Found) Uncaught ReferenceError: txtComments is not defined(…)
下面是我的代码JS和设计代码。
<script type="text/javascript">
function characterCounter(controlId, countControlId, maxCharlimit) {
if (controlId.value.length > maxCharlimit)
controlId.value = controlId.value.substring(0, maxCharlimit);
else countControlId.value = maxCharlimit - controlId.value.length;
}
</script>
<fieldset style="width: 280px;">
<legend>Counting Remaining Characters example</legend>
<asp:TextBox ID="txtComments" Width="280px" Rows="4" Columns="12" runat="server"
TextMode="MultiLine" onkeyup="characterCounter(txtComments, this.form.remCount, 150);"
onkeydown="characterCounter(txtComments, this.form.remCount, 150);" /><input type="text"
name="remCount" size="3" maxlength="3" value="150" readonly="readonly" />
characters left
</fieldset>
当我尝试输入一些东西时,值不会改变。
【问题讨论】:
标签: javascript c# asp.net