如何使用javascript基于asp.net中文本框中的文本启用/禁用Button。 [英] how to Enable/disable Button based on text in textboxes in asp.net using javascript.

查看:105
本文介绍了如何使用javascript基于asp.net中文本框中的文本启用/禁用Button。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script language="javascript" type="text/javascript">
//function to enable button if two textboxes contains text
function SetButtonStatus(sender, target) {
var first = document.getElementById('<%=item_name.ClientId %>');
var second = document.getElementById('<%=model.ClientID %>');
var third = document.getElementById('<%=company.ClientId %>');
var fourth = document.getElementById ('<%=quantity.ClientId %>');
//Condition to check whether user enters text in two textboxes or not
if ((sender.value.length >= 1 && first.value.length >= 1) && (sender.value.length >= 1 && second.value.length >= 1) && (sender.value.length >= 1 && third.value.length >= 1) &&(sender.value.length >= 1 && fourth .value.length >= 1))
document.getElementById(target).disabled = false;
else
document.getElementById(target).disabled = true;
}</script>







这是我的代码,但收到错误

错误3'System.Web.UI.WebControls.TextBox'不包含'ClientId'的定义,并且没有可以找到接受类型'System.Web.UI.WebControls.TextBox'的第一个参数的扩展方法'ClientId'(你错过了使用指令或汇编参考吗?



请提出建议。




this is my code but getting an error
Error 3 'System.Web.UI.WebControls.TextBox' does not contain a definition for 'ClientId' and no extension method 'ClientId' accepting a first argument of type 'System.Web.UI.WebControls.TextBox' could be found (are you missing a using directive or an assembly reference?

please suggest something.

推荐答案

试试' ClientID',而不是'ClientId'



希望它有所帮助。
Try 'ClientID', and not 'ClientId'

Hope it helps.


这篇关于如何使用javascript基于asp.net中文本框中的文本启用/禁用Button。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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