Compartir a través de


HtmlInputSubmit Constructores

Definición

Inicializa una nueva instancia de la clase HtmlInputSubmit.

Sobrecargas

HtmlInputSubmit()

Inicializa una nueva instancia de la clase HtmlInputSubmit con los valores predeterminados.

HtmlInputSubmit(String)

Inicializa una nueva instancia de la clase HtmlInputSubmit utilizando el tipo especificado.

HtmlInputSubmit()

Inicializa una nueva instancia de la clase HtmlInputSubmit con los valores predeterminados.

public:
 HtmlInputSubmit();
public HtmlInputSubmit ();
Public Sub New ()

Ejemplos

En el ejemplo de código siguiente se muestra cómo agregar HtmlInputTextcontroles , HtmlInputPasswordy HtmlInputSubmit mediante programación a una página de Web Forms mediante constructores predeterminados para crear una pantalla de inicio de sesión sencilla.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  
  protected void page_load(object sender, EventArgs e)
  {
    if (IsPostBack)
    {
      // Add code to process the Login.
    }
  }

  protected void Page_Init(object sender, EventArgs e)
  {
    HtmlInputText userText = new HtmlInputText();
    userText.MaxLength = 20;
    Placeholder1.Controls.Add(userText);

    HtmlInputPassword passwordText = new HtmlInputPassword();
    passwordText.MaxLength = 20;
    Placeholder2.Controls.Add(passwordText);

    HtmlInputSubmit submitButton = new HtmlInputSubmit();
    submitButton.Value = "Submit";
    Placeholder3.Controls.Add(submitButton);
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <table cellpadding="2">
        <tr>
        <td>User Name
            <asp:placeholder
                runat="server"
                id="Placeholder1" />
        </td></tr>
        <tr>
        <td>Password
            <asp:placeholder
                runat="server"
                id="Placeholder2" />
        </td></tr>
        <tr><td><asp:placeholder
                runat="server"
                id="Placeholder3" />
        </td></tr>
      </table>
    </form>
  </body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    
    If (IsPostBack) Then
      ' Add code to process the Login.
    End If

  End Sub

  Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
    
    Dim userText As HtmlInputText = New HtmlInputText
    userText.MaxLength = 20
    Placeholder1.Controls.Add(userText)

    Dim passwordText As HtmlInputPassword = New HtmlInputPassword
    passwordText.MaxLength = 20
    Placeholder2.Controls.Add(passwordText)

    Dim submitButton As HtmlInputSubmit = New HtmlInputSubmit
    submitButton.Value = "Submit"
    Placeholder3.Controls.Add(submitButton)

  End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="Form1" runat="server">

      <table cellpadding="2">
        <tr>
        <td>User Name
            <asp:placeholder
                runat="server"
                id="Placeholder1" />
        </td></tr>
        <tr>
        <td>Password
            <asp:placeholder
                runat="server"
                id="Placeholder2" />
        </td></tr>
        <tr><td><asp:placeholder
                runat="server"
                id="Placeholder3" />
        </td></tr>
      </table>
    </form>
  </body>
</html>

Comentarios

En la tabla siguiente se muestra el valor de propiedad inicial de una instancia de HtmlInputSubmit.

Propiedad Valor
HtmlControl.TagName Cadena literal "submit".

Se aplica a

HtmlInputSubmit(String)

Inicializa una nueva instancia de la clase HtmlInputSubmit utilizando el tipo especificado.

public:
 HtmlInputSubmit(System::String ^ type);
public HtmlInputSubmit (string type);
new System.Web.UI.HtmlControls.HtmlInputSubmit : string -> System.Web.UI.HtmlControls.HtmlInputSubmit
Public Sub New (type As String)

Parámetros

type
String

Tipo de botón de entrada.

Ejemplos

En el ejemplo de código siguiente se muestra cómo agregar HtmlInputTextcontroles , HtmlInputPasswordy HtmlInputSubmit mediante programación a una página de Web Forms para crear una pantalla de inicio de sesión sencilla. En este ejemplo se muestra cómo se pueden pasar varios valores para el type parámetro , que invalida el tipo intrínseco del control HTML.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  protected void page_load(object sender, EventArgs e)
  {
    if (IsPostBack)
    {
      // Add code to process the Login.
    }

  }

  protected void Page_Init(object sender, EventArgs e)
  {

    // Pass "password" to make the HtmlInput control render a
    // password input type.
    HtmlInputPassword passwordText = new HtmlInputPassword();
    passwordText.MaxLength = 20;
    Placeholder1.Controls.Add(passwordText);

    // Pass "submit" to make the HtmlInput control render a
    // form submit button.
    HtmlInputSubmit submitButton = new HtmlInputSubmit("submit");
    submitButton.Value = "Log On to System";
    Placeholder2.Controls.Add(submitButton);

  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="Form1" runat="server">

      <table cellpadding="2">
        <tr>
        <td>Password
            <asp:placeholder
                runat="server"
                id="Placeholder1" />
        </td></tr>
        <tr><td><asp:placeholder
                runat="server"
                id="Placeholder2" />
        </td></tr>
      </table>
    </form>
  </body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    
    If (IsPostBack) Then
      ' Add code to process the Login.
    End If

  End Sub

  Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Pass "password" to make the HtmlInput control render a
    ' password input type.
    Dim passwordText As HtmlInputPassword = New HtmlInputPassword()
    passwordText.MaxLength = 20
    Placeholder1.Controls.Add(passwordText)

    ' Pass "submit" to make the HtmlInput control render a
    ' form submit button.
    Dim submitButton As HtmlInputSubmit = New HtmlInputSubmit("submit")
    submitButton.Value = "Log On to System"
    Placeholder2.Controls.Add(submitButton)
    
  End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="Form1" runat="server">

      <table cellpadding="2">
        <tr>
        <td>Password
            <asp:placeholder
                runat="server"
                id="Placeholder1" />
        </td></tr>
        <tr><td><asp:placeholder
                runat="server"
                id="Placeholder2" />
        </td></tr>
      </table>
    </form>
  </body>
</html>

Comentarios

En la tabla siguiente se muestra el valor de propiedad inicial de una instancia de HtmlInputSubmit.

Propiedad Valor
HtmlControl.TagName Valor del parámetro type.

Se aplica a