03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

560 x CHAPTER 15 WORKING WITH DATA — ADVANCED TOPICS<br />

2. Right-click this new folder <strong>and</strong> choose Add Í Add New Item.<br />

Add a sk<strong>in</strong> file called GridView.sk<strong>in</strong>. You should end up with a<br />

Solution Explorer look<strong>in</strong>g like Figure 15-5.<br />

3. Open the Genres.aspx page <strong>in</strong> Markup View <strong>and</strong><br />

delete all the style elements you created <strong>in</strong> the previous<br />

exercise except the HeaderStyle, the PagerStyle,<br />

the SortedAscend<strong>in</strong>gHeaderStyle, <strong>and</strong> the<br />

SortedDescend<strong>in</strong>gHeaderStyle. From the four rema<strong>in</strong><strong>in</strong>g styles,<br />

remove all attributes <strong>and</strong> replace them with a s<strong>in</strong>gle CssClass<br />

attribute named after the style <strong>and</strong> prefixed with GridView. You<br />

should end up with the follow<strong>in</strong>g styles:<br />

<br />

FIGURE 15-5<br />

<br />

<br />

<br />

Don’t worry if VS adds red error l<strong>in</strong>es under the CSS class names. Because the CSS classes aren’t<br />

def<strong>in</strong>ed yet, it can’t f<strong>in</strong>d them. Later, you add them to the theme’s CSS file, where VS still can’t<br />

f<strong>in</strong>d them. They’ll work f<strong>in</strong>e at run time, though, so don’t worry.<br />

4. Select the styles <strong>in</strong> the code editor <strong>and</strong> then cut them to the clipboard us<strong>in</strong>g Ctrl+X. Switch to the<br />

GridView.sk<strong>in</strong> file, delete all exist<strong>in</strong>g code (the comment text you saw earlier), <strong>and</strong> paste the<br />

styles <strong>in</strong>to the sk<strong>in</strong> file.<br />

5. Wrap the styles <strong>in</strong> an element with its runat attribute set to server <strong>and</strong> its<br />

CssClass attribute set to GridView. Don’t add an ID attribute, because sk<strong>in</strong> files don’t need this.<br />

You should end up with this code:<br />

<br />

... styles go here<br />

<br />

6. Open the resources folder for this chapter (located at C:\<br />

Beg<strong>ASP</strong><strong>NET</strong>\Resources\Chapter 15 if you followed the <strong>in</strong>structions<br />

<strong>in</strong> the Introduction section of this book) <strong>in</strong> File Explorer<br />

(W<strong>in</strong>dows Explorer <strong>in</strong> W<strong>in</strong>dows 7), select the Images folder <strong>and</strong><br />

the Management.css file, <strong>and</strong> press Ctrl+C to copy them. Switch<br />

back to VS, click the Management folder under App_Themes, <strong>and</strong><br />

press Ctrl+V. Just as the other two themes do, the management<br />

theme now has its own style sheet <strong>and</strong> Images folder, shown <strong>in</strong><br />

Figure 15-6.<br />

The two images are used to change the header for sorted columns<br />

<strong>in</strong> the GridView, as you will see later.<br />

FIGURE 15-6<br />

7. Open the Web.config file for the Management folder <strong>in</strong> the root that you added earlier <strong>and</strong> set the<br />

theme to Management:<br />

<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!