03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

Create successful ePaper yourself

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

616 x CHAPTER 16 SECURITY IN YOUR <strong>ASP</strong>.<strong>NET</strong> <strong>4.5</strong> WEBSITE<br />

Any content you put <strong>in</strong> the control is placed <strong>in</strong> the<br />

AnonymousTemplate area, because that is now the<br />

active template for the control <strong>in</strong> Design View.<br />

3. Click the Log<strong>in</strong> control once to select it <strong>and</strong> then press<br />

Ctrl+X to cut it to the clipboard. Click <strong>in</strong>side the small<br />

white rectangle that represents the Log<strong>in</strong>View to position<br />

your cursor <strong>in</strong> the control, <strong>and</strong> then press Ctrl+V to<br />

paste the Log<strong>in</strong> control <strong>in</strong>to your Log<strong>in</strong>View.<br />

4. Open the Smart Tasks panel of the Log<strong>in</strong>View aga<strong>in</strong><br />

<strong>and</strong> switch to the LoggedInTemplate us<strong>in</strong>g the Views<br />

drop-down list. Click <strong>in</strong>side the small white rectangle of<br />

the control aga<strong>in</strong> <strong>and</strong> type the text You are already<br />

logged <strong>in</strong>.<br />

FIGURE 16-9<br />

5. Switch to Markup View <strong>and</strong> look at the code. The Log<strong>in</strong> control should be placed <strong>in</strong>side the<br />

AnonymousTemplate, <strong>and</strong> the text you typed should be displayed with<strong>in</strong> the LoggedInTemplate<br />

tags:<br />

<br />

<br />

<br />

<br />

<br />

<br />

You are already logged <strong>in</strong>.<br />

<br />

<br />

6. Save <strong>and</strong> close the page because you’re done with it for now.<br />

7. Open the master page Frontend.master <strong>in</strong> Markup View <strong>and</strong> locate the element at the<br />

bottom of the page. Remove the text Footer Goes Here <strong>and</strong> replace it with a new Log<strong>in</strong>Name<br />

control by dragg<strong>in</strong>g it from the Toolbox <strong>in</strong>to the element. Set its FormatStr<strong>in</strong>g property<br />

to Logged <strong>in</strong> as {0} by typ<strong>in</strong>g <strong>in</strong> the code directly:<br />

<br />

8. From the Toolbox, drag a new Log<strong>in</strong>View control <strong>and</strong> drop it below the Log<strong>in</strong>Name control,<br />

but still <strong>in</strong> the element. Switch to Design View, <strong>and</strong> on the Smart Tasks panel of the<br />

Log<strong>in</strong>View, choose LoggedInTemplate from the Views drop-down list. Then <strong>in</strong> the white rectangle<br />

for the active LoggedInTemplate, drag <strong>and</strong> drop a new Log<strong>in</strong>Status control.<br />

9. Switch to Markup View aga<strong>in</strong> <strong>and</strong> wrap the code for the Log<strong>in</strong>Status <strong>in</strong> a pair of parentheses.<br />

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

<br />

<br />

<br />

<br />

()

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

Saved successfully!

Ooh no, something went wrong!