什么叫“又让输一遍口令才行”?-----------------------------------------------------------
<script language=C# runat=server>
void test(object source, EventArgs value){ Response.Write(txtUpwd.Text);
}
</script>
<form runat=server>
<asp:TextBox  id="txtUpwd"  runat="server"  textMode="Password"></asp:TextBox>(**) 
<asp:RequiredFieldValidator  id="RequiredFieldValidator3"  runat="server"  ControlToValidate="txtUpwd"  ErrorMessage="请输入您的登录口令"></asp:RequiredFieldValidator> 
<input type="submit" id="Submit" OnServerClick="test" value="Submit" runat = server/>&nbsp;&nbsp;</form>
-----------------------------------------------------------

解决方案 »

  1.   

    感谢您使用微软产品。在您贴出的代码中,关于RequiredFieldValidator验证控件的使用不存在问题。问题可能出现在其他地方。下面有一段完整的示例代码关于RequiredFieldValidator验证控件的使用(来自于MSDN)。可供您测试RequiredFieldValidator验证控件的使用,并和您的代码进行比较。
    <%@ Page Language="VB" %>
    <html>
    <head>
       <script runat="server">
          Sub ValidateBtn_Click(sender As Object, e As EventArgs) 
             If Page.IsValid Then 
                lblOutput.Text = "Required field is filled!"
             Else 
                lblOutput.Text = "Required field is empty!"
             End If
          End Sub
       </script>
    </head>
    <body>
       <form runat="server">
          <h3>RequiredField Validator Example</h3>
          <table bgcolor="#eeeeee" cellpadding="10">
             <tr valign="top">
                <td colspan="3">
                   <asp:Label ID="lblOutput" 
                        Text="Fill in the required field below"
                        runat="server"/>
                   <br>
                </td>
             </tr>
             <tr>
                <td colspan="3">
                   <b>Credit Card Information</b>
                </td>
             </tr>
             <tr>
                <td align="right">
                   Card Number:
                </td>
                <td>
                   <asp:TextBox id="TextBox1" 
                        runat="server"/>
                </td>
                <td>
                   <asp:RequiredFieldValidator id="RequiredFieldValidator2"
                        ControlToValidate="TextBox1"
                        Display="Static"
                        ErrorMessage="*"
                        runat="server"/> 
                </td>
             </tr>
             <tr>
                <td></td>
                <td>
                   <asp:Button id="Button1" 
                        Text="Validate" 
                        OnClick="ValidateBtn_Click" 
                        runat="server"/>
                </td>
                <td></td>
             </tr>
          </table>
       </form>
    </body>
    </html>关于验证控件的更详细信息,请参考微软官方网站,并提供有相应的源代码:
    http://samples.gotdotnet.com/quickstart/aspplus/
     — 微软全球技术中心 VB支持中心本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
    为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
      

  2.   

    这个情况我也碰到过,我觉得,这很有可能是bug,这个情况有时候有有时候没,和ie浏览器版本有关,
      

  3.   

    感谢大家!我在这个空件后面有一个dropdownlist空件,他有onSelectedIndexChanged,并且我添加了代码,是不是因为这个原因,页面被刷新了,textbox类型为password的内容就没有了!??