使用Javascript在模式内的标签上显示错误消息不工作
我正在开发一个应用程序,在该应用程序中,我仅当用户输入正确的密码时,才向用户提供更改基准年的选项,我通过使用模式弹出扩展程序来实现这一点: 如果密码匹配,则在文本框中将readonly设置为false,否则在面板中提供错误消息使用Javascript在模式内的标签上显示错误消息不工作,javascript,c#,asp.net,label,modalpopupextender,Javascript,C#,Asp.net,Label,Modalpopupextender,我正在开发一个应用程序,在该应用程序中,我仅当用户输入正确的密码时,才向用户提供更改基准年的选项,我通过使用模式弹出扩展程序来实现这一点: 如果密码匹配,则在文本框中将readonly设置为false,否则在面板中提供错误消息 <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none" Width="233px" BackColor="White" > <p&
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none" Width="233px" BackColor="White" >
<p>Password</p>
<br />
<asp:TextBox ID="password" runat ="server"></asp:TextBox>
<br />
<label id="error" runat="server"></label>
<div>
<asp:Button ID="OkButton" runat="server" Text="OK" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
</div>
<br />
<p>If you do not know the password, you may contact a supervisor to receive the password</p>
</asp:Panel>
密码
如果您不知道密码,您可以联系主管以接收密码
这是用户单击“确定”时触发的脚本:
<script type="text/javascript">
function onOk() {
var value = document.getElementById
('<%=password.ClientID%>').value;
var password = '<%=ConfigurationManager.AppSettings
["UnlockPassword"].ToString() %>'
if (value == password)
{
document.getElementById
('<%=TxtBase.ClientID%>').readOnly = false;
}
else
{
document.getElementById
("error").value = "Incorrect Password Please Try Again";
}
}
</script>
函数onOk(){
var值=document.getElementById
('')价值;
var密码=“”
如果(值==密码)
{
document.getElementById
('').readOnly=false;
}
其他的
{
document.getElementById
(“错误”).value=“密码不正确,请重试”;
}
}
0x800a138f-JavaScript运行时错误:无法设置未定义或空引用的属性“value”
当我用ID=“error”设置标签以显示错误消息时,我遇到了一个错误。请帮助!!!!我甚至尝试了我正在使用的innerHtml(IE)。还有,为什么模式在点击else语句后会关闭?回发后,模式弹出窗口不能保持打开状态,因为模式是从客户端脚本打开的(我想是这样),但您可以从服务器调用另一个打开命令
这篇文章可能会有帮助:尝试使用html浏览器检查器检查标签元素,看看id是否相同,或者尝试在错误标签中不使用runat=server。@JorgeMejia此修复了我的问题文档。getElementById(“”)。innerHTML=“密码不正确,请重试”;但是模态一直关闭,我试过更新面板,但回发后仍然关闭,有什么线索我可以修复吗?