Home
Wiley Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter Kit
Contents
1. TE az Enter information to connect to the selected data source or dick Change to choose a different data source and or provider Data source Microsoft SQL Server SqlClient Ser server name x Change Data Source Data source Description Microsoft Access Database File Microsoft ODBC Data Source Use this selection to connect to Microsoft SQL Server Orade 7 3 8i or 9i using the NET Microsoft SQL Server Database File Framework Data Provider for Orade Orade Database lt other gt Data provider NET Framework Data Provider for O x C Always use this selection OK Cancel Test Connection Figure 1 18 Adding a connection to a database server other than SQL Server After specifying the data source type you can use the drop down Server name list to see all the databases of the type you selected that advertise their presence and are available You can also type an instance name directly For the default instance you just need to enter the machine name or you can access a named instance such as a remote Microsoft Data Engine MSDE or SQL Server Express instance by appending the instance name to the machine name separated by a backslash Figure 1 19 shows a connection to the default instance of SQL Server running on a remote machine named DELBOY and to the Northwind database on that machine 17 Chapter 1 18 RarCarnschon Ze En
2. 4x EJ C complete App_Code 3 iy App_Data 2 O gpa LI images E page content C user controls Q XML Data E Contact aspx ES Default aspx EE Delivery aspx 33 Links aspx C PPQ master EE ShowMenu aspx A style css ee 3 TestMenu aspx E TestMenu2 aspx 3 TestMenu3 aspx i3 Web Config a Web sitemap Figure 1 11 Solution Explorer window In fact VWD has automatically attached the database to SQL Server Express Select Database Explorer from the View menu to open the Database Explorer window see Figure 1 12 If you are prompted to give yourself dbo permission at his point select yes The Database Explorer window shows the data connections set up for VWD to use You will see the database shown there as well and you can expand the tree view list to see the categories of objects for the database If when you select the Database Diagrams entry you are prompted to create the items necessary to support diagramming click Yes As you select each item in the list you see details of this item appear in the Properties window such as the connection string and provider details that VWD is using to connect to SQL Server Express 11 Chapter 1 The Solution Explorer and Database Explorer windows dock at the right hand side of the main VWD window by default but you can drag any of the windows to a docked or floating position using their title bars As you drag small arrow indi
3. Chapter 1 Reading and Displaying Data with ASP NET Now that you have set up VWD and SQL Server Express and have seen some of the features that allow you to access data this chapter concludes by showing you just how quickly and easily you can build an ASP NET page that uses the values stored in a database The task is to create a list of the types of pizza and drinks available from Pizza Pretty Quick PPQ by extracting and displaying values from the MenuItems table in the database 1 Start VWD so that the Start Page is displayed see Figure 1 21 and click the link to Open a Web Site Alternatively you can select Open Web Site from the File menu a Start Page Visual Web Developer 2005 Express Edition ogg Fie Edit View Tools Window Community Help pE Ag kaa a E d L B Toolbox skd Start Page x pio Ax General Visual Web Developer 2005 There are no NG usable controls in Express Edition this group Drag an item onto this text to addit to q the toobox Recent Projects Visual Web Developer 2005 Express Edition complete Extending the Personal Web Site Starter Kit Wed 27 Apr 2005 07 00 00 GMT Use Visual Studio 2005 and SQL Server 2005 Express Edition to personalize and extend the Personal Web Site Starter Kit Writing Generic Data Access Code in ASP NET 2 0 and ADO NET 2 0 Thu 14 Apr 2005 07 00 00 GMT Use a step by step approach to learn how to use different ASP NET 2 0 and ADO NET 2 0 tools and t
4. Description Gj Stored Procedures Sri S ij Functions T Synonyms a O Types J Assemblies H Solution Explorer Ma Database Explorer Table Output Sort Type Sort Order Fiter Ore A q 3 Menultems M Properties Ix Menultems Vv Col GraphicFiletame PizzaToppings Menultems a Ea E GraphicFileName Menultems M Ba identity o m E Query Designer s gt SELECT MenultemType ItemName PizzaToppings GraphicFileName FROM Menultems Figure 1 15 Equivalent SQL statement The Query Editor provides a range of ways to create and edit a database query You can add tables to the top section of the window and then drag the columns you want to show into the Criteria grid in the center of the window where you also specify any filtering or sorting you want to apply to the rows Alternatively you can type or copy and paste a SQL statement directly into the lower section of the Query Editor This section below the Criteria grid shows the equivalent Transact SQL T SQL commands used by VWD to fetch or update data when you execute the query Below the SQL window right at the bottom of the central window is another grid that displays the results of executing the query or any error messages generated by the query Getting Started 7 The Criteria grid section specifies not only the columns for the query but also any sorting or filtering you require As a simple example use the drop down lists i
5. Cheese Cheese pizza4 of p SQL Comment Drink Cheap tasteless ALLL drink2 gf E Top Specificator No Drink Cola NULL drinki gif Drink Expensive beer MUUL drink3 gif mu NULL NULL MAL identity 1 of7 gt bib Figure 1 17 Results of query execution You can also use VWD to work with data that is located in a remote SQL Server or other database as well as with local data as we do in this book Right click on the root entry named Data Connections at the top of the Database Explorer window and select Add Connection This opens the Add Connection dialog where you specify details of the database server to which you want to connect At the top of this dialog is the Data source type and the default is Microsoft SQL Sever SqlClient This is the most efficient way to access a SQL Server database because it uses the built in high speed inter face called Tabular Data Stream TDS that is native and exclusive to SQL Server However you can click the Change button see Figure 1 18 and select a different data source type if required For example you can connect to an Access database file any database system that has an open database connectivity ODBC provider available direct to a persisted SOL Server MDF file or to an Oracle database You can even specify using the checkbox at the bottom of the window if this should be the default data source type to use in the future Getting Started
6. in the bottom pane of the Query Editor window see Figure 1 17 15 Chapter 1 16 E complete Visual Web Developer 2005 Express Edition So Fle Edit View Project Buld Debug Data QueryDesigner Tools Window Community Help H RARE RA me W E EEN N Oe Be a aa be Query0 Quer PQ_DATA MDF x Database Explorer 2 E Menultems El 2 all Columns i Date Connections MenultemID LE PPQ_Dats MOF MenultemT ype S C Database Diagrams ItemName O Tables PizzaToppings S O Views Description t Gj Stored Procedures GraphicFieName O Functions x S Lj Synonyms lt u gt e Cl Types 7 a E7 amp ij Assemblies Column Alas Table Output Sort Type Sort Order Filter Or E MenultemType Menultems Descending 1 a y Solution Explorer Mi Database Explorer TtemName Menultems M Ascending 2 Properties 4 x gt PizzaToppings Menuitems m ma a Ory Queryo GraphicFileName Menultems v BS sj l gt E identity SELECT MenultemType ItemName PizzaToppings GraphicFileName FROM Menultems ORDER BY MenultemType DESC ItemName B Query Designer MenultemType ItemName PizzaToppings GraphicFieName zza I Carnivore Special A cow pizza3 gf Distinct Values No Pizza Hawaiian Ham and pineapple pizza2 gf Pizza Margherita Cheese and tom pizza L gf Output All Colum No Pizz Three Cheeses
7. means that you can run VWD on a machine without a Web server installed to develop your site And you can also run it on a machine that does have a Web server such as Internet Information Server IIS installed without interfering with the operation of that Web server Summary 30 In this first chapter you have seen how easy Visual Web Developer VWD 2005 Express Edition is to install configure and use to create powerful and attractive Web pages quickly and with very little effort Because the standard installation also includes SQL Server 2005 Express Edition you don t even have to have a database server available to be able to build data driven pages although as you saw you can use any database server or file based database such as Microsoft Access if you prefer VWD is a remarkable tool for building a whole range of Web sites Web applications and Web Services as you will discover throughout the remainder of this book You will also see and learn about the amazing new features and capabilities of ASP NET version 2 0 which make building high performance Web applications and Web sites so much quicker and easier than ever before In this chapter you installed VWD and used it to access a database through SQL Server Express You also saw some of the features of the VWD interface and its capabilities The discussion skipped over much of the detailed working of these features so that you could quickly get a feel for how it works and w
8. see Figure 1 27 e skeleton Visual Web Developer 2005 Express Edition x File Edit View Website Build Debug Format Layout Tools Window Community Heb N cc er le SO at oy if J o es ee ese gt TestMenu aspx x Database Explorer Ix T lalla aaO O l l ar GridView Tasks 4 cman MenultemType ItemName PizzaToppings Description GraphicFileName Auto Format ja Connections A 0 abc abc abc abc abc Se PPQ_Data MOF Choose Data Source jataSource 1 Database Di 1 abe abe abc abc abc re kas jagrams E Data Source 2 abe abe abc abc abc eee be w O Menultems m efresh Schema 3 abc abc abc abc abc a Grime olumers z zeAndPrice 4 abc abc abc abc abc j Add New Column w E sysdiagrams SqlData Source SqlDataSource1 Enable P T Views dari is T Stored Procedures Enable Sorting ij Functions Z Synonyms Enable Editing Sa Types T Enable Deleting T Assemblies A Enable Selection xplorer Mla Database Expl Edt Templates EX Figure 1 27 GridView Tasks pane Note If you previously experimented with the free tool named WebMatrix for versions 1 0 and 1 1 of ASP NET you will probably be feeling a strange sense of familiarity creep over you looking at the results shown here WebMatrix was in many ways a test platform for the ASP NET 2 0 concept of using data source controls and intelligent grid controls to display data The Web Matrix MxDataGrid c
9. the contents of the database If you cannot see the Solution Explorer or Database Explorer windows use the options on the View menu to make them visible Alternatively select Reset Window Layout from the Window menu You can also close the Start Page now 4 Switch back to Solution Explorer and right click on the top level entry C skeleton in the Solution Explorer window and select Add New Item or select Add New Item from the Website menu to open the Add New Item dialog see Figure 1 24 Select Web Form change the Name to TestMenu aspx and leave the Language set to Visual Basic Also leave the other two checkboxes unticked 22 Add New Item C Websites PPQ skeleton ax Templates ae Visual Studio installed templates E Web Form E Master Page E Web User Control 9 HTML Page j Web Service Ye Class Aj Style Sheet 4g Global Application Class 53 Web Configuration File a XML File a Text Fie SuResource File LJ SQL Database Aj DataSet Generic Handler By Site Map gf Mobile Web Form g VBScript File JScrpt File E Mobile Web User Control E Moble Web Configuration File ig XSLT Fie ig Skin File DJ Browser File My Templates Search Onine Templates A form for Web Applications Name TestMenu aspx Language Visual Basic ix Place code in separate fie 7 i C Select master page Figure 1 24 Add New Item dialog Getting Started 5 Click Add and the new page is added to the si
10. Getting Started Developing sites and applications for the Web finally comes of age with the release of Microsoft Visual Web Developer VWD 2005 Express Edition and version 2 0 of the NET Framework VWD is one of the Express products that Microsoft provides as an expansion of the Visual Studio product line These are lightweight easy to use and easy to learn tools aimed at hobbyists students and novice developers VWD is a lightweight tool for building dynamic Web sites and Web services While there have been other tools and technologies around for a long time the great new features in VWD and NET 2 0 make it even easier to build test deploy manage and extend your Web sites and Web applications This chapter starts the process of demonstrating the capabilities of VWD and showing you how easy it is to build attractive high performance Web sites with ASP NET 2 0 In this chapter you will See the completed example application Install and set up Visual Web Developer 2005 and SQL Server 2005 Express Editions Install the example application files for this book View the example database and execute a test query COooco o Generate a simple page that uses the example database The last two items in this list perform two tasks They confirm that the database is properly installed and accessible thus avoiding any problems that may arise later on They also let you see just how powerful and yet easy to use VWD and ASP NET 2 0 a
11. International Settings Keyboard pany Startup Task List Y Selection margin Web Browser V Indicator margin Projects and Solutions V Vertical scroll bar Text Editor Horizontal scroll bar Database Tools 4 HTML Designer Figure 1 6 Selecting the Show all settings checkbox Getting Started After installing the Visual Web Developer tool you should install the example files for the Pizza Pretty Quick application described in the book To download the examples or to see the application running online go to www daveandal net books 8079 You can also download the examples from the Wrox Books Web site at http eu wiley com WileyCDA WileyTitle productCd 0764588079 html The examples download file contains two versions of the PPQ application One is a skeleton site contain ing the database the images and other resources used in the application but without the ASP NET pages that you will create by working through the chapters in this book The other is a completed version of the application that you can run to see what it looks like how it works and modify or experiment with as you wish without having to build the pages yourself first The next section describes the process for installing the samples setting up the file permissions that are required and testing the application to make sure that it is working properly on your machine Step by Step Installing the PPQ Example Files Follow th
12. MasterPageFik Strict StyleSheetThe Theme Trace TraceMode UiCulture E Body Alink Barennund Alink C Design Source Figure 1 25 Source view gt Color of all active links in the 5 doament 6 Click on the Design button at the bottom of the main window just below the Editor pane and next to the Source button that is currently highlighted to switch the Design view Then go to the Database Explorer window and make sure that the list of Tables in the PPQ database is displayed Click on the table named Menultems and drag it onto the page in the main Editor pane as shown in Figure 1 26 23 Chapter 1 24 Database Explorer ix Bite j Data Connections Al i PPQ_Data MDF w Gj Database Diagrams S E Tables N a E Menaem sa 5 Orders R E SizeAndPrice E sysdiagrams S Lj Views Gj Stored Procedures w Lj Functions w Lj Synonyms w Lj Types a E Assemblies ta Sl Solution Explorer ia Database Explorer Figure 1 26 Dragging Menultems onto the main editor pane 7 Now the magic begins You will see that VWD creates a grid in the page using the new ASP NET GridView control with columns that match those in the source data table such as MenuItemID MenuItemType and ItemName It also adds a control named SqlDataSource to the page just below the grid In addition to the right of the grid a Task pane with the title GridView Tasks appears
13. S Edit Delete Select 7 abc abc abe abc abc eee Edit Delete Select 8 abc abc abc abc abc E ee Edit Delete Select 9 abc abc abc abc abc X Enable Deleting 12 V Enable Selection gpintiserrenensmern merece sane Edit Templates SqlData Source SqiDataSource1 a Figure 1 28 Adding links The pop up task panes like the GridView Tasks pane shown in Figure 1 28 can be displayed and hidden by clicking on the small square icon that contains a left or right facing arrow This icon appears at the top right of any control that provides a task pane when you move the mouse over that control 9 The Auto Format dialog that opens from the Auto Format link shows a list of preconfigured styles that you can apply to the GridView control Select one see Figure 1 29 and click OK Auto Format we Select a scheme Preview Simple A Autumn Oceanica Edit Delete Select 0 Brown Sugar 3 Slate Edit Delete Select 1 at Se Edit Delete Select 2 at ainy Day Snowy Pine Edit Delete Select 3 at Lilacs in Mist Black amp Blue 1 Edit Delete Select 4 at Black amp Blue 2 z RENT Edit Delete Select 5 at Apple Orchard rA A a PE NT ee A G A alte ai Me isl gt OK Cancel I Apply Figure 1 29 Selecting a preconfigured style Chapter 1 10 You will see the grid change to reflect the new style However before you run the page there are a few other changes you can make to produce a n
14. System mrak P men B Desktop A wy My Documents F pe S W SUNDIVE G3 3v2 Floppy A 5 Local Disk C ze Documents and Settings FTP Site a Inetpub e Program Files http 5 SetupFiles Remote Site Temp Websites PPQ S complete skeleton WINDOWS S wmpub a WUTemp lt Local Disk D mtd DVD Drive E m Folder C Websites PPQ skeleton Open Cancel Figure 1 22 Navigating to the skeleton folder Click OK and you then see the files that make up the site in the Solution Explorer window Switch to the Database Explorer window and you see the database that is in the App_Data folder of the site VWD automatically attaches any MDF file it finds in the folder named App_Data when it opens a site and this is what has happened here You can expand the tree to see the contents of the database as shown in Figure 1 23 21 Chapter 1 P G skeleton LZ App_Code 6 LI App_Data w Lj images w Lj page content w O user controls w O XML Data EE Contact aspx E Links aspx Aj style css Ep Web Config i Web sitemap J Data Connections o B Agan w O Database Diagrams O Tables a E Menultems w E Orders 5 SizeAndPrice w E sysdiagrams O Views E Stored Procedures Q Functions L Synonyms i Types jj Assemblies Sy Solution Explorer Database Expl Solution Explorer Zs Database Expl Figure 1 23 Expanding the tree to see
15. cators become visible allowing you drop the window into another one or dock it at the side of the main VWD window Use the drop down menu the down arrow icon in the title bar or the Auto Hide feature the pin shaped icon to set up the window positions you require If you cannot reorganize windows in the way you want to you can go back to the original window layout using the Reset Window Layout command on the main Window menu 4 Now that the database is available in VWD you can test that it is working properly and see the kinds of data it contains Right click on the data connection name and select New Query from Database Explorer ax EMEA 3 p Data Connections Uk PPQ_Data MDF jj Database Diagrams O Tables 2 Views J Stored Procedures LI Functions C Synonyms Lj Types Q Assemblies Sol ution Explorer Zit Database Explorer Properties ax PPQ_Data MDF mA B Identity B Connection B Misc Connection String Figure 1 12 Database Explorer window the pop up menu that appears see Figure 1 13 12 Getting Started Modify Connection Ca Fur Close Connection i Syn Ga Ty Change View a Solution Explorer Properties PPQ_Data MDF Figure 1 13 Selecting New Query 5 This opens the Query Editor in the main central section of the VWD window You can close or auto hide the Toolbar window to make more room as shown in the screenshot The Add Tab
16. ctually are You will be amazed at how quickly and easily you can create a page that includes many features that previously would have required a great deal of code and development work Chapter 1 About the Example Application In this book you will be building a Web site that displays and sells products a common scenario for many Web developers today It is not a complicated site in comparison to many out there but is extensive enough to demonstrate most of the features of ASP NET 2 0 and VWD as well as showing you the prime techniques and approaches that are used as the foundations for almost all Web sites built using version 2 0 of NET The product you will see in the demonstration site is not complicated either The site is a fictional online pizza parlor that sells and delivers pizzas and drinks to customers Figure 1 1 shows the page in the example application that lists the items available from Pizza Pretty Quick or as you will see it described throughout the book PPQ The page header and the menu you see at the left are part of a master page This makes is easy to achieve a consistent look and feel for the whole site and saves a lot of work both when creating new pages and when updating the site design Data for the list of available items comes from a database table stored in a local copy of SOL Server 2005 Express Edition running on the same machine as VWD lE Our Stone Baked Menu Microsoft Internet Expl
17. e A page content i TestMenu3 aspx 3KB ASP NET Server Page 28 07 2005 10 02 A D user controls El TestMenu3 aspx vb 1KB BFie 26 07 2005 20 05 A XML Data Z Testenu aspx 3KB ASP NET Server Page 18 07 2005 15 26 A skeleton E Web Config 3KB XML Configuration File 20 07 2005 16 48 A O App_Code dM Web sitemap 2KB ASP NET Site Map 29 07 2005 13 52 A C App_Dats O images C page lt ontent CD user controls gt XML Data o C WIndows rn 19 objects Disk free space 13 7 GB 32 0 KB My Computer Figure 1 7 Subfolders inside the PPQ folder Chapter 1 2 If you are running Windows XP and you have Internet Information Services IIS installed you must now grant the accounts named ASPNET and NETWORK SERVICE under which ASP NET executes depending on whether you installed SP2 the required permissions to access the database provided with the example files This and the remaining steps are not required in Windows Server 2003 or if you do not have IIS installed In Windows Explorer right click on the subfolder named App_Data within the skeleton folder and select Properties In the App_Data Properties dialog select the Security tab and click the Add button to open the Select Users or Groups dialog as shown in Figure 1 8 Click the Locations button and select the name of your machine not the domain it is part of and click OK then enter the account name ASPNET in the text box and click the Check Names button Th
18. e full account name including the machine name is underlined to indicate that is was located App_Data Properties Be General Sharing Securty Web Sharing Customize Group or user names fP Everyone Add I Remove __Pemnissions for Everyone Allow Deny Select Users Computers or Groups Zed Select this object type Users Groups or Built in security principals Object Types From this location primrose hill blackwellintemet com Locations Enter the object names to select examples DELMONTE ASPNET l Cam Figure 1 8 Select Users or Groups dialog Click OK to return to the Select Users or Groups dialog ensure the new entry ASPNET is selected in the upper list and select the Write option in the lower list box see Figure 1 9 then click OK Getting Started App_Data Properties we General Sharing Security Web Sharing Customize Group or user names ASP NET Machine Account DELMONTE ASPNET 8 Everyone Add Remove Permissions for ASP NET Machine Account Allow Deny Modify Read amp Execute v List Folder Contents v Read Write Special Permissions vv For special permissions or for advanced settings click Advanced OK l Cancel N Apply Figure 1 9 Selecting the Write option If you cannot see a Security tab in the App_Data Pro
19. echniques for writing generic data access code Introduction to the Personal Web Site Starter Kit Fri 08 Apr 2005 07 00 00 GMT Learn about the new Personal Web Site Starter Kit which is an avalable project type in Visual Studio 2005 and Visual y solution Explorer Ma Database Expl Web Developer 2005 Express Edition m New Visual Studio Tools Features for Web Developers Properties A x Thu 16 Sep 2004 07 00 00 GMT Watch Brian Goldfarb demo some of the new tools enhancements to both the design editor and code editor which indude validation InteliSense improvements source code preservation ALUE and more Web Development with Visual Web Developer 2005 Express Edit Fri 16 Jul 2004 07 00 00 GMT Use Data Explorer in Visual Web Developer 2005 Express Edition to view SQL Server 2005 Express Edition databases work with data sources and build n tier architecture with data components Visual Web Developer Express He Give us feedback suggestions or tell us about bugs in Visual Studio 2005 ES Figure 1 21 Start Page 20 2 Getting Started In the Open Web Site dialog ensure that File System is selected in the top left of the dialog and navigate to the skeleton folder within the C Websites PPQ folder where you installed the example files see Figure 1 22 Open Web Site we z File System ev Select the folder you want to open a Xx File
20. enable debugging A Debugging should be disabled in the Web config file before deploying the Web site to a production environment O Run without debugging Equivalent to Ctrl F5 Figure 1 32 Debugging Not Enabled dialog 27 Chapter 1 Untitle p File Edit View Favorites Tools Help Qx O amp BO Plh kF A amp B http focalhost 119 1 skeleton TestMenu aspx g icroso MenultemType ItemName PizzaToppings Description Margherita Cheese and tomato The basic pizza Nice but dull A bit fruity Served by someone wearing a loud shirt For those who need their meat A thin crust pizza base topped with a 160z steak Hawaiian Ham and pineapple It s a bit runny The one you ve never heard of Almost as much taste as rainwater The real thing best drunk warm javascript _doPostBack GridView Select 2 Local intranet Figure 1 32 13 Nowa browser window opens and you will see your new ASP NET page appear You can select a row simply by clicking the link in the left hand column and that row is high lighted automatically see Figure 1 33 g soft Internet Explorer File Edit View Favorites Tools Help Gok O AAO Ash drraoits Gy amp B amp http localhost 119 1 skeleton TestMenu aspx MenultemType ItemName o Description Cola i The one you ve never heard of Cheap tasteless Almost as much taste as beer rainwater Expensive beer with flavo
21. er 2005 Express Edition Installation Options Select the optional product s you would like to install v Microsoft MSDN 2005 Express Edition The MSDN Express Library contains additional product documentation for all Visual Studio Express Editions You can choose to install MSDN Express Library at a later time See the Readme for more information v Microsoft SQL Server 2005 Express Edition x86 SQL Server Express is a basic version of Microsoft SQL Server that allows you to easily read write and deploy application data U For more information see the Readme file lt Previous Figure 1 2 Installation Options page al Cancel If you would like to read more about the installation and any issues it may have then you can click the Readme link on the installation options screen Figure 1 2 Chapter 1 3 Click Next In the Destination Folder page see Figure 1 3 confirm the path where VWD will be installed It is recommended that you leave it set to the default This page shows a summary of the products for installation and the disk space requirements Visual Web Developer 2005 Express Edition Setup peanon Clio isual Web Developer 2005 Express Edition Select the location where you would like to install Visual Web Developer 2005 Express Edition Install in folder C Program Files Microsoft Visual Studio 8 The following products will be ins
22. es Be z 3 j MenultemType ItemName PizzaToppings Description Edit Delete Select abc abc abc abc Edit Delete Select abc abc abc abc Edit Delete Select abc abc abc abc Edit Delete Select abc abc abc abc Edit Delete Select abc abc abc abc Edit Delete Select abc abc abc abc Edit Delete Select abc abc abc abc Edit Delete Select abc abc abc abc Edit Delete Select abc abc abc abc Edit Delete Select abc abc abc abc 12 re SqlDataSource1 Figure 1 31 Updated GridView Now you can run the page to see the results Click the Start Debugging button in the Toolbar above the main editing window or just press the F5 key Alternatively you can select Start Debugging from the Debug menu At this point the Debugging Not Enabled dialog appears see Figure 1 32 because there is no web config file in the application folders VWD needs a web config to be able to turn on debugging by setting a value in this file The best course of action is to select the first option whereupon VWD will create a default web config file and set the appropriate values This also means that you will not see this dialog every time you run a page and VWD will be able to provide more information on any errors that it encounters Debugging Not Enabled we The page cannot be run in debug mode because debugging is not enabled in the Web config file What would you like to do Modify the Web config file to
23. ese steps for installing the PPQ example files 1 Download the example files from one of the locations detailed earlier The download file is a ZIP file and you must extract the files from it into a folder on your machine making sure that you retain the folder structure within the examples ZIP file Extract the examples into a new folder named C Websites PPQ or into a folder of the same name on another drive You will see the two subfolders named skeleton and complete within the PPQ folder see Figure 1 7 C Websites PPQ complete aax File Edit View Favorites Tools Help iv Qax P Search Folders x m ss C C Websites PPQ komplete x Go Folders x Name Size Type Date Modified Attribu W sunone a App_Code File Folder 28 07 2005 10 07 JB 3 Floppy A C App_Data File Folder 06 07 2005 15 59 G Local Disk C Eimages File Folder 29 07 2005 15 33 A S Documents and Settings page content File Folder i 3 Inetpub Quser controls File Folder B Program Files Qxm Data File Folder A B Setup les lt 3 Contact aspx 2KB ASP NET Server Page A Temp 23 Defeult aspx 2KB ASP NET Server Page 4 3 Websites T Delvery aspx 2KB ASP NET Server Page A pea Tf Links aspx 2KB ASP NET Server Page A complete lt 3 PPQ master 4KB ASP NET Master Page A App_Code E ShowMenu aspx 6KB ASP NET Server Page A App_Data style css 1KB Cascading Style Sh A images ZB TestMenu2 aspx SKB ASP NET Server Pag
24. hat it can do You will of course see a lot more detail in later chapters of this book In summary this chapter covered A preview of the completed example application Installation and set up of Visual Web Developer 2005 and SQL Server 2005 Express Editions Installation of the example application files for this book Viewing the example database and executing a test query COCoovco do Generating a simple page that uses the example database In Chapter 2 you will begin a more detailed journey through the features of VWD and ASP NET 2 0 by looking at the design of the PPQ Web site how master pages can make things so much easier and how you can plan and implement navigation between the pages of your site
25. icer result Two of the columns in the grid dis play information that is not really relevant in this page The first column named MenuItemID contains the ID value for each menu item while the column named GraphicFileName contains the file name of an image for each item So in the GridView Tasks pane click the Edit Columns link to open the Fields dialog see Figure 1 30 In the Fields dialog locate the MenuItemID col umn in the Selected fields list and remove it by clicking the button marked with a cross next to the list Then repeat this process to remove the GraphicFileName column from the grid 2 Fields ajx Available fields All Fields A E undField I full ey f MenultemType ItemName PizzaToppings Description v for oe ed Add Selected fields amp CommandField Al E MenultemID B MenultemType E ItemName B PizzaToppings on a N r s gt C Auto generate fields Faa Refresh Schema BoundField properties Elua Convert this field into a TemplateField Figure 1 30 Fields dialog 11 Click OK to close the dialog and you will see the updated GridView control in the page You can see that it now only contains four columns from the source data table see Figure 1 31 26 12 Getting Started 2 skeleton Visual Web Developer 2005 Express Edition File Edit View Website Build Debug Format Layout Tools Window Community Help a Weal nal a eae
26. kup Language HTML standard that you want to be used for validating your page content Chapter 1 Options we E Start Pages in Fonts and Colors Source View Format O Design View Validation Source View Auto list members Line numbers C word wrap Indenting gt Lave Tab size 4 Block Indent size 4 Miscellaneous Auto show Smart Tag on control creation Figure 1 5 Options dialog box T You can also exert a lot more control over a wider range of settings by ticking the Show all settings checkbox at the bottom left of the Options dialog see Figure 1 6 This displays a tree with literally hundreds of settings available in more than 75 pages of options Some of these of these are not applicable to the kinds of files you will create in VWD or when writing code using Visual Basic 2005 However the General pages in sections such as Environment Help Projects and Solutions Text Editor and HTML Designer are worth a visit as you get used to using the tool and you now know where to look for these settings Options we Environment Settings General C Go to selection anchor after escape AutoRecover V Drag and drop text editing Documents _ Indude insertion point movements in Undo list Find and Replace ME Te To Fonts and Colors a Automatic delimiter highlighting Help Y Track changes Import and Export Settings V Auto detect UTF 8 encoding without signature
27. le dialog also appears automatically showing a list of tables in the database that you can use in your new query as shown Figure 1 14 _ Query0 Quer PQ_DATA MDF i Data Connections S amp PPQ_Date MOF O Database Diagrams E Tables O Views E Stored Procedures O Functions E Synonyms EA Types E Assemblies Solution Explorer Mt Database Explorer a x ee A Re 2 B identity Query Designer Distinct Values No Output All Colur No SQL Comment Top Specificator No Figure 1 14 Add Table dialog 13 Chapter 1 14 6 Select the table named Menultems and click Add to add this table to the Diagram pane at the top of the Query Editor window Then click Close In the list of columns that appears in the Diagram pane select the columns named MenuItemType ItemName PizzaToppings and GraphicFileName You can either tick the checkboxes to add them to the grid or drag and drop them there Notice how VWD creates the equivalent SQL statement in the section below the grid as shown in Figure 1 15 a complete Visual Web Developer 2005 Express Edition Sax Fle Edit View Project Buld Debug Data QueryDesigner Tools Window Community Help e ane ae E O ace i SETT 5 x x Database Explorer AX MENA S j Data Connections UE PPQ_Date MOF v MenultemType S O Database Diagrams v ItemName S E Tables v PizzaToppings S O Views
28. microsoft com express You can install it on Windows 98 Windows 2000 Professional or Server Windows XP with Service Pack 2 or Windows Server 2003 In this book you will see it running on both Windows XP and Windows Server 2003 Installation is easy as you will see in the following step by step guide and there is no other configuration required after installation Step by Step Using the Setup Wizard Follow these steps to use the Setup Wizard 1 If you are installing from the book s CD ROM and the installer doesn t automatically begin when you insert the CD double click on setup exe to start the Setup Wizard If you downloaded the software double click on the downloaded program file to start the Setup Wizard In the Setup Wizard step through the screens that concern providing feedback and accepting the license agreement You may also have to install other updates such as XP Service Pack 2 or the latest Windows Installer during this process and these may require a reboot during the installation Continue to click Next until you reach the Installation Options page that shows the list of prod ucts for installation Figure 1 2 Make sure that SQL Server 2005 Express Edition is included and it is also a good idea to install the MSDN Express Library as well You will see references to help topics in these pages in various places within this book Visual Web Developer 2005 Express Edition Setup Ga MIKI Visual Web Develop
29. n on or off features such as Multiple Active Results Sets and Asynchronous Processing which saves resources and increases efficiency if you do not require these features Figure 1 20 shows a connection to a database file and some of the many options available in the Advanced Properties dialog Add Connection we Enter information to connect to the selected data source or click Advanced Properties ax Change to choose a different data source and or provider a eas 2 I J Data source IB advanced m aciono SQE Server Selen MultipleActiveResultSets False Server name Network Library locathost SQLEXPRESS x Packet Sze 8000 TE Type System Verson Latest Log on to the server IE Context se Windows Authentication Application Name Net SqiChent Data Provider Workstation ID Use SQL Server Authentication E Initialization Asynchronous Processing False Connect Timeout 15 Current Language B Pooling Connection Reset True Connect to a database Enlist Troe O Select or enter a database name Load Balance Timeout 0 Max Pool Size 100 Min Pool Size 0 Attach a database fie Pooling True C Websites PPQ omplete App_DataPPQ_D E Replication x Logical name Data Source Indicates the name of the data source to connect to Data Source localhost SQLEXPRESS AttachDbFilename C Wel Gest connection Cx Cx Figure 1 20 Connecting to a database MDF file and setting the Advanced Properties of the connection 19
30. n the Sort Type column of the grid to set the sort order for the rows as Ascending by ItemName then Descending by ItemPrice as shown in Figure 1 16 Select the columns named MenuItemType ItemName PizzaToppings and GraphicFileName Again you will see the equivalent SQL statement appear in the SQL pane below the grid M complete Visual Web Developer 2005 Express Edition Fle Edit View Project Buld Oebug Data QueryDesigner Tool Window Community Help H RARER A ee ED A ee Mew AY A oud E Menultems 1 _ All Columns ji Data Connections U amp PPQ_Date MOF O Database Diagrams O Tables Lj Views O Stored Procedures C Functions Lj Synonyms C Types C Assemblies amp ylSolution Explorer Mit Database Explorer MenultemT ype ItemName PizzaToppings Description GraphicFieName CC PEAF Column Sort Type Sort Order MenultemType V Descending 1 4x ItemName Ascending nE X PizzaToppings is GraphicrileName B identity s SELECT MenultemType ItemName PizzaToppings GraphicFileName FROM Menultems ji ORDER BY MenultemType DESC ItemName Distinct Values No E Query Designer Output All Colum No SQL Comment amp Top Specificator No Identity Figure 1 16 Sorting by ascending and descending order 8 Click the Execute button the button in the toolbar with a red exclamation mark and the results of executing this query appear
31. ode in ASP NET 2 0 and ADO NET 2 0 Thu 14 Apr 2005 07 00 00 GMT Use a step by step approach to learn how to use different ASP NET 2 0 and ADO NET 2 0 tools and techniques for writing generic data access code Introduction to the Personal Web Site Starter Kit Fri 08 Apr 2005 07 00 00 GMT Learn about the new Personal Web Site Starter Kit which is an available project type in Visual Studio 2005 and Visual Web Developer 2005 Express Edition New Visual Studio Tools Features for Web Developers Thu 16 Sep 2004 07 00 00 GMT Watch Brian Goldfarb demo some of the new tools enhancements to both the design editor and code editor which indude validation InteliSense improvements source code preservation and more Web Development with Visual Web Developer 2005 Express Edition and Fri 16 Jul 2004 07 00 00 GMT Use Data Explorer in Visual Web Developer 2005 Express Edition to view SQL Server 2005 Express Editon databases work with data sources and buld n bter architecture with data components Properties ax pale 6 VWDis extremely configurable so you can change many features to suit your preferences Click Options on the Tools menu to open the Options dialog see Figure 1 5 Here you see a simplified view of the options you can set These include general options the fonts and colors used in the various windows within the IDE the formatting options for the text and code you type and the target browser or HyperText Mar
32. ontrol was the forerunner to the new ASP NET 2 0 GridView control and the Web Matrix MXSqlDataSource control was the forerunner to the Sql1DataSource and other data source con trols in ASP NET 2 0 Getting Started 8 The list of checkboxes on the GridView Tasks pop up is just too tempting to ignore so go ahead and tick them all to enable paging sorting editing deleting and selection At each stage you ll see the grid in the page change to reflect the features you specify such as adding the paging controls below the grid turning the header text for each column into a hyperlink and adding the Edit Delete and Select links to each row as shown in Figure 1 28 Then click the Auto Format link at the top of the GridView Tasks pop up ef skeleton Visual Web Developer 2005 Express Edition Fie Edit View Website Buld Debug Format Layout Tools Window Community Help TestMenu aspx x Explorer 1 aa 3 GridView Tasks g MenultemID MenultemType ItemName PizzaToppings Description GraphicFileName P zE uto Forma Edit Delete Select 0 abc abc abe abe abc Edit Delete Select 1 abe abe abe abe abe bak Edit Delete Select 2 abc abc abc abc abc oo ET Edit Delete Select 3 abc abc abe abe abe Edit Delete Select 4 abc abc abc abc abc A E Ede Add New Column Edit Delete Select 5 abc abc abc abc abc v Enable Paging Edit Delete Select 6 abe abe abe abc abc Paice v
33. orer Se File Edit View Favorites Tools Help v Home our enu gt Our Stone Baked Menu Links Contact Pizza Carnivore Special Generously topped with A cow For those who need their meat A SBS thin crust pizza base topped with a 160z steak Large 12 95 Gigantic 17 95 ORE a DIC 1F G9 IIE 34 G9 DIL 13 G9 DIS Pizza Hawaiian RS Q 4 Generously topped with Ham and pineapple A bit fruity Served by X sf ja someone wearing a loud shirt gt Slice 2 50 Small 5 95 Medium 7 95 Large 9 95 Pizza Margherita Generously topped with Cheese and tomato The basic pizza Nice but dull Slice 1 95 Small 4 95 Medium 6 95 Large 9 95 Huge 12 95 VIIBI DIE IBD DIG 14 G9 DVIS 33S9 DIS iv Done Local intranet Figure 1 1 The completed site showing the list of items you can order The installation routine for VWD allows you to install SQL Server Express as part of the main program installation Alternatively if required you can access data stored in SQL Server 2000 or SQL Server 2005 on another machine The set of examples you can download for this book contains the SQL Server database Getting Started Installing Visual Web Developer Visual Web Developer 2005 Express Edition is available along with SQL Server 2005 Express Edition on the CD ROM included with this book Both are also available for download along with other Express products from Microsoft at http msdn
34. perties dialog you have Simple File Sharing enabled Select Folder Options from the Tools menu and select the View tab At the bottom of the list uncheck the option named Use Simple File Sharing This option does not appear in Windows Server 2003 because this operating system does not support simple file sharing However the Use Simple File Sharing option does not appear in Windows XP Home Edition either because this operating system uses only simple file sharing In this case you must restart your machine and hold down the F8 key as it starts and then select Safe Mode Log in as Administrator after Windows starts up in safe mode and navigate to the C WebSites PPQ folder in Windows Explorer When you right click on the App_Data folder and select Properties you will see that the Security tab has now appeared 4 Now repeat the process from step 2 to give Write permission to the NETWORK SERVICE account for the App_Data folder within the skeleton folder of the examples If you have not yet installed Service Pack 2 for Windows XP you will not have an account named NETWORK SERVICE and so you can skip step 3 5 Repeat the process again from step 2 to give Write permission to the ASPNET and NETWORK SERVICE accounts for the App_Data folder within the completed folder of the examples The application including the database is now installed and ready to use Chapter 1 Viewing the PPQ Example Database With Visual Web Developer up and r
35. r The real thing best drunk warm For those who need their meat A cow A thin crust pizza base topped with a 160z steak Margherita Cheese and tomato The basic pizza Nice but dull Cheese Cheese and more Cheese Camivore Special Three Cheeses It s a bit runny A bit fruity Served by Hawaiian Ham and pineapple Se chee javascript _doPostBack GridView 1 Sort PizzaToppings Local intranet Figure 1 33 Automatically highlighting a row 28 Getting Started 14 You can also sort the rows in a different order by clicking on the links in the title bar and if there were more than 10 rows in the table you would be able to change to a different page of results In this case paging controls would appear at the bottom of the grid as you ll see in later exam ples see Figure 1 34 Untitled Page Microsoft Internet Explorer File Edit View Favorites Tools Help Ad 2 Ch Plh K Faites Gay oe B ess a http focalhost 119 1 skeleton TestMenu aspx MenultemType Update Cancel Edit Delete Select Edit Delete Select Edit Delete Select ItemName Cola Cheap tasteless beer Carnivore Special Acow Margherita Cheese Cheese and more Cheese Ham and pineapple PizzaToppings Cheese and tomato Almost as much taste as tainwater Expensive beer with The real thing best flavor drank warm For those who need their r The basic pizza Nice but dull It s a bi
36. t runny A bit fruity Served by someone wearing a loud shirt la Figure 1 34 Selecting a different page of results 4 Local intranet 15 You can even edit the values in the rows see Figure 1 35 and save these values back to the database by clicking the Update link that appears when a row is in edit mode And all of this without writing any code at all Fj Untitled Page Microsoft Internet Explorer File Edt View Favorites Tools Help Qk O d iz PH Search S Favorites O7 a Ge Edit Delete Select Edt Delete Select Edit Delete Select Pizza Update Cancel Edit Delete Select Edit Delete Select Edit Delete Select Edit Delete Select Edit Delete Select Figure 1 35 Editing row values Margherita Large Margherita Huge Pizza Hawi ian Special Small Hawiian A Medium Hawiian Large Carnivore Special Large Carnivore Special Gigantic Three Cheeses Small Address http localhost 1305 skeleton TestMenu aspx Go 4 95 9 95 12 95 5900 7 95 9 95 12 95 17 95 5 95 29 Chapter 1 Notice that the URL in the address bar and the icon for VWD s built in Web server that appears in the notification area of the Windows taskbar indicate that the page is running on your local machine localhost but using a nonstandard port number usually port 80 is used for a Web server You will see a different port number because VWD chooses one at run time This
37. talled Microsoft NET Framework 2 0 Visual Web Developer 2005 Express Edition Microsoft MSDN 2005 Express Edition Microsoft SQL Server 2005 Express Edition x86 Disk space requirements C 1 5 GB lt Previous In Figure 1 3 Destination Folder page 4 Click Install to start the installation After it completes you will find entries in the Programs section of your Start menu for Visual Web Developer and SQL Server The SQL Server section includes a tool that you can use to set the configuration options for SQL Server if you want to change the services or protocols it uses This may be necessary if you want to be able to access SQL Server from another machine but no changes are required when accessing it from the local machine as you will see in this book 5 Start up VWD to confirm that it has been successfully installed You will see the Start Page and some empty docked windows as shown in Figure 1 4 Getting Started Sits Recent Projects Visual Web Developer 2005 Express Edition o skeleton Visual Web Developer Express He Give us feedback suggestions or tell us about bugs in Visual Studio 2005 EE t Figure 1 4 Start Page Extending the Personal Web Site Starter Kit Wed 27 Apr 2005 07 00 00 GMT Use Visual Studio 2005 and SQL Server 2005 Express Edition to personalize and extend the Personal Web Site Starter Kit Writing Generic Data Access C
38. te it appears in the Solution Explorer window and is displayed in the main VWD window At the same time the Toolbox is populated with a list of all the available ASP NET controls At the moment you are in Source view as shown by the indicator just below the main editor window shown in Figure 1 25 so the HTML and an empty code section delimited by lt script gt tags is visible Ma skeleton Visual Web Developer 2005 Express Edition dagg Fie Edit View Website Buld Debug Tools Window Community Help A Label abl TextBox sb Button LinkButton ImageButton A Hyperlink EA DropDownList ListBox v ChedBox E ChecBoxtist RadioButton RadioButtonList La Image i ImageMap J Table BulletedList HiddenField Ej Literal T Calendar Sj AdRotator t FileUpload 4 Wizard E m MultiView E Panel SZ PlaceHolder O View a ea haem Pole A Server Objects amp Events 1 lt amp Page L 12i lt head gt 1319 lt body gt K3 lt form id formi ly No Events W3C DTD XHTML 1 0 lt title gt Untitled Page lt title gt runat server gt Transitional EN C skeleton 42 App_Code C App_Data LI images C page content E user controls O XML Data E Contact aspx fe Links aspx A style css E TestMenu aspx ES web config Sh Web sitemap E Solution Ex Big Database E Properties x DOCUMENT
39. ter information to connect to the selected data source or click Change to choose a different data source and or provider Data source Microsoft SQL Server SqlClient Server name psor x Log on to the server O Use Windows Authentication Use SQL Server Authentication Username anon Password Save my password Connect to a database Select or enter a database name Figure 1 19 Connecting to the Northwind database on a remote machine named DELBOY Figure 1 19 you must specify details of a suitable account within SQL Server If for any reason you cannot install SQL Server Express or want to experiment with a different database you can use the process just described to connect to a suitable database You can confirm that the connection to the target database is working by clicking the Test Connection button before you close the Add Connection dialog Getting Started Figure 1 19 is the option to connect to a SQL Server MDF database file In this case you specify the file location using the Browse button near the bottom of the Add Connection dialog As before you must specify the database server name to which the file will be attached and the authentication type you want to use Another feature is the ability to specify the fine details of the connection Click the Advanced button near the bottom of the Add Connection dialog to open the Advanced Properties dialog For example you can tur
40. unning you can now look at the example database used for the PPQ application This demonstrates the database access features that VWD provides and will give you a feeling for the way that the sample data is organized and used within the application Step by Step Viewing the PPQ Database Follow these steps to view the PPQ database 1 In VWD select Open Web Site from the File menu and ensure that the File System option is selected in the left hand side of the dialog see Figure 1 10 Select the folder named complete within the examples and click Open Open Web Site we File System on Select the folder you want to open ia X File System a R Desktop A E H E My Documents 5 W SUNDIVE Local IIS a 312 Floppy A e Local Disk C Documents and Settings FTP Site 3 Inetpub y 3 Program Files http 4 SetupFiles Remote Site Temp 3 Websites PPQ complete C3 skeleton WINDOWS wmpub C WUTemp See Local Disk D 1 DVD Drive E x Folder C Websites PPQomplete Open Cancel Figure 1 10 File System option 10 Getting Started The Web site is loaded into VWD and the files that make up the application can be seen in the Solution Explorer window If the Solution Explorer window is not visible open it by selecting Solution Explorer from the View menu As shown in Figure 1 11 notice that the database in the App_Data folder is also visible Solution Explorer
Download Pdf Manuals
Related Search
Related Contents
ETNA Trader Front Office User Manual 1770-6.5.4, Data Cartridge Recorder, User Manual manuale - Hanna Instruments 53855-Series 653-b Hand Operated Lever Hoists.qxd Hampton Bay L-GZ680PST-M Use and Care Manual KNX - Modbus TCP master User`s manual v10 USER MANUAL Geometry - Support Fisher & Paykel CE604DTB1 hob Copyright © All rights reserved.
Failed to retrieve file