16.01.2013 Views

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 35: Building Applications Using Windows SharePoint Services Data 973<br />

complicated because of several factors, including security, access to style sheets, image<br />

objects, <strong>and</strong> so on. In addition, to use a Web Part within the confines of an ASP.NET site<br />

requires Windows SharePoint Services extensions to be installed on that site.<br />

As is usually the case, <strong>and</strong> as it is with our example, our Windows SharePoint Services<br />

site <strong>and</strong> ASP.NET sites are completely isolated from one another. The general<br />

assumption is that to provide security, the ASP.NET site users should have zero access to<br />

the Windows SharePoint Services site or its objects. Although we have both sites on the<br />

same machine, using TCP/IP, these two sites could be in London <strong>and</strong> New York City.<br />

To accomplish our goal of displaying the data from an internal Windows Share-<br />

Point Services site to an external ASP.NET site, we will use a direct connection to the<br />

Windows SharePoint Services database <strong>and</strong> use a DataList control in ASP.NET to display<br />

the data directly from the database table.<br />

Getting to the data is the first requirement, <strong>and</strong> the key to this is accessing the<br />

GUID for the list, as we did in the previous section. This key enables us to pull the<br />

data from SQL Server to use it as we need to in the ASP.NET page.<br />

Updating the Home Page In our example, we left our ASP.NET site with a single<br />

page named Default.aspx <strong>and</strong> referred to it as the home page. We added a single<br />

image to it to test the site <strong>and</strong> make sure it was operational.<br />

For the next steps <strong>and</strong> to keep the example simple, we are going to add our<br />

functionality to a new page named ProbSolutionKB.aspx. We’ll add a link to it from<br />

the home page (Default.aspx) so that we can access it for testing. Open Visual Studio<br />

<strong>and</strong> open the project created for the ASP.NET site (in our example, port 383).<br />

In the original setup, we set the Default.aspx page to be the start page of the<br />

project when we run the application. If you have not done this, you should do it<br />

now. In Visual Studio Solution Explorer, right-click Default.aspx <strong>and</strong> select Set As<br />

Start Page from the menu.<br />

To start off, we want to make this example more realistic by making the home<br />

page look a little better. (This is not required.) We’re going to modify the Default.aspx<br />

page (which is the home page for the site) by adding a heading to it using a table <strong>and</strong><br />

adding a new image. We’ll also add a link to the new page to be created.<br />

In Visual Studio, first add the image for the How Cool Version 2 product,<br />

HowCoolV2sm.jpg (or any other image). (You can even keep the CoffeeBean.bmp<br />

we used in the setup if you prefer.) Regardless of how you choose to use Visual<br />

Studio—that is, whether you use the Design mode or code by h<strong>and</strong>—we want to<br />

accomplish the following tasks:<br />

■ Add a background color to the page.<br />

■ Create a main table that will surround the page objects.<br />

■ Create a table within the main table to h<strong>and</strong>le our page layout.<br />

■ Add the image to the page as a heading logo.<br />

■ Add a link to the page to be created.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!