In this walkthrough, you will work with two refactoring techniques: renaming variables and extracting methods. ![]() The code editor includes tools to help you perform various refactoring tasks. Therefore, you refactor the page's code by creating a data-access method in the page and inserting calls to the method in the handlers. As you develop your page, you discover that you need to access the data from several different handlers. A simple example might be that you write code in an event handler to get data from a database. Refactoring is a software methodology that involves restructuring your code to make it easier to understand and to maintain, while preserving its functionality. You view your current code formatting settings in Visual Studio by selecting Tools -> Options -> Fonts and Colors. The warning simply notifies you that you haven't used the myStr variable yet. The error must be fixed by adding a semicolon to the end of the line. The following image shows the code with the underlines. Also, hold your mouse pointer over the red underline to see the error message. Hold the mouse pointer over myStr to see a tooltip that tells you about the warning. A red underline indicates an error that you must fix. When you press ENTER, the code editor places green and red underlines (commonly call "squiggly" lines) under areas of the code that have issues. Inside the handler, type the following line that contains an error and press ENTER: string myStr = "Loading." You are using the event handler only as a place to write some code. In Design view, double-click the blank page to create a handler for the Load event for the page. To correct simple coding errors in Visual Studio In this part of the walkthrough, you will write a line of code that illustrate the error correction features in the editor. The code editor in Visual Studio helps you to avoid errors as you write code, and if you have made an error, the code editor helps you to correct the error. The next time you run this application to test our progress, you will automatically see this new page in the browser. In Solution Explorer, right-click the new page named FirstWebPage.aspx and select Set As Start Page.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |