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.

Introduction to User Controls x 289<br />

when the image cannot be displayed correctly. Some older browsers show the alternate text as the<br />

tooltip for the image when you hover your mouse over it.<br />

9. Switch to Markup View <strong>and</strong> if your Panel control has Height <strong>and</strong> Width attributes that were<br />

added by default when you dragged it on the page, remove both of them.<br />

10. Wrap the Image <strong>in</strong> a st<strong>and</strong>ard element <strong>and</strong> set its href attribute<br />

to http://p2p.wrox.com. If you want, you can use the a code snippet<br />

to <strong>in</strong>sert the bare l<strong>in</strong>k for you. To do this, type the letter a <strong>and</strong><br />

then press Tab. VS <strong>in</strong>serts a l<strong>in</strong>k for you <strong>and</strong> enables you to type <strong>in</strong><br />

the href value directly. When you then press Tab aga<strong>in</strong>, the content<br />

of the l<strong>in</strong>k is selected, which you can delete by press<strong>in</strong>g Del (the<br />

Image control will be the contents of the l<strong>in</strong>k). F<strong>in</strong>ally, cut the clos<strong>in</strong>g<br />

tag <strong>and</strong> move it to after the image.<br />

FIGURE 8-3<br />

FIGURE 8-4<br />

11. Set the target of the anchor tag () to _blank to force the browser to open up the page <strong>in</strong> a<br />

new w<strong>in</strong>dow when the image is clicked. When you’re done, the code for the entire user control<br />

should look like the follow<strong>in</strong>g code, except for the Language attribute that you may have set to <strong>VB</strong><br />

<strong>and</strong> the AutoEventWireup that is False by default <strong>in</strong> <strong>VB</strong>.<strong>NET</strong>:<br />

<br />

<br />

<br />

<br />

<br />

<br />

12. Save the changes by press<strong>in</strong>g Ctrl+S <strong>and</strong> then close the user control file by press<strong>in</strong>g Ctrl+F4.

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

Saved successfully!

Ooh no, something went wrong!