Javascript变量'的" Value "属性不会出现在智能感知上,而是显示的值

Javascript variable's “Value” property does not come up on the Intellisense Insted show Value of

本文关键字:感知 智能 显示 变量 Value Javascript 属性      更新时间:2023-09-26

你好,我是java脚本的新手。

我想在我的ASP.net网页中实现这个功能。我在项目中使用了一个单独的。js文件,并从asp.net网页的头部分调用它。

这是我要实现的函数。

function userValid() 
{
    var Name;
    Name = document.getElementById("txtName").value;
    if (Name == '') 
    {
       alert("Please Enter Name");
      return false;
    }
    return true;
}

但是问题是在输入document.getElementById("txtName")之后。(它只显示valueOf()而不显示value。

文本框代码

<asp:TextBox ID="txtName" runat="server" Width="250" AutoComplete="off"></asp:TextBox>

我在这里错过了什么?

不管它显示什么,它对visual studio中的java脚本没有很大的帮助。所以你做的是对的。

你也应该使用ClientId而不是直接的"txtName"

 Name = document.getElementById("<%= txtName.ClientID %>").value;

更多关于ClientId的细节在这里
http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid (v = vs.110) . aspx

visual studio中使用智能的更多参考
http://msdn.microsoft.com/en-us/library/bb385682.aspx