Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
Thousands of businesses have used Microsoft ASP.NET to build professional, dynamic websites. In this course, web developer David Gassner demonstrates the tools needed to build and deploy a dynamic site using ASP.NET 3.5 or 4.5. Covering everything from installing and configuring Visual Web Developer 2008 or Visual Studio Express 2012 for Web and SQL Server Express to creating web form pages, this course is designed to give beginning and intermediate developers hands-on experience.
The two primary languages that are used in ASP.NET, Visual Basic.net and C# are syntactically very different from each other. But they both use the underlying .NET Class Library, the set of components that enable your web applications. When you are first learning a programming language, it's useful to have a testing environment. A simple application to which you can add arbitrary code, and to displays the result of running that code. In this chapter, I demonstrate how to use critical aspects of the two programming languages. This is what the web form page looks like. It has a heading, a textbox and two buttons labeled Run Code and Clear Console. Let's take a look at the source code.
I'll open the code up to full screen by pressing the keyboard shortcut, Alt+Shift+Enter. Notice that within the form, there are two panels. A panel is a server-side control that translates as a div tag. So you can easily force content to be stacked one on top of another. With in the first panel, there is the textbox with a text mode attribute of MultiLine. This allowed the textbox control to display multiple lines of text. And then within the second panel there are two buttons with ids of runButton and clearButton, and they each have an onClick event handler that runs a function.
So each time the output function is called, it will add the line to the textbox and then go down to the next line. In the current version of the C# page, the runButton_Click function calls this function output, and passes in a value of Hello world, and then when the user clicks the clearButton the text property of the textbox is set to a blank string. So that's all the code in our testing environment. Let's give it a try. I'll run the application without debugging. I'll click the Run Code button a few times. And you'll see that each time I click the button, I'm appending a value to the existing textbox controls text property, and then when I click Clear Console that results in clearing the textbox.
Now I'm going to be using this page as the base for all of my exercises. So before I leave it, I'm just going to go back to the runButton_click function and I'm going to remove the call to the output function. And this will be the base file that I copy for each exercise. Now, I'll close that file and I'll press Alt+Shift+Enter again so I can see my panels, and I'll open up the Visual Basic version. Let's take a look at this one in full screen. The Markup code in the Visual Basic version is exactly the same. It has the same two panels. The textbox and the two buttons. The Ids are the same, and the click events are the same. But notice that the syntax of the scripting code is a little bit different.
In Visual Basic, a function that doesn't return a value is called a sub or a subroutine. The subroutine output is marked with protected sub at the beginning and the end sub at the end. The code within the function is almost exactly the same as the C# version. The exception is that there is no semicolon at the end of the line. I'm still however using Environment.NewLine to represent a character return line feed combination. The runButton_Click event still calls the output function, passes in a text value of Hello world and the clearButton_Click event still sets the text property to a blank string. I'll run this version of the page, without debugging. I'll test it by clicking the Run Code button a few times, and I'll clear the console. Then I'll close the page as with the C# version, I'll remove the call to output from the click event, so that I can use this as the base page for all of the other exercises in this chapter.
So if you don't have access to the Exercise Files, create your version of this page, using the code that I've displayed on the screen, and then for each exercise make a copy of that page, so that you can go through that particular exercise.
Find answers to the most frequently asked questions about ASP.NET Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.