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.

360 x CHAPTER 10 <strong>ASP</strong>.<strong>NET</strong> AJAX<br />

8. Copy the exact same rule <strong>in</strong>to the DarkGrey.css file for the DarkGrey theme.<br />

9. Switch back to the ContactForm.ascx user control <strong>and</strong> below the clos<strong>in</strong>g tag of the UpdatePanel<br />

at the end of the file, drag an UpdateProgress control from the AJAX Extensions category of the<br />

Toolbox. Set its AssociatedUpdatePanelID to UpdatePanel1, the ID of the UpdatePanel def<strong>in</strong>ed<br />

earlier <strong>in</strong> the page.<br />

10. Between the tags create a element, <strong>and</strong> with<strong>in</strong> this template,<br />

create a element with its class attribute set to PleaseWait, the CSS class you created<br />

<strong>in</strong> step 7. Inside the element, type some text to <strong>in</strong>form your users that they should hold on<br />

for a while. You should end up with this code:<br />

<br />

<br />

<br />

<br />

Please Wait...<br />

<br />

<br />

<br />

11. To emulate a long delay while send<strong>in</strong>g out the message so you can see the UpdateProgress control,<br />

add the follow<strong>in</strong>g l<strong>in</strong>e of code to the Code Beh<strong>in</strong>d of the control, just after the l<strong>in</strong>es that<br />

change the visibility of the controls <strong>in</strong> the method that sends out the e-mail:<br />

<strong>VB</strong>.<strong>NET</strong><br />

Message.Visible = True<br />

FormTable.Visible = False<br />

System.Thread<strong>in</strong>g.Thread.Sleep(5000)<br />

C#<br />

Message.Visible = true;<br />

FormTable.Visible = false;<br />

System.Thread<strong>in</strong>g.Thread.Sleep(5000);<br />

12. Save all your changes <strong>and</strong> open the Contact.aspx page from the About folder once aga<strong>in</strong>. Fill <strong>in</strong><br />

the required details <strong>and</strong> click the Send button. Shortly after you click the button, you should see the<br />

UpdateProgress control appear that displays text <strong>and</strong> an animated image below the form, shown<br />

<strong>in</strong> Figure 10-4. Shortly after that, the UpdateProgress control <strong>and</strong> the entire form should disappear<br />

<strong>and</strong> you should be presented with the Message Sent text.<br />

COMMON MISTAKES If you don’t see the described behavior, your browser<br />

may be work<strong>in</strong>g with an outdated version of the CSS fi les. Press Ctrl+F5 or<br />

Ctrl+R to get the latest version from the server <strong>and</strong> try aga<strong>in</strong>. Alternatively, you<br />

can clear the browser’s cache.

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

Saved successfully!

Ooh no, something went wrong!