After installing Visual Studio, you are now ready to create first ASP.NET application with VB.NET. Follow these steps.
Step-1 Select the Appropriate Project Type and Template
Run Visual Studio and click the “New Project” option in this screen.
- Select option “Visual Basic” from the templates section
- Click on “Web” Option from the “Windows” list
- Ensure that you have “ASP.NET Web Application” selected in the detailed pane
- Change the name of the application
- If you want the web application to be stored in a specific directory click “Browse” Button and select the appropriate directory from the dialog box
- Click OK to select the template for this web application
From the dialog box appearing
- Select the “Empty” template
- Check the “Web Forms” checkbox
- Click OK to create solution for this web application
If a dialog box appears asking you to register with Azure, just click “Cancel” button and proceed to solution window.
Step-2 Create a Web Form
Now you need to add web form to create your first ASP.NET Web application that contains the controls to let the users interact.
- Right Click on “myFirstWebApp” Project
- Click on “Add”
- Click on “Web Form” to add a new Web Form in the project
Type the name you want to give to this form and click OK
By default you will be presented with the source of this web form. To design the from you have to select the Design option.
Step-3 Place Web Controls on the Web Form
From the Toolbox on left use 2 Labels, 2 Textboxes and one Button to create the interface. Also change the names of the controls you just placed (txtUserName, txtDepartment and btnLogin)
Step-4 Place Code in the btnLogin_Click event
To make the form interactive add the code in the .vb file of the Web Form. To do this in the design view double-click the btnLogin button to open the code window and type the following code in the click event.
MsgBox(" User " & txtUserName.Text & " of Department " & txtDepartment.Text & " is allowed to login")
Completed the task now See the output
From the toolbar section click on the option “Google Chrome” to run your newly created webform in your browser.
It will look like this. Enter the values in the textboxes and click the “Click to Login” Button.
This message will popup to display the names that you have entered in the text boxes.