document.all("labelID").innerTextordocument.all("labelID").innerHTML

解决方案 »

  1.   

    <asp:label ID="lblTempUserName" runat="server"    Visible="false"></asp:label><a href="javascript:Validate()">管理javascript如下:
     function Validate()
     {
       if (document.all("lblTempUserName").innerText=="")
      {
                                      window.alert("hello");
    }
     }报网页有错?
      

  2.   

    you set Visible="false", the label is never output to the client side, try Visible="true"
      

  3.   

    我的本意是将成功登陆后的用户名保存在label中,然后在javascrpt中判断label控件的内容,但是设置为true后,界面上就出现了用户名,这违背了设计的原意。
    有什么更好的方法吗?思归。
      

  4.   

    make it invisible, :-):<asp:label ID="lblTempUserName" runat="server"   Style="display:none" Visible="true"></asp:label>
      

  5.   

    思归,可以了。
    但还有一问:
    为什么通过 (document.forms["Default"].elements["lblTempUserName"])不能获得其值?但是(document.forms["Default"].elements["txtUser"].value却能获得textbox控件的值?
      

  6.   

    form.elements..... can contain any combination of the button, input, select, and textArea objects. For compatibility with existing Web content, however, input type=image objects are excluded. see
    http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/elements.asp?frame=true