ASP.Net/Asp Control/Password Field

Материал из .Net Framework эксперт
Версия от 11:53, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

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

<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" />
    <br /> 
    <asp:label id="message2" runat="server" /> 
    <br />
    <asp:label id="message3" runat="server" />
    <br />
    <form runat="server">
      Please enter your name:
      <asp:textbox id="text1" runat="server" />
      <br /><br />
      Please enter your address:
      <asp:textbox id="text2" runat="server" rows=5 textmode="multiline" />
      <br /><br />
      Please enter your chosen password:
      <asp:textbox id="text3" runat="server" textmode="password" />
      <br /><br /> 
      <input type="Submit">
    </form>
  </body>
</html>



Password Field Demo (C#)

<%@ 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>
    <br />
    <asp:Label id="lblAddress" runat="server"></asp:Label>
    <br />
    <asp:Label id="lblPassword" runat="server"></asp:Label>
    <br />
    <form runat="server">
        Please enter your name: 
        <asp:textbox id="txtName" runat="server"></asp:textbox>
        <br />
        <br />
        Please enter your address: 
        <asp:textbox id="txtAddress" runat="server" textmode="multiline" rows="5"></asp:textbox>
        <br />
        <br />
        Please enter your password: 
        <asp:textbox id="txtPassword" runat="server" textmode="password"></asp:textbox>
        <br />
        <br />
        <input type="submit" value="Submit Query" />
    </form>
</body>
</html>



Using a TextBox Control for Passwords (VB.net)

<%@ 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"
/>
<BR><BR>
Enter your Name:<BR>
<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 
/>
<BR><BR>
Enter your Password:<BR>
<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 
/>
<BR><BR>
<asp:button 
    id="butOK"
    text="OK"
    type="Submit"
    onclick="SubmitBtn_Click" 
    runat="server"
/>
</Form>
</BODY>
</HTML>