<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Paul Johnson's Technology Musings : CSS</title><link>http://blogs.msdn.com/pajohn/archive/tags/CSS/default.aspx</link><description>Tags: CSS</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Web Widgets with .Net : Part Two</title><link>http://blogs.msdn.com/pajohn/archive/2008/06/25/web-widgets-with-net-part-two.aspx</link><pubDate>Thu, 26 Jun 2008 00:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8653418</guid><dc:creator>pajohn</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/pajohn/comments/8653418.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pajohn/commentrss.aspx?PostID=8653418</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Introduction&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;This is a continuation of an article about Web Widgets posted previously &lt;A href="http://blogs.msdn.com/pajohn/archive/2008/06/18/web-widgets-with-net-part-one.aspx" mce_href="http://blogs.msdn.com/pajohn/archive/2008/06/18/web-widgets-with-net-part-one.aspx"&gt;here&lt;/A&gt;.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;This article builds upon concepts learned in the first article, so if you haven’t read it, I recommend you start there. It walked through the basic steps to create an HttpHandler to output JavaScript. Here, I will continue with that concept and build upon it by making a dynamic, data-driven, Web Widget.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;The full working VS project with code examples for this article can be downloaded here: &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;A href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=webwidgetsdotnet&amp;amp;DownloadId=2331"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=webwidgetsdotnet&amp;amp;DownloadId=2331&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The Base project to start with this in this article can be downloaded here:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;A href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=webwidgetsdotnet&amp;amp;DownloadId=2407"&gt;&lt;FONT size=3 face=Calibri&gt;http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=webwidgetsdotnet&amp;amp;DownloadId=2407&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Events Widget Background&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The purpose of the widget we are going to build is to display Developer and IT Pro Events from a data store. The events will be displayed as a list of hyperlinks that will take the user to more details about each event. This is similar to a web widget my group, STO (Server and Tools Online) built for MSDN and TechNet in 2007. This widget displayed events (Live Events, Webcasts, etc) for Developers and IT Pros, targeted towards their interests. The widget has since been replaced, during the latest upgrades to the sites, but a screenshot is below so you can get an idea. Note, the Data Access Layer used in my demo projects is returning example data.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;A href="http://i283.photobucket.com/albums/kk303/pajohnms/eventswidgetscreenshot3.jpg"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;http://i283.photobucket.com/albums/kk303/pajohnms/eventswidgetscreenshot3.jpg&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Step 1 : Make it Data-Driven&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;If you look in the “Demo2 Start Here” project, you will see some new directories and files have been added since Demo1. First, notice the Data directory which contains two csharp files, DAL.cs and Event.cs. This is a very basic Data Access Layer which we’ll use to get example data to pass to JavaScript. Also notice that Core.js file has several functions added. These functions are used to create various controls, tags, event handlers, and to attach scripts.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo1" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;1)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Open up the “Demo2 Start Here” project and navigate to the files in the Data directory.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l2 level1 lfo1" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;2)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;If you open /Data/Event.cs, you will notice the following attributes in the file:&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.25in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;DataContract&lt;/SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt; attribute applied to the class&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.25in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;DataMember&lt;/SPAN&gt;] &lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;attribute applied to each property in the class&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.25in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;These attributes are what makes this class serializable.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We will be serializing the Event Data to a format that JavaScript can use, called &lt;A href="http://www.json.org/" mce_href="http://www.json.org/"&gt;JSON&lt;/A&gt;. JSON stands for JavaScript Simple Object Notation, and is a simple way to define data structures in JavaScript.&amp;nbsp;&lt;/FONT&gt;&lt;FONT face=Calibri&gt;The DAL.cs file is our Data Access Layer, and simply has one method in it that will return&amp;nbsp;a generic&amp;nbsp;list of example Events.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo1" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;3)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Navigate to /Templates/Core.js and walk through the methods I’ve added here. We will use these methods in /Templates/EventsWidget.js to create controls, attach scripts, and stylesheets.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo1" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;4)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Navigate to /Templates/EventsWidget.js and notice the code that already exists here. I have created an EventsWidget object, and gave it two methods. We will be calling the render method at runtime to render the widget to the page.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l2 level1 lfo1" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;5)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Now to write some code. Open up Handlers/EventsWidget.cs. Add the following line to BuildOutput() method to access the DAL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;List&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;Event&lt;/SPAN&gt;&amp;gt; eventData = &lt;SPAN style="COLOR: #2b91af"&gt;DAL&lt;/SPAN&gt;.GetData(5);&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo1" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;6)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Next, open up Handlers/WidgetBase.cs. Add the following method, which we’ll use to serialize our Data to JSON format.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l2 level1 lfo1" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; COLOR: blue; mso-highlight: silver"&gt;public&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; mso-highlight: silver"&gt; &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; SerializeToJson(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; obj)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt; serializer = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;DataContractJsonSerializer&lt;/SPAN&gt;(obj.GetType());&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;using&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;var&lt;/SPAN&gt; stream = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MemoryStream&lt;/SPAN&gt;())&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;serializer.WriteObject(stream, obj);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Encoding&lt;/SPAN&gt;.Default.GetString(stream.ToArray());&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.25in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.25in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoListParagraphCxSpLast&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;This code uses a great feature of .Net 3.5, the DataContractJsonSerializer, which makes the job of serializing to JSON a snap. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;6)&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Jump back over to EventsWidget.cs. Now we can serialize our data and pass it into the JavaScript template. Add the following lines below your GetData() call in BuildOutput().&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; COLOR: blue; mso-highlight: silver"&gt;string&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; mso-highlight: silver"&gt; eventJsonData = &lt;SPAN style="COLOR: blue"&gt;base&lt;/SPAN&gt;.SerializeToJson(eventData);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; placeholder = &lt;SPAN style="COLOR: #2b91af"&gt;ConfigurationSettings&lt;/SPAN&gt;.AppSettings[&lt;SPAN style="COLOR: #a31515"&gt;"EventDataPlaceholder"&lt;/SPAN&gt;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;output = output.Replace(placeholder, eventJsonData);&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;7)&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Notice the following config setting in web.config. This creates a string that we will use as a placeholder for the data in our JavaScript file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; mso-highlight: silver"&gt;&amp;lt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;add&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt; &lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;key&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;=&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;"&lt;SPAN style="COLOR: blue"&gt;EventDataPlaceholder&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;value&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;=&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;{eventData:placeholder}&lt;/SPAN&gt;"&lt;SPAN style="COLOR: blue"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;8) Open up Templates/EventsWidget.js and add the following line to the constructor. &lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;this&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;.eventData = {eventData:placeholder};&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.25in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;This variable’s value will be replaced at runtime by the code we added in step 6. Then you can see that this variable gets passed into core.createHyperlinkList(), which loops through the data and creates a unordered list of hyperlinks.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;9) Now that we’ve got data passed into our object, we can call the render method to display the widget. Add the following line to /Templates/EventsWidget.js at the very bottom of the file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.25in; MARGIN: 0in 0in 10pt 0.25in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;ev_w.render();&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;10) At this point, you can hit this in a browser. You should see a list of 5 hyperlinks from the event data, but they will be unstyled at this point. Next, I’m going to walk through adding a configuration setting to the querystring and adding a stylesheet.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Step 2 : Make it Configurable&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Now I’m going to give adopters a way to configure the output of the widget on their site. The easiest thing to configure will be the amount of events to display. It seems quite feasible as an option adopters might want. I want them to be able to configure this in the script block they deploy, so the configuration variable will be sent in the querystring. Let’s start by modifying the middle-tier to accept this parameter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; mso-list: l1 level1 lfo2; mso-add-space: auto" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;1)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Open /Handlers/EventsWidget.cs&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l1 level1 lfo2; mso-add-space: auto" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;2)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Add a private member variable to hold the value for top number of events to display. Add the following line to the top of the class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;private&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt; &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; _topN;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l1 level1 lfo2; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;3)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Add the following method to the class to take the parameter out of the querystring and set the member variable we just added.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; COLOR: blue; mso-highlight: silver"&gt;private&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; mso-highlight: silver"&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; GetRequestParameters()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;_topN = 5;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (!&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt;.IsNullOrEmpty(Request.QueryString[&lt;SPAN style="COLOR: #a31515"&gt;"topN"&lt;/SPAN&gt;]))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (!&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt;.TryParse(Request.QueryString[&lt;SPAN style="COLOR: #a31515"&gt;"topN"&lt;/SPAN&gt;], &lt;SPAN style="COLOR: blue"&gt;out&lt;/SPAN&gt; _topN))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;_topN = 5;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l1 level1 lfo2; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;4)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Reference the method we just added and change the hard-coded 5 value in GetData(5) to GetData(_topN). On the first line of BuildOutput(), add the following line.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;GetRequestParameters();&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l1 level1 lfo2; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;5)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Last, let’s add the parameter to the querystring in the script block. I’m going to change the value to 3, so we can tell it’s different from the previous 5 we were displaying.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; COLOR: blue; mso-highlight: silver"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; COLOR: #a31515; mso-highlight: silver"&gt;script&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; mso-highlight: silver"&gt; &lt;SPAN style="COLOR: red"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="text/javascript"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;src&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="eventswidget.jss?topN=3"&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #a31515"&gt;script&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l1 level1 lfo2; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;6)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Now, hit the widget again in a browser. You should now see 3 events listed (or whatever number you pass in).&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l1 level1 lfo2; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;IMG style="WIDTH: 480px" src="http://i283.photobucket.com/albums/kk303/pajohnms/3eventsSS.jpg" width=480 mce_src="http://i283.photobucket.com/albums/kk303/pajohnms/3eventsSS.jpg"&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;BR style="PAGE-BREAK-BEFORE: always; mso-special-character: line-break" clear=all&gt;&lt;/P&gt;&lt;/SPAN&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Step 3 : Make It Pretty with CSS&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Now, we’re going to attach a StyleSheet so that it looks a little better. You probably noticed I’ve been adding CSS class names on several elements in the JavaScript code. There is a stylesheet in the project that contains those classes, and now we’ll hook that up. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;One important thing to note;&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt; when attaching objects such as other scripts, stylesheets, images, etc, you need to use the absolute path to those objects, since they are going to live on your host server. I have created a way to pass in a path from the middle-tier to the client-side tier, so that this doesn’t have to be configured separately for different deployments.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l0 level1 lfo3; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;1)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Add the widget path data in the middle tier. Open /Handlers/WidgetBase.cs and add the following to the ProcessRequest method. This will replace a placeholder value in core.js to give us the application path on our server.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; COLOR: blue; mso-highlight: silver"&gt;string&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; mso-highlight: silver"&gt; widgetPathPlaceholder = &lt;SPAN style="COLOR: #2b91af"&gt;ConfigurationSettings&lt;/SPAN&gt;.AppSettings[&lt;SPAN style="COLOR: #a31515"&gt;"WidgetPathPlaceholder"&lt;/SPAN&gt;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (output.IndexOf(widgetPathPlaceholder, 0) &amp;gt; -1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;output = output.Replace(widgetPathPlaceholder, Request.Url.GetLeftPart(&lt;SPAN style="COLOR: #2b91af"&gt;UriPartial&lt;/SPAN&gt;.Authority) + &lt;SPAN style="COLOR: #2b91af"&gt;HttpRuntime&lt;/SPAN&gt;.AppDomainAppVirtualPath);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l0 level1 lfo3; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;2)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Open /Templates/Core.js and add the following line to the constructor.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; COLOR: blue; mso-highlight: silver"&gt;this&lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: silver; mso-highlight: silver"&gt;.widgetPath = &lt;SPAN style="COLOR: #a31515"&gt;'{widgetPath:placeholder}'&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Now, we have a widgetPath property we can use in any widget for attaching scripts, stylesheets, etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l0 level1 lfo3; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;3)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Open /Templates/EventsWidget.js and add the following line inside the render method.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; BACKGROUND: silver; FONT-SIZE: 10pt; mso-no-proof: yes; mso-highlight: silver"&gt;core.attachStyleSheet(core.widgetPath + &lt;SPAN style="COLOR: #a31515"&gt;'/styles/main.css'&lt;/SPAN&gt;, &lt;SPAN style="COLOR: #a31515"&gt;'eventsStyle'&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;This will call the attachStylesheet method in our Core object and pass in the widgetpath parameter we created. This method adds our stylesheet into the head element of the adopters HTML page.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l0 level1 lfo3; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT face=Calibri&gt;4)&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;View your widget in a browser. The classes from the stylesheet should be applied and it should have a more appealing look and feel.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l0 level1 lfo3; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;&lt;IMG style="WIDTH: 480px" border=0 src="http://i283.photobucket.com/albums/kk303/pajohnms/3eventsSSwStyles.jpg" width=480 mce_src="http://i283.photobucket.com/albums/kk303/pajohnms/3eventsSSwStyles.jpg"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.75in; mso-list: l0 level1 lfo3; mso-add-space: auto" class=MsoListParagraph&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Note; an adopter now has a default style for the widget, but with CSS they would also have the freedom to modify the style by creating more specific styles for these elements.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 12pt"&gt;&lt;FONT face=Calibri&gt;Now you have learned a way to create a web widget, using C# middle-tier, and JavaScript client-tier. This useful approach allows rich and easy content syndication that you can now put to use. It is a very powerful technique, and is also fun to build. I personally really enjoy working on a project that encompasses this many techniques, languages and technologies. It keeps development interesting and makes it fun. Enjoy.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8653418" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pajohn/archive/tags/web+widgets/default.aspx">web widgets</category><category domain="http://blogs.msdn.com/pajohn/archive/tags/tech+ed/default.aspx">tech ed</category><category domain="http://blogs.msdn.com/pajohn/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://blogs.msdn.com/pajohn/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/pajohn/archive/tags/.Net/default.aspx">.Net</category><category domain="http://blogs.msdn.com/pajohn/archive/tags/JSON/default.aspx">JSON</category><category domain="http://blogs.msdn.com/pajohn/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://blogs.msdn.com/pajohn/archive/tags/httphandler/default.aspx">httphandler</category><category domain="http://blogs.msdn.com/pajohn/archive/tags/csharp/default.aspx">csharp</category><category domain="http://blogs.msdn.com/pajohn/archive/tags/CSS/default.aspx">CSS</category></item></channel></rss>