gpt4 book ai didi

asp.net - 如果文本框名称在字符串变量中,如何获取 clientID

转载 作者:行者123 更新时间:2023-11-29 10:54:28 25 4
gpt4 key购买 nike

我写了下面的代码来检查我的文本框中是否有空白值,但是它生成了编译错误,请提供解决方案。

我在 javascript 中的代码:

 function checkTextboxNotFilled(txtbox) {
var txtb = document.getElementById("<%= " + txtbox + ".ClientID %>");
if (GetFormattedString(txtb.value) == "") {
return true ;
}
else {
return false ;
}
}

错误:

'string' does not contain a definition for 'ClientID' and no extension method 'ClientID' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)

我这样调用它:checkTextboxNotFilled("MytextboxName")

最佳答案

这可能对你有帮助。

 function checkTextboxNotFilled(txtboxid) {
var txtb = document.getElementById(txtboxid);
if (GetFormattedString(txtb.value) == "") {
return true ;
}
else {
return false ;
}
}

并调用:checkTextboxNotFilled("<%= Mytextbox.ClientID %>");

关于asp.net - 如果文本框名称在字符串变量中,如何获取 clientID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3146791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com