js获取不到用户控件里控件ID....在线等. 10
页面上放一个用户控件,写上JS代码functioncalcResult(){document.getElementById('<%=txtPulsecounting1.C...
页面上放一个用户控件,写上JS代码
function calcResult() {
document.getElementById('<%=txtPulsecounting1.ClientID %>').value = "cndy";
}
用户控件代码:
<div style="border-right: 1px solid #C0C0C0; width: 100px; height: 30px; float: left;">
<asp:TextBox ID="txtHeight1" runat="server" Width="90" BorderStyle="None" BorderWidth="0"
onblur="calcResult()" Style="margin-top: 6px; margin-left: 4px; text-align: center"></asp:TextBox>
</div>
<div style="border-right: 1px solid #C0C0C0; width: 100px; height: 30px; float: left;">
<asp:TextBox ID="txtPulsecounting1" runat="server" Width="90" BorderStyle="None"
BorderWidth="0" Style="margin-top: 6px; margin-left: 4px; text-align: center"></asp:TextBox>
</div>
提示错误:当前上下文中不存在名称“txtPulsecounting1” 展开
function calcResult() {
document.getElementById('<%=txtPulsecounting1.ClientID %>').value = "cndy";
}
用户控件代码:
<div style="border-right: 1px solid #C0C0C0; width: 100px; height: 30px; float: left;">
<asp:TextBox ID="txtHeight1" runat="server" Width="90" BorderStyle="None" BorderWidth="0"
onblur="calcResult()" Style="margin-top: 6px; margin-left: 4px; text-align: center"></asp:TextBox>
</div>
<div style="border-right: 1px solid #C0C0C0; width: 100px; height: 30px; float: left;">
<asp:TextBox ID="txtPulsecounting1" runat="server" Width="90" BorderStyle="None"
BorderWidth="0" Style="margin-top: 6px; margin-left: 4px; text-align: center"></asp:TextBox>
</div>
提示错误:当前上下文中不存在名称“txtPulsecounting1” 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询