Create TextBox, Button, LinkButton, HyperLink & ImageButton controls

Create a simple website and demonstrate how to use control like TextBox, Button, LinkButton, HyperLink and ImageButton.

Answer:

Introduction:
ASP.NET has many web controls to develop a good GUI. These controls are the objects on ASP.NET web pages that run when the page is requested. Many web controls are similar to the HTML elements like as textbox, button, hyperlink etc.

Here, is a simple example to demonstrate the use of different controls like TextBox, Button, LinkButton, HyperLink and ImageButton with asp tag.

// ASP code to practically employ different controls

<!DOCTYPE html>
   <head>
      <title>Sample Page</title>
   </head>
   <body>
        <form id="f1" method="post" runat="server">
             <table>
                <h3>Personal Info</h3>
                <tr>
                   <td>Name:</td><td> <asp:textbox id="txt1" runat="server" ></asp:textbox></td>
                </tr>
                <tr>
                    <td>Father Name:</td><td> <asp:textbox id="txt2" runat="server" ></asp:textbox></td>
                </tr>
                <tr>
                    <td>Mother Name:</td><td> <asp:textbox id="txt3" runat="server"></asp:textbox></td>
                </tr>
                <tr>
                    <td>Gender: </td>
                    <td><asp:CheckBox ID="check1" runat="server" Text="M"></asp:CheckBox><asp:CheckBox ID="CheckBox1" runat="server" Text="F"></asp:CheckBox></td>
                </tr>
               <tr>
                    <td><asp:Button ID="btn1" runat="server" Text="Submit"></asp:Button></td>
                    <td><asp:Button ID="btn2" runat="server" Text="Reset"></asp:Button></td>
                </tr>
                <tr>
                    <td><asp:HyperLink ID="link1" runat="server"  NavigateUrl="#" text="click here for more.."></asp:HyperLink></td>
                </tr>
                <tr>
                    <td><asp:ImageButton ID="imgbtn" runat="server" ImageUrl="images/new/home2-icon.png" /> Home</td>
                </tr>
            </table>
        </form>
    </body>
</html>


Output:

The output is simple form which has textbox, checkbox, button, hyperlink and image button.

asp.net server controls