10.02.2014 Views

Beginning Ajax With ASP.NET (2006).pdf

Create successful ePaper yourself

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

Chapter 8<br />

Listing 8-3: (continued)<br />

38. if(prototypeJs.Length > 0)<br />

39. RegisterClientScriptBlock(page, Constant.<strong>Ajax</strong>ID + “.prototype”,<br />

40. “”);<br />

41.<br />

42. if(coreJs.Length > 0)<br />

43. RegisterClientScriptBlock(page, Constant.<strong>Ajax</strong>ID + “.core”,<br />

44. “”);<br />

45.<br />

46. if(convertersJs.Length > 0)<br />

47. RegisterClientScriptBlock(page, Constant.<strong>Ajax</strong>ID + “.converters”,<br />

48. “”);<br />

49.<br />

50.<br />

51. if(Settings.TokenEnabled)<br />

52. {<br />

53. RegisterClientScriptBlock(page, Constant.<strong>Ajax</strong>ID + “.token”,<br />

54. “<strong>Ajax</strong>Pro.token = \”” +<br />

Current<strong>Ajax</strong>Token + “\”;”);<br />

55. }<br />

56. }<br />

Being as flexible as possible, the library allows you to set these property values with additional<br />

Web.Config entries. The only thing you’ve done so far in the Web.Config is to wire up the <strong>Ajax</strong> Pro<br />

page handler. The library has defined a custom section that you can use in your Web.Config. This is<br />

processed by the <strong>Ajax</strong>Pro.<strong>Ajax</strong>SettingsSectionHandler, found in the /Configuration/<br />

<strong>Ajax</strong>SettingsSectionHandler.cs file.<br />

Try It Out<br />

Adding Custom Sections to Your Web.Config File<br />

Fortunately, <strong>ASP</strong>.<strong>NET</strong> has framework calls that make it really easy to add custom sections to your<br />

Web.Config file. Listing 8-4 shows a sample entry in your Web.Config to override the several default<br />

property and actions of the <strong>Ajax</strong>.<strong>NET</strong> Pro library. Listing 8-5 shows how the library reads those overridden<br />

values.<br />

Listing 8-4: Web.Config configSections Sample<br />

<br />

...<br />

01. <br />

02. <br />

03. <br />

06. <br />

07. <br />

08.<br />

186

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

Saved successfully!

Ooh no, something went wrong!