Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Buttons
Message
 
À
05/03/2002 11:48:35
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
00628502
Message ID:
00628530
Vues:
26
>Hello,
>
> I have an ASPX page that has a button and a text box. When the user enters information in the textbox I want them to be able to hit enter and the code for the button runs. Is this possible? If so, how do I do it?

Just put the code in the Button Click event. The code will run on the server when the page does a postback.

Web forms event model
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconwebformseventmodel.asp

See Quickstart example 3
<html>

    <script language="VB" runat="server">

        Sub EnterBtn_Click(Sender As Object, E As EventArgs)
            Message.Text = "Hi " & Name.Text & ", welcome to ASP.NET!"
        End Sub

    </script>

    <body>

       <h3><font face="Verdana">Handling Control Action Events</font></h3>

       <p>

       This sample demonstrates how to access a <asp:textbox server control within the "Click" 
       event of a <asp:button, and use its content to modify the text of a <asp:label.

       <p>

       <hr>

       <form action="controls3.aspx" runat=server>

          <font face="Verdana"> 

             Please enter your name: <asp:textbox id="Name" runat=server/> 
                                     <asp:button text="Enter" Onclick="EnterBtn_Click" runat=server/>

             <p>

             <asp:label id="Message"  runat=server/>

          </font>

       </form>

    </body>

</html>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform