ASP.Net/Asp Control/Password Field

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Password field (asp:textbox textmode = password) (VB.net)

   <source lang="csharp">

<script runat="Server" language="VB"> Sub Page_Load()

   Dim strArrayDetails(2) As String
   Dim intLoop As Integer
   
   strArrayDetails(0) = text1.Text 
   strArrayDetails(1) = text2.Text
   strArrayDetails(2) = text3.Text
   
   Message1.text = CStr(strArrayDetails(0)) 
   Message2.text = CStr(strArrayDetails(1)) 
   Message3.text = CStr(strArrayDetails(2)) 

End Sub </script> <html>

 <head>
   <title>Text Box Example</title>
 </head>
 <body>
   <asp:label id="message1" runat="server" />
   
<asp:label id="message2" runat="server" />
<asp:label id="message3" runat="server" />
<form runat="server"> Please enter your name: <asp:textbox id="text1" runat="server" />

Please enter your address: <asp:textbox id="text2" runat="server" rows=5 textmode="multiline" />

Please enter your chosen password: <asp:textbox id="text3" runat="server" textmode="password" />

<input type="Submit"> </form> </body>

</html>

      </source>
   
  


Password Field Demo (C#)

   <source lang="csharp">

<%@ Page Language="c#" %> <script runat="server">

   void Page_Load()
   {
     if (Page.IsPostBack)
     {
         lblName.Text = "";
         lblAddress.Text = "";
         lblPassword.Text = "";
     }
   
     if (txtName.Text !="")
       lblName.Text = "You have entered the following name: " +  txtName.Text;
   
   
     if (txtAddress.Text !="")
       lblAddress.Text = "You have entered the following address: " + txtAddress.Text;
   
   
     if (txtPassword.Text !="")
       lblPassword.Text = "You have entered the following password: " + txtPassword.Text;
   
   
   }

</script> <html> <head>

   <title>Text Box Example</title>

</head> <body>

   <asp:Label id="lblName" runat="server"></asp:Label>
   
<asp:Label id="lblAddress" runat="server"></asp:Label>
<asp:Label id="lblPassword" runat="server"></asp:Label>
<form runat="server"> Please enter your name: <asp:textbox id="txtName" runat="server"></asp:textbox>

Please enter your address: <asp:textbox id="txtAddress" runat="server" textmode="multiline" rows="5"></asp:textbox>

Please enter your password: <asp:textbox id="txtPassword" runat="server" textmode="password"></asp:textbox>

<input type="submit" value="Submit Query" /> </form>

</body> </html>

      </source>
   
  


Using a TextBox Control for Passwords (VB.net)

   <source lang="csharp">

<%@ Page Language=VB Debug=true %> <script runat=server> Sub SubmitBtn_Click(Sender As Object, E As EventArgs)

   If txtName.Text = "Admin" and txtPassword.Text = "me" Then
       lblMessage.Text = "Access approved."
   Else
       lblMessage.Text = "Access denied"
   End If

End Sub </SCRIPT> <HTML> <HEAD> <TITLE>Using a TextBox Control for Passwords</TITLE> </HEAD> <form runat="server"> <asp:label

   id="lblMessage" 
   runat="server"

/>

Enter your Name:
<asp:textbox

   id="txtName" 
   columns="25"
   maxlength="30"
   backcolor="LightYellow"
   font-name="Comic Sans MS"
   font-size="9pt"
   tooltip="Contact your administrator for a new log-in"
   runat=server 

/>

Enter your Password:
<asp:textbox

   id="txtPassword" 
   textmode="Password"
   columns="25"
   maxlength="30"
   backcolor="LightYellow"
   font-name="Comic Sans MS"
   font-size="9pt"
   tooltip="Passwords a case-sensitve"
   runat=server 

/>

<asp:button

   id="butOK"
   text="OK"
   type="Submit"
   onclick="SubmitBtn_Click" 
   runat="server"

/> </Form> </BODY> </HTML>

      </source>