Showing posts with label Customizing Toolbars in vs. Show all posts
Showing posts with label Customizing Toolbars in vs. Show all posts

Tuesday, December 27, 2016

Customizing Toolbars in vs

          I n today tutorial we will Customizing Toolbars in vs and You can customize toolbars in three ways: you can show or hide the built-in toolbars, you can add and remove buttons on existing toolbars, and you can create your own toolbars with buttons you often use.Enabling and Disabling Toolbars

Enabling and Disabling Toolbars

                  You disable and enable existing toolbars by right-clicking any existing toolbar or the menu bar and then selecting the appropriate item from the list. Once the toolbar is displayed, you can use its drag grip at its left to drag it to a new location within the Toolbar area.

Editing Existing Toolbars

                  If you feel that an existing toolbar is missing an important button or that it contains buttons you rarely use, you can customize the buttons on the toolbar. To do this, right-cliack any toolbar or the menu bar, choose Customize, switch to the Commands tab, and select the toolbar you want to modify from the Toolbar drop-down. With the command buttons at the right, you can add new and remove existing commands, or change their order.

Creating Your Own Toolbars

              Creating your own toolbar is useful if you want to group some functions that you frequently use. To create a new toolbar, open the Customize window as explained in the preceding section. Click the New button and type a name for the toolbar. Then switch to the Commands tab and modify your toolbar as you would do with existing toolbars.

 

in simple words or steps:



You can change the layout, position, and content of toolbars in the integrated development environment (IDE). You can also add buttons to toolbars and change the assigned icon for any button.
1.     Create new toolbars
2.     To create a new toolbar
3.     On the Tools menu, choose Customize.
4.     In the Customize dialog box, select the Toolbars tab.
5.     Choose New.
6.     In the New Toolbar dialog box, type a name for the toolbar.
7.     Choose OK.
To add a command button to a toolbar
1.     On the Toolsmenu, choose Customize.
2.     In the Customize dialog box, select the Commands tab.
3.     Click Rearrange Commands.
4.     Under Choose a menu or toolbar to rearrange, select Toolbar and then choose the correct toolbar from the drop-down list.
5.     Click Add.
6.     In the Add Command dialog box, select category name from the Categories list and then choose an appropriate command from the Commands list.
7.     Click OK.
8.     Click Close and then click Close again.
To group commands on a toolbar
1.     On the Toolsmenu, choose Customize.
2.     In the Customize dialog box, select the Commands tab.
3.     Click Rearrange Commands.
4.     Under Choose a menu or toolbar to rearrange, select Toolbar and then choose the correct toolbar from the drop-down list.
5.     Select the command you want to begin a visual group.
6.     Click the Modify Selection drop-down list and select Begin a Group.
7.     A separator bar appears on the list of commands, above the selected command.
8.     Click OK, then click Close, and then click Close again.
9.     The command appears on the toolbar with a separator before it.
10.   Customize toolbar button images
11.   The IDE provides forty-two button images that can be exchanged with the default toolbar icons.
12.   To change toolbar button images
13.   On the Tools menu, choose Customize.
14.   In the Customize dialog box, select the Commands tab.
15.   Click Rearrange Commands.
16.   Under Choose a menu or toolbar to rearrange, select Toolbar and then choose the correct toolbar from the drop-down list.
17.   Select the toolbar command of which you intend to change the image.
18.   Choose Modify Selection.
Choose Change Button Image and select an alternative on the cascading menu.
 

Customizing Keyboard Shortcuts in vs 2013

Monday, December 26, 2016

A Tour of the IDE VS studio


A Tour of the IDE of vs studio 2013


Visual Studio tpur of the IDE  is by far the most extensive and feature-rich integrated development environment (IDE) for building ASP.NET web pages. The abbreviation IDE refers to the way all the separate tools you need to build complex web applications are integrated in a single environment. Instead of writing code in a text editor, compiling code at the command line, writing HTML and CSS in a separate application, and managing your database in yet another, VS enables you to perform all of these tasks, and more, from the same environment. Besides the efficiency this brings because you don’t have to constantly switch tools, this also makes it much easier to learn new areas of VS, because many of the built-in tools work in the same way.
The Main Development Area in vs studio

To get familiar with the many tools that are packed in VS’s interface, take a look at Figure 1-9. It shows the same screen you got after you created your first website in VS, but now it highlights some of the most important screen elements. If you are already familiar with a previous version of Visual Studio, you could skip this section and pick up again at the next Try It Out exercise later in this section.











NOTE:

If you have a previous version of Visual Studio installed, your screen may look different, because
Visual Studio is able to import settings from older versions.
Choosing Your Development Profilein vs studio
Because VSEW targets people new to ASP.NET development as well as seasoned web developers, you can choose among different developer profiles: Basic Settings, Code Only, and Expert Settings. In Basic Settings mode, many menu items you don’t frequently use have been hidden or are place in their own submenu. The Code Only profile is great for pure coding sessions where you’re not interested in many of the design features of VSEW, such as Design View or the Toolbox. Expert Settings mode gives you access to the full functionality of VSEW. You can switch between settings using the Tools ➪ Settings menu. This book assumes you are using Expert Settings mode right from the beginning. You may not need all the features you see right from the start, but you sure will use most of them by the end of the book. Because the menu items change location depending on the profile you choose, I decided to use Expert Settings mode right away, to make it easier to refer to a specific menu item or feature. You don’t have this option in the commercial versions of Visual Studio — Expert Settings is on by default.

The Main Menu in vs studio

At the top of the application, right below the Windows title bar, you see the main menu. This menu bar contains familiar items you find in many other Windows applications, like the File, Edit, and Help menus as well as menus specific to VS, such as the Website and Debug menus. The menu changes dynamically depending on the task you’re working on, so you’ll see menu items appear and disappear as you work your way through the application. You can use the Help ➪ Set Help Preference menu to configure online and offline help. Offline help needs to be installed first, and online help requires a connection to the Internet. On the far right you see a Sign In link that lets

you sign in with your Microsoft account to enable synchronization of VS settings between different machines.
The Notification Window in vs studio

In the application’s title bar to the left of the Windows Close, Minimize, and Maximize buttons, you see an icon with a little flag. Clicking the flag icon brings up the Notification window in which Visual Studio provides you with important information. For example, it will show available downloads for new documentation content, expired licenses, product updates, and more.

Depending on the importance of the available notifications, the color of the flag icon in the title bar changes color. The Notifications window is also accessible from the View menu. If you installed the RTM version of Visual Studio, you’re likely to see a few updates which you can safely install now.
The Toolbar Area in vs studio

Right below the menu, you see the toolbar area, which is capable of showing different toolbars that give you quick access to the most common functions in VS. In Figure 1-9 abow, only two of the toolbars are enabled, but VS comes with many other toolbars that you can use in specific task-oriented scenarios. Some toolbars appear automatically when you’re working on a task that requires a particular toolbar’s presence, but you can also enable and disable toolbars to your liking. To enable or disable a toolbar, right-click an existing toolbar or the menu bar and choose the toolbar from the menu that appears.

The Toolbox in vs studio

On the left of the main screen, tucked away at the border of VS, you see the tab for the Toolbox. If you click the tab, the Toolbox folds out, giving you a chance to see what it contains. If you click the little pin icon in the upper-right corner of the Toolbox (or any of the other panels that have this pin icon), it gets pinned to the IDE so it remains open.


Just as with the menu bar and the toolbars, the Toolbox automatically updates itself to show content that is relevant to the task you’re working on. When you’re editing a standard ASPX page, the Toolbox shows the many controls you have available for your page. You can simply drag an item


from the Toolbox and drop it on a location of your page where you want it to appear. These controls are discussed in great detail in later section. Note that each Toolbox category also contains a Pointer icon. This isn’t a control itself, though. In other designers for Visual Studio (such as Win Forms) this icon is used to get out of control drawing mode, but it has little use in ASP.NET. The Toolbox contains multiple categories that you can expand and collapse as you see fit to make it easier to find the right tool. You can also reorder the items in the list, add and remove items from the Toolbox, and even add your own tools to it. Customizing the IDE is discussed later in this section. If the Toolbox is not visible on-screen, press Ctrl+Alt+X to open it or choose View ➪ Toolbox, provided you have chosen the Expert Settings option in the Tools ➪ Settings menu.

The Solution Explorer in vs studio

At the right of the screen, you see the Solution Explorer. The Solution Explorer is an important window because it gives you an overview of the files that comprise your website. Instead of placing all your files in one big folder, the Solution Explorer enables you to store files in separate folders,creating a logical and organized site structure. You can use the Solution Explorer to add new files to your site, move existing files around using drag and drop or cut and paste, rename files and delete them from the project, and more. Much of the functionality of the Solution Explorer is hidden behind its right-click menu, which changes depending on the item you right-click.
At the top of the Solution Explorer, you see a small toolbar that gives you quick access to some functionality related to your website, including refreshing the Solution Explorer window, an option to nest related files, and a button that enables you to configure your website. Most of this functionality is discussed later. You can access the Solution Explorer by choosing View ➪ Solution Explorer from the main menu or by pressing Ctrl+Alt+L.

The Server Explorer in vs studio

This window, hidden behind the Solution Explorer in Figure 1-9, enables you to work with your databases and other services. You can access the Server Explorer by choosing View ➪ Server Explorer or by pressing Ctrl+Alt+S. The Server Explorer is discussed in more detail in the section about databases, I mean later in database section.

The Team Explorer in vs studio


This window, hidden behind the Solution Explorer in Figure 1-9, is used to connect to and work with Team Foundation Server (TFS), Microsoft’s Application Lifecycle Management tool used for source control, work item tracking, and more. For more details, and a free account for the hosted version of TFS, check out http://tfs.visualstudio.com. TFS and the Team Explorer are not discussed in this articles.

The Properties Grid in vs studio

With the Properties Grid, you can view and edit the properties of many items in Visual Studio, including files in the Solution Explorer, controls on a web page, properties of the page itself, and much more. The window constantly updates itself to reflect the selected item. You can quickly open the Properties Grid by pressing F4. You can use this same shortcut to force the Properties Grid to show the details of a selected item.

The Document Window in vs studio

The Document Window is the main area in the middle of the application. This is where most of the action takes place. You can use the Document Window to work with many different document formats, including ASPX and HTML files, CSS and JavaScript files, code files for VB and C#, XML and text files, and even images. In addition, you can use the same window to manage databases, create copies of your site, view the pages in your site in the built-in mini-browser, and much more. The Document Window is a tabbed window by default, which means it can host multiple documents, each one distinguished by a tab with the filename at the top of the window. The rightclick menu of each tab contains some useful shortcuts for working with the file, including saving and closing it and opening the file’s parent folder in File Explorer. To switch between documents, you can press Ctrl+Tab, click the tab for the document you want to see, or click the down arrow in the upper-right corner of the Document Window, next to the Solution Explorer, shown in Figure 1-9. Clicking the down arrow reveals a list of open documents so you can easily select one. Another way to switch documents is to press Ctrl+Tab and then hold down the Ctrl key. On the window that pops ups, you can select a document you want to work with in the right-hand column. You can then use the cursor keys to move up and down in the list with open documents. This makes it super easy to select the correct file. On the same dialog box, you see a list with all active tool windows. Clicking one of the windows in the list shows it on-screen, moving it in front of other windows if necessary. To get a quick preview of a document without opening it for editing, click the file you want to see in the Solution Explorer once. You can see that a file is in preview mode by its tab, which is docked to the right of the row with tabs as opposed to the left for open files.
At the bottom of the Document Window in Figure 1-9, you see three buttons called Design, Split, and Source. These buttons appear automatically when you’re working with a file that contains markup, such as ASPX pages. They enable you to open the Design View of a page (giving you an idea of how the page will look in the browser), its Markup View (the HTML and other markup),or both at the same time. How this works is explained in more detail in later section, but for now it’s important to realize you can switch among Markup, Split, and Design View by clicking one of the three buttons. The Markup View is also often called the Source View or Code View window. However, to avoid confusion with the code editor that is used to edit Code Behind files, this course uses the term Markup View exclusively.

The Start Page in vs studio

Whenever you start up VS, the Start Page is loaded in the Document Window. With the Start Page, you can quickly create new and open existing websites and other projects. The Start Page also provides a number of links to related news and information about web development. To pin your favorite projects to the Start Page, click the pin icon to the left of the project name in the list with recent projects. To unpin a project, right-click it and choose Remove from List. To reopen the Start Page, choose View ➪ Start Page. To get a feel for how you can use all these windows, the following Try It Out shows you how to build a simple web page that contains a few ASP.NET Server Controls.

This Try It Out exercise guides you through creating a new website with a single page that contains a number of ASP.NET Server Controls. You see how to use windows like the Document Window and the Solution Explorer, and how to use the Toolbox and the Properties Grid to add ASP.NET Server

Controls to the page and change their looks.

1. Start VSEW or Visual Studio 2013.

2. If you’re using the Express edition, choose Tools ➪ Settings and choose Expert Settings to turn on the developer profile that gives you access to the full feature set of VSEW.

3. On the File menu choose New Web Site. Depending on configuration, you may have to choose File ➪ New ➪ Web Site instead. This triggers the New Web Site dialog box.

4. In this dialog box, make sure that ASP.NET Empty Web Site is selected and not the ASP.NET Web Forms Site item that you used in a previous exercise. Ensure that File System is chosen in the Web Location drop-down list. It doesn’t matter if you choose Visual Basic or C# for this exercise. Click OK to create the new site.

5. Next, right-click the new website in the Solution Explorer. Make sure you click the website (labeled WebSite2) and not the parent Solution element. It’s the highlighted element in Figure 1-5. From the context menu that appears, choose Add ➪ Add New Item.

6. In the new window that appears, click Web Form and type ControlsDemo as the name. The ASPX extension is added for you automatically when you click the Add button. You can leave the other settings in the dialog box at their default settings. The page should open in Markup View, showing you the default HTML, like the <html>, <head>, <title>, and <body> elements that VS adds there for you automatically when you create a new page.


7. Switch the page to Design View by clicking the Design

button at the bottom of the Document Window.

8. If the Toolbox isn’t open yet, press Ctrl+Alt+X to open it or click the




Toolbox tab to show it and then click the pin icon in the top-right corner to make the Toolbox visible at all times. Drag a TextBox and a Button from the Standard category of the Toolbox into the dashed area in the Design View of the page. You should end up with a Design View that looks similar to Figure 1-10.


9. Right-click the button in Design View and choose

Properties. In the Properties Grid, locate the Text property



under the Appearance category (shown in Figure 1-11) and change it from Button to Submit Information. As soon as you press Tab or click somewhere outside the Properties Grid, the Design View of the page is updated and shows.

the new text on the button.


10. Press Ctrl+F5 to open the page in your default browser.

Note that it’s not necessary to explicitly save the changes
to your page (although it’s a good idea to do this often anyway using the shortcut Ctrl+S). As soon as you press Ctrl+F5 to run the page, VS saves all changes to open documents automatically.

11. Type some text in the text box and click the button. Note that after the page has reloaded, the text is still displayed in the text box. Other than that, not much has happened because you didn’t write any code for the button yet.

How It Works


When you dragged the Button and the TextBox from the Toolbox on the page in Design View, VS added the corresponding code for you in Markup View automatically. Similarly, when you changed the Text property of the button in the Properties Grid, VS automatically updated the markup for the control in Markup View. Instead of using the Properties Grid, you could also have typed the text directly between the quotation marks of the Text property in Markup View. After changing the Text property, your page should contain this code in Markup View:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1" runat="server" Text="Submit Information" />
When you press Ctrl+F5 to view the page in the browser, the web server receives the request, the page is processed by the ASP.NET run time, and the resulting HTML for the page is sent to the browser. After you type in some text and click the button, the same process is more or less repeated: The web server receives the request, the page is processed, and the result gets sent back to the browser. When you click the button, you cause a postback to occur, where any information contained in the page — such as the text you typed in the text box — is sent back to the server. ASP.NET reacts to the postback by rendering the page again. However, this time it prepopulates controls, like the TextBox, with the values that were sent to the page.
Take a look at the resulting HTML for the page after the postback, using the browser’s View Source command (rerun the page from VS by pressing Ctrl+F5 if you already closed it). You should see code similar to this:
<input name="TextBox1" type="text" value="Hello World" id="TextBox1" /><input type="submit" name="Button1" value="Submit Information" id="Button1" />Just as with the earlier example, you can see that the resulting HTML is substantially different from the original ASPX markup.Postbacks are an important concept in ASP.NET, and you see more about them in other section.

VSEW hosts many more windows and tool panels than those you have seen so far. The next section briefly touches upon some of the windows you’ll most frequently use when building pages. All of the windows mentioned are accessible from the main View menu in VS or VSEW if you’re using the Expert Settings mode. Informational Windows In addition to the windows that are visible by default when you start VS, many more windows are available. You see most of them in action in the remainder of this book, but some are worth

highlighting now. You access all windows that are discussed next from the main View menu.
The Error List The Error List gives you a list of the things that are currently somehow broken your site, including incorrect markup in your ASPX or HTML files and programming errors in VB or C# files. This window can even show you errors in XML and CSS files. The Error List shows its messages in three categories — Errors, Warnings, and Messages — that signify the severity of the problem. Figure 1-12 shows the Error List for a page that has some problems with its CSS and XHTML.



A Tour of the IDE VS studio


Figure 1.12

The Output Window

When you try to build your site using the Build menu, the Output window tells you whether or not the build succeeded. If the build failed, for example because you have a programming error, it tells you why the build failed. In the commercial versions of Visual Studio, the Output window is used for other information as well, including the status of external plug-in programs. Building — or compiling — websites is discussed later in this book, including in Chapter 19, which deals with deployment of your website.
The Find Results Window

The Find and Replace features of VS are invaluable tools when it comes to managing the content of your site. You will often need to replace some text in the current document or even in the entire site. Find in Files (Ctrl+Shift+F) and Replace in Files (Ctrl+Shift+H) both output their results in the Find Results window, as shown in Figure 1-13.






Because having several informational windows open at the same time may take up precious screen space, it’s often a good idea to dock them. This way, only one of them is visible at a time, while you still have quick access to the others. You learn how to customize the IDE, including the docking of windows, next.
NEXT:Creating Your First ASP.NET Web Page

downloading Visual Studio

                            In today post we will provide you how to downloading Visual Studio You can get the free Visual Studio Express 2013 for Web from the Microsoft site at www.microsoft.com/express/. On the Express homepage, follow the Downloads link until you reach the page that offers the downloads for the Express products, including VSEW. From this page, you can download VSEW as a Web Install, where you download only the installer, while the remaining files are downloaded during the installation process. Make sure you choose Visual Studio Express 2013 for Web from the page, and not one of the other free Express products or one of the older editions of Visual Studio. Don’t be fooled by the file size of the Web Install download, which is just a few megabytes. The file you download is just the installer that downloads the required files over the Internet. The total download depends on your current system and will be somewhere between 500MB and 1GB. If you want to try out the full version of Visual Studio 2013, which also contains the web components, you can sign up for a free trial on the Microsoft site at http://msdn.microsoft.com/ vstudio. You can choose to download an ISO image that you’ll need to burn on a DVD or choose to download the Web Installer. Finally, you can download VSEW with the Microsoft Web Platform Installer (WPI) application available for download at www.microsoft.com/web/platform and at www.asp.net/downloads/.Besides VSEW, this tool also gives you easy access to many other web development–related tools and programs. The WPI is an excellent tool to get a whole bunch of web development–related programs and tools in one fell swoop. I often use it to get up and running quickly on a clean development machine.

Installing Visual Studio Express for Web (VSE W)

Installing VSEW is a straightforward, although somewhat lengthy, process. Depending on your installation method, your computer, and your Internet connection speed, installing VSEW may take anywhere between 20 minutes and an hour — or even more.
This Try It Out exercise guides you through installing VSEW on your computer. It assumes you’re using the web installer, although the process for installing the Express edition from a DVD is almost identical. The steps you need to perform to install the full versions of Visual Studio 2013 are similar as well, although the screens you’ll see will be somewhat different.
1. Start by browsing to www.microsoft.com/ express/ and follow the instructions to download VSEW 2013. You can install directly by choosing the Download and then the Install Now link or you can download an ISO file that you can burn on a DVD or mount on Windows as a virtual drive. Make sure you download Visual Studio Express 2013 for Web, and not one of the

downloading Visual Studio

other free Express editions or older versions. If this link is ever changed or no longer provides direct access to the VSEW download, search the web for “install Visual Studio Express 2013 for Web” and you’ll be taken to a download page where you can start the installation.

2. When the download completes, start the installer. You should see a screen similar to Figure 1-1. Check the checkbox for the license terms and privacy policy. If you’re installing the full version of Visual Studio, click the Next button that appeared when you agreed to the license terms. You see a screen similar to Figure 1-2. Make sure you select at least the Microsoft Web Developer Tools option.

downloading Visual Studio

3. In both cases, click the Install button to start the installation process.

4. After a while you should see a message indicating that Visual Studio has been installed successfully. The installer may need to reboot your machine during or after the installation. Once the installer has finished, Visual Studio is ready for use.

How It Works


The straightforward installation process guided you through the setup of Visual Studio. During installation, a copy of SQL Server 2012 Express Local DB, Microsoft’s free version of its SQL Server 2012 database engine, has been installed. SQL Server 2012 is discussed and used a lot in the future article. Now that Visual Studio is installed, it’s time to fire it up and start working with it. The next section shows you how to create your very first site in VSEW. You see how to create a site, add content to a web page, and view that page in your browser. downloading Visual Studio for which is very simple




Saturday, October 15, 2016

Creating First Program in ASP.NET

                                                    
               Today we will do our First program in asp.net using visual basic.net language visual stdio 1: The first step we should open Visual studio from start menu then from the IDE click on new website as shown in figure 2-2.  
Creating First Program in ASP.NET
figure 2-2

Today we will do our First program in asp.net using visual basic.net language visual stdio 1: The first step we should open Visual studio from start menu then from the IDE click on new website as shown in figure 2-2

Creating First Program in ASP.NET
FIGURE 2-3

2: The first thing we will select visual basic language and select the asp.net empty website and chose your save location on the browse button.

3: click on OK button
4: The new windows should open look like this as shown in figure 2-3



figure 2.4

5:Right Click On the website in the solution explorer click on add from menu and select new webfrom from there and give name your webfrom whatever you want and hit the add button


6:And new screen will appear look like this as shown in figure 2-4 bellow.





explanation:-
You probably can’t wait to get started with your first ASP.NET website, so instead of giving you a theoretical overview of websites in VS, the next Try It Out exercise dives right into the action and shows you how to build your first web project. Then, in the How It Works explanation and the section that follows, you get a good look at what goes on behind the scenes when you view an ASP .NET page in your browser.

1. Start Visual Studio from the Windows Start menu or Start screen. For VSEW, the menu item is called VS Express 2013 for Web. For Windows 8.1, you’ll need to click the down arrow on the Start screen to go to the list of all applications. If you’re using the commercial version of Visual Studio, just start Visual Studio 2013 from the Start screen; all web-related components are accessed from the main VS program. You’ll be greeted by a dialog that lets you sign in to Visual Studio with a Microsoft account. This is useful if you want to synchronize your settings across multiple machines. Click Sign In to enter your credentials or sign up for a new account. If you don’t want to sign in, click Not now, maybe later. The first time you start VS, there might be a delay before you can use it because it’s busy configuring itself. Subsequent starts of the application will go much faster.
2. If you’re using a commercial version of Visual Studio, you may also get a dialog box that lets you choose between different collections of settings the first time you start Visual Studio. The choice you make on that dialog box influences the layout of windows, toolboxes, menus, and shortcuts. Choose the Web Development settings because those settings are designed specifically for ASP .NET developers. You can always choose a different profile later by resetting your settings, as explained later in this chapter.
3. Once VS is fully configured, you see the main screen appear, as shown in Figure 1-3. You get a full description of all the windows, toolbars, panels, and menus in the next section, so
for now, just focus on creating a new website. Click the File menu in the upper-left corner and choose New Web Site.If you’re using a commercial version of Visual Studio, depending on the settings you chose when starting Visual Studio the first time, you may have to open the submenu New first. Make sure you don’t accidentally use the New Project menu, because that is used to create different types of .NET applications. 

The New Web Site dialog box appears as shown in Figure 1-4.



4. In the middle of the dialog, above the list of the available templates, select .NET Framework 4.5.1 from the drop-down list. Then, in the Installed Templates section on the left, you can choose a programming language you will use for your site. This book shows all examples in both Visual Basic and Visual C# so you can choose a language to your liking.

5. In the list of templates in the middle, click ASP.NET Web Forms Site. Verify that File System is the selected option in the Web Location drop-down list at the bottom left. If you want, you could change the location on disk where the website is stored by clicking the Browse button and choosing a new location on your computer’s hard drive. For now, the default location — a folder under your Documents folder — is fine, so you can leave the location as is.

6. Click OK. VS creates a new website for you that includes a number of files and folders (see Figure 1-5) to jump-start your website.

7. Open the file Default.aspx by double-clicking it and remove all the code inside the <asp:Content> block that has its ID set to BodyContent (it starts with <div> at line 5 and ends with </div>) all the way at the bottom. Replace it with the following
bolded code:
--------------------------------------------------------------------------------------------------------------------------
<asp:Content runat="server"ID="BodyContent" ContentPlaceHolderID="MainContent">
<h2>Hello World</h2>
<p>Welcome to Beginning ASP.NET 4.5.1 on <%: DateTime.Now.ToString() %></p>
</asp:Content>
--------------------------------------------------------------------
You’ll see code formatted like this a lot more in this book. When you are instructed to type in code formatted like this with some code in bold, you only need to type in the bolded code. The other code should already be present in the file. Don’t worry about the code with the angle brackets (<>) and percentage symbol in the welcome message; these are called tags, and you learn more about them later. Although this code may not look familiar to you now, you can probably guess what it does: It writes out today’s date and time.

8. Press Ctrl+F5 to open the page in your default web browser. You see a page similar to the one shown in Figure 1-6.





If you already have some experience with Visual Studio you may be used to pressing F5 instead. If you use that option, the site is opened in debug mode and you may get a dialog asking if you want to enable debugging (which you can safely do). Debugging with F5 is discussed in Chapter 18, and you’re advised to use Ctrl+F5 until then. If you see an information bar warning about intranet settings in Internet Explorer, click Turn on Intranet Settings. If you don’t see the date and time in the page, or if you get an error, look again at the code in the welcome message. It starts with an angle bracket (<) followed by a percentage symbol and a colon. It closes with a single percentage sign and another angle bracket (>). Also, make sure you typed in the code exactly as shown here, including capitalization. This is especially true when you are using C#, because that language is case sensitive.


9. Notice how a small icon representing IIS Express has appeared in the tray

bar of Windows, visible in Figure 1-7.


The icon belongs to the built-in web server called IIS Express. This web server has been started by VS automatically to serve the request for your page. You learn more about how the web server processes your page in the later section. If you don’t see the icon in the tray, click the arrow near the other icons in the Windows tray and click the Customize option. Then set IIS Express System Tray to Show Icon and Notifications. That’s it. You just created your very first ASP.NET website with Visual Studio.

How It Works

Although the website you created in this Try It Out is quite simple, the process that eventually results in the page Default.aspx being displayed in your browser isn’t so simple. All by itself, an ASP.NET page (also referred to as an ASPX page because of its extension, or a Web Form) can’t do much. It needs to be processed and served by a web server before your browser can display it. That’s why VS automatically started up IIS Express to handle the request for the page. Next, it started up your default web browser and directed it to the address of the web server (http://localhost:49815/Default in the Try It Out example), although the actual port number in the address may change every time you start the web server because it is randomly chosen by VS. It’s important to realize that the ASPX file you modified in VS is not the same as the one that eventually gets displayed by the browser.

When you create a page in VS, you add markup to it. The markup in an ASPX page is a combination of HTML, code for ASP.NET Server Controls (which you learn more about in this article and in and the future articles, code written in Visual Basic.NET or C#, and more. When you request an ASPX page in your browser, the web server processes the page, executes any server-side code it finds in the file, and effectively transforms the ASP.NET markup into plain HTML
that it then sends to the browser, where it is displayed. In the preceding Try It Out, the resulting HTML causes the browser to display the current date and time. HTML, or HyperText Markup Language, is the language that browsers use to display a web page. You learn how HTML looks and how to use it later article.

NEXT:  Workingwith ASP.NET Server Controls

Popular Posts

Contact Form

Name

Email *

Message *