|
Web Forms
Working with Forms
Well, now let's start working with ASP.NET. This site works with ASP.NET using VB.
To open a new ASP.NET Web application, open Visual Studio .NET and from the main menu
select File->New Project. From the New Project dialogue
click on Visual Basic Projects under project types and ASP.NET Web Application under
templates. It looks like the image below.
The page that opens looks like the image below.
The page is opened in grid layout mode. To change it to flow layout mode you
need to set the pageLayout property to flow layout
in the properties window. To view the properties window for the page select
View-> Properties Window from main menu or hold F4 key
on your keyboard.
Your First ASP.NET Program
On to the Web Form drag a Label and a Button from the toolbox. Double-click the button
to open it's event. Write the following code in the click event of the button.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
Label1.Text = "Welcome to ASP.NET"
End Sub
|
The above said code displays "Welcome to ASP.NET" on a label web server control. You
can run the sample at the bottom of this page. As mentioned before, working
with ASP.NET using VB is like working with VB itself. Everything you do here
is what you do with a VB Windows application.
Initializing a Web Form
We use the Page_Load event to initialize a Web Form. The
code you place in this event is executed first and all the code you write performs
some function on the page when it is loaded. The Page_Load event looks like this
in code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles MyBase.Load
'Put user code to initialize the page here
End Sub
|
Continue >>
Live Code Demo
Label
|