Follow the below simple
Example to know how to work with the web forms.
Drag and Drop the Two Labels, Textbox, and Button controls onto the form and arrange the controls as shown in the below figure.
OR
Write the following code in the
Source snippet.
[html]<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Sample.aspx.vb" Inherits="ControlsExample.Sample" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<table width="100%">
<tr>
<td style="text-align: right">
<asp:Label ID="lblName" runat="server" style="text-align: right; font-weight: 700;" Text="Enter Name:"></asp:Label></td>
<td><asp:TextBox ID="txtName" runat="server" BorderColor="#000066" BorderStyle="Solid"></asp:TextBox></td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" style="font-weight: 700"/>
</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td>
<asp:Label ID="LblMessage" runat="server" style="font-weight: 700"></asp:Label>
</td>
<td></td>
</tr>
</table>
</form>
</body>
</html>
[/html]
Double click on the
Submit Button. Then the following code will be generated in the
Sample.aspx.vb.
[vbnet]
Public Class Sample
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
End Sub
End Class
[/vbnet]
Write the following code in the
btnSubmit_Click event as shown in the below code.
[vbnet]
Public Class Sample
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
LblMessage.Text = "Entered Name is " + txtName.Text
End Sub
End Class
[/vbnet]
Output:
Click on the
Google Crome which appeared on the above in the window or press
f5 to run the application.Then, Output will be generated in the browser and then Enter the Name. Then, the output will be appeared as shown in the below figure.