Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C# 2008 Step by Step.pdf
Скачиваний:
26
Добавлен:
25.03.2016
Размер:
13.96 Mб
Скачать

Chapter 29 Protecting a Web Site and Accessing Data with Web Forms

621

4.Click the Return to Customers hyperlink.

5.On the CustomersData Web form, click the hyperlink in the Customer ID column for another customer. The OrderHistory Web form should display the order history for the appropriate customer.

6.When you have finished browsing the data, close Internet Explorer and return to Visual Studio 2008.

This chapter has shown you the fundamentals of building and protecting a Web application that maintains data in a database. If you are interested in creating highly interactive Web

applications that incorporate multimedia capabilities, you should take a look at Microsoft Silverlight. You can find more information about Silverlight at http://silverlight.net.

If you want to continue to the next chapter

Keep Visual Studio 2008 running, and turn to Chapter 30.

If you want to exit Visual Studio 2008 now

On the File menu, click Exit. If you see a Save dialog box, click Yes and save the project.

Chapter 29 Quick Reference

To

Do this

Create a login Web form

Create a new Web form. Add a Login control for authenticating users.

 

 

Configure security for an ASP.

Use the ASP.NET Web Site Administration Tool to add and maintain users,

NET Web site

define roles, and create access rules. (On the Website menu, click ASP.NET

 

Configuration to start this tool.)

 

 

Implement Forms-based

Edit the web.config file. Set the <authentication mode> attribute to

security

Forms, provide the URL of the login form, and specify any authentication

 

parameters required. For example:

 

<authentication mode=”Forms”>

 

<forms loginUrl=”LoginForm.aspx”

 

timeout=”5”

 

cookieless=”AutoDetect”

 

protection=”All” />

 

</authentication>

Create a Web form for displaying data from a database

Add a data source control to the Web form, and configure it to connect to the appropriate database.

Add a GridView control to the Web form, and set its DataSourceID property to the data source control.

622

Part VI Building Web Applications

 

 

Fetch and display data in

Set the AllowPaging property of the GridView control to True. Set the

manageable chunks in a

PagerSize property to the number of rows to be displayed on each page.

Web form

Modify the PagerSettings and PagerStyle properties to match the style of

 

 

the Web form.

 

 

Modify rows in a database

Ensure that the data source enables updating data.

using a GridView control

Using the Common GridView Tasks smart tag menu, select Enable Updating.

 

 

Navigate from one Web form

Define a column as a HyperLinkField control. Specify the URL and optional

to another by selecting a row in

query string for the destination form in the DataNavigateUrlFormatString

a GridView control

property, and specify any data to pass to the form as query string param-

 

 

eters in the DataNavigateUrlFields property.

 

 

In the destination form, retrieve any query string parameters by accessing

 

 

the QueryString collection of the Request property of the Web form.

 

 

Bind a GridView control to a

Set the DataSource property of the GridView control to the data source. Set

data source at run time

the DataField property of any boundfield columns in the GridView to the

name of the property holding the data to be displayed in the data source.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]