Creating an ASP.NET Application in .NET

Generation Code 128 Code Set C in .NET Creating an ASP.NET Application
Creating an ASP.NET Application
Decode Code-128 In Visual Studio .NET
Using Barcode Control SDK for Visual Studio .NET Control to generate, create, read, scan barcode image in .NET applications.
After you've set up the development environment for ASP.NET, you can create your first ASP.NET Web application. You can create an ASP.NET Web application in one of the following ways: Use a text editor: In this method, you can write the code in a text editor, such as Notepad, and save the code as an ASPX file. You can save the ASPX file in the directory C:\inetpub\wwwroot. Then, to display the output of the Web page in Internet Explorer, you simply need to type http://localhost/<filename>.aspx in the Address box. If the IIS server is installed on some other machine on the network, replace "localhost" with the name of the server. If you save the file in some other directory, you need to add the file to a virtual directory in the Default WebSite directory on the IIS server. You can also create your own virtual directory and add the file to it. Use the VS.NET IDE: In this method, you use the IDE of Visual Studio .NET to create a Web page in a WYSIWYG manner. Also, when you create a Web application, the application is automatically created on a Web server (IIS server). You do not need to create a separate virtual directory on the IIS server. From the preceding discussion, it is obvious that the development of ASP.NET Web applications is much more convenient and efficient in Visual Studio .NET. ASP.NET Web pages consist of HTML text and the code. The HTML text and the code can be separated in two different files. You can write the code in Visual Basic or C#. This separate file is called the code behind file. In this section, you'll create simple Web pages by using VB as well as C#. CrossFor more information on code behind files, refer to Reference 3. Before you start creating a Web page, you should be familiar with basic ASP.NET syntax. At the top of the page, you must specify an @ Page directive to define pagespecific attributes, such as language. The syntax is given as follows: <%@ Page attribute = value %>
Generate Code 128B In .NET Framework
Using Barcode maker for Visual Studio .NET Control to generate, create ANSI/AIM Code 128 image in VS .NET applications.
To specify the language as VB for any code output to be rendered on the page, use the following line of code: <%@ Page Language = "VB" %> This line indicates that any code in the block, <% %>, on the page is compiled by using VB. To render the output on your page, you can use the Response.Write() method. For example, to display the text "hello" on a page, use the following code: <% Response.Write("Hello") %> Note The syntax used in the block, <% %>, must correspond to the language specified in the @ Page directive. Otherwise, an error is generated when you display the page in a Web browser. You can use HTML tags in the argument passed to the Response.Write() method. For example, to display the text in bold, you use the following code: <% Response.Write("<B> Hello </B>") %> For dynamic processing of a page, such as the result of a user interaction, you need to write the code within the <Script> tag. The syntax of the <Script> tag is given as follows: <Script runat="server" [language=codelanguage]> code here </Script> In this syntax . . . runat="server" indicates that the code is executed at the server side. [language=codelanguage] indicates the language that is used. You can use VB, C#, or JScript .NET. The square brackets indicate that this attribute is optional. If you do not specify this attribute, the default language used is VB. After gaining an understanding of the basic ASP.NET page syntax, you can now create a simple ASP.NET Web application. In the following sections, you'll create a simple Web application by using VB and C#. To do so, you'll use the VS.NET IDE. Creating a Visual Basic Web Application You can create an ASP.NET application using Visual Basic by creating a Visual Basic Web Application project. To do so, complete the following steps: 1. Select File New Project. The New Project dialog box appears. 2. Select Visual Basic Projects from the Project Types pane. 3. Select ASP.NET Web Application from the Templates pane. The Name box contains a default name of the application. The Location box contains the name of a Web server where the application will be created. However, you can change the default name and location. In this case, the name of the sample application is SampleVB. The New Project dialog box now appears as shown in Figure 2-3.
Code-128 Decoder In .NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
Figure 2-3: The New Project dialog box 4. Click OK to complete the process. VS.NET displays the application, as shown in Figure 2-4. By default, the file WebForm1.aspx is selected and displayed. In addition to several other files, WebForm1.vb is also created. You can write the page logic in this file. This file is the code behind file.
Bar Code Drawer In .NET
Using Barcode generator for VS .NET Control to generate, create barcode image in VS .NET applications.
Figure 2-4: The VS.NET window with a new project The WebForm1.aspx file is displayed in Design mode by default. To view the file in HTML mode, click HTML at the bottom of the WebForm1.aspx file window. As you can see in HTML view, the language to be used on the page is VB. Any HTML text or code (in the <% %> block) within the <Body> </Body> block is rendered on the page when it is displayed in a Web browser. The default background color of a page is white. You can change the background color of a page by setting the bgcolor attribute of the <Body> element. When you set this attribute, you are prompted to pick the color, as shown in Figure 2-5.
Barcode Reader In VS .NET
Using Barcode decoder for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
Figure 2-5: Setting the bgcolor attribute When you select a color from the color palette, the corresponding color code is set as the value of the bgcolor attribute. A sample of such code is given as follows: <Body bgcolor="#ccccff"> Write the following code within the <Body> </Body> element to display the text "Hello World": <% Response.Write(" <Font Size=10> <Center> <B> Hello World </B> </Center> </Font>") %> After you complete writing the code for your application, you need to build your application so that you can execute it on a Web server. To build the project, choose Build Build. Tip You can also build a project by pressing Ctrl + Shift + B. When you build a project, the Web Form class file is compiled to a Dynamic Link Library (DLL) file along with other executable files in the project. The ASPX file is copied to the Web server without any compilation. You can change the ASPX file (only the visual elements of the page) without recompiling, because the ASPX file is not compiled. Later, when you run the page, the DLL and ASPX files are compiled into a new class file and then run. The output of the page that you developed is displayed in Figure 2-6.
Code 128 Creation In C#.NET
Using Barcode creator for .NET framework Control to generate, create Code128 image in .NET framework applications.
Figure 2-6: A sample output of the Web page Creating a C# Web Application In addition to Visual Basic, you can also use C# to create ASP.NET Web applications. To do so, you need to create a Visual C# Web application project as follows: 1. Select File New Project. The New Project dialog box appears. 2. Select Visual C# Projects from the Project Types pane. 3. Select Web Application from the Templates pane. The Name box contains a default name of the application. The Location box contains the name of a Web server where the application will be created. However, you can change the default name and location. In this case, the name of the sample application is SampleCSharp. 4. Click OK to complete the process. When you switch to HTML view of the WebForm1.aspx file, you'll notice that the language specified in the @ Page directive is C#. To create a Web page that displays
Make USS Code 128 In .NET Framework
Using Barcode encoder for ASP.NET Control to generate, create Code-128 image in ASP.NET applications.
"Hello World," you simply need to write the following code in the <Body> </Body> block of the page: <% Response.Write("<Font Size=10> <Center> <B> Hello World </B> </Center> </Font>"); %> Notice that the code in the <% %> block is terminated with a semicolon. This difference in syntax is due to the fact that the language for this page is C# and not VB. When you build the application and execute it, a Web page appears in the browser displaying the text "Hello World."
Print Code-128 In VB.NET
Using Barcode maker for VS .NET Control to generate, create Code 128 Code Set B image in Visual Studio .NET applications.
Generating Data Matrix 2d Barcode In .NET Framework
Using Barcode creator for Visual Studio .NET Control to generate, create Data Matrix 2d barcode image in Visual Studio .NET applications.
Generate Code 128C In VS .NET
Using Barcode maker for Visual Studio .NET Control to generate, create Code 128C image in Visual Studio .NET applications.
Barcode Generator In C#.NET
Using Barcode printer for .NET framework Control to generate, create barcode image in .NET framework applications.
Generating EAN / UCC - 13 In Java
Using Barcode maker for Java Control to generate, create EAN13 image in Java applications.
Generating Barcode In C#
Using Barcode maker for .NET framework Control to generate, create bar code image in .NET framework applications.
Bar Code Creation In VS .NET
Using Barcode encoder for ASP.NET Control to generate, create bar code image in ASP.NET applications.