Navigation

Search

Categories

On this page

Awesomeness, in a box.
Rendering difference between Firefox and IE when using innerHTML
Off to Redmond
Playing with IE8: Reports Module as a WebSlice
Developing an RSS Data Source - Part III
Developing an RSS Data Source - Part II
Developing an RSS Data Source - Part I
Just signed my offer letter

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 22
This Year: 13
This Month: 0
This Week: 0
Comments: 4

Sign In
Pick a theme:

 Saturday, August 23, 2008
Saturday, August 23, 2008 1:06:00 AM (GMT Standard Time, UTC+00:00) ( Microsoft Internship | MVC )
Well, its been a fun summer, but my time at Microsoft is over ...


... for now :).  It looks like I'll be coming back full-time come next August, so it's a bittersweet end.  I'll miss the people on my team and the interns I've met, but in most cases I'll see them again next year!  Keep an eye on this blog, because you can bet I'll be posting when the stuff I worked on goes live!

Comments [0] | | # 
 Tuesday, August 19, 2008
Tuesday, August 19, 2008 5:30:23 PM (GMT Standard Time, UTC+00:00) ( Microsoft Internship | Random Stuff )

Thanks to Alex Tuteur for typing up the lyrics from our scribbles on paper, to Kyle Farnung for filiming, converting and posting the video, to Kristine Johnson for singing the epic win-ness, and to all the people who helped write the song!

STILL AROUND
By Andrew Nurse, Kristine Johnson, Alex Tuteur, Ben Butler, Kyle Farnung, Steven Truong (EXP), Adam Kiu, and William Hong

Internz: a triumph
I’m sending a lolcat: EPIC FAIL
It’s hard to understate procrastination
MICROSOFT INTERNS
We do nothing but read mail all day
For the good of all of us
Except for the FTEs
But there’s no sense crying over broken compiles
You just keep on building, it’ll work in awhile
And the coding gets done
And you make a bad pun
For the interns who are
STILL AROUND

I’m not really working
I’m reading Internz all day long
Even though I didn’t meet commitments
And now it’s review time
And it is my future on the line
As I leave it sucks because
I was so happy right here
Now it’s time to leave and I am packing my bag
To go back to my school and deal with the jet lag
So I’m GLaD that I’ve turned
Think of all the cash we’ve earned
As the interns who are
STILL AROUND

I’m going to leave now
I guess you prefer to stay right here
Maybe I’ll find someone else to work for
Maybe at Google
THAT WAS A JOKE, HAHA, FAT CHANCE
Anyway this lolcat’s great
It’s so amusing and fun
Look at me still coding when there’s packing to do
When I look out there it makes me GLaD I’m not you
I’ve got all my boxes done
Now it’s time for me to run
Bye bye interns who are
STILL AROUND

I can’t believe you are all
STILL AROUND
I’m done with coding and you’re
STILL AROUND
I’m leaving now and you are
STILL AROUND
While I’m at school you’ll be
STILL AROUND
And when I’m back here you’ll be
STILL AROUND
STILL AROUND
STILL AROUND
Comments [3] | | # 
 Saturday, August 16, 2008
Saturday, August 16, 2008 12:54:35 AM (GMT Standard Time, UTC+00:00) ( JavaScript | Microsoft Internship )
I know, its been a while since I've blogged, but I'm just so busy with my Microsoft internship its been hard to find time. Anyway, on to the post...

I've been doing quite a bit of JavaScript work recently and I discovered an interesting inconsistency between Firefox and IE when it comes to the innerHTML project. Federico, from the ASP.Net QA team blog, posted the details on that blog, but here's a quick summary.

Basically, it comes down to when the browsers perform whitespace normalization. In HTML, multiple whitespace (space, tab, newline etc.) characters are treated as a single space. Also, whitespace at the beginning of "block" elements (which are elements like DIV which have newlines before them) is removed. In Firefox, the whitespace is preserved exactly as typed when stored in Firefox's internal structures. When the HTML is rendered out, Firefox performs the normalization on the fly. However, in IE, the whitespace is normalized before the internal structures are built.

The result of this is that the contents of the innerHTML property for a DOM element can vary between these two browsers.

Check out the blog post for more details.

Comments [0] | | # 
 Monday, May 05, 2008
Monday, May 05, 2008 4:32:52 PM (GMT Standard Time, UTC+00:00) ( )
Phew, I've been posting a lot of forum posts and blogs today trying to tidy up loose ends, because I'm off to Redmond today! I'll be going back to Microsoft for another summer internship, and I'm really excited!

I'll try to post more later in the week (because I really have to shutdown my computer and pack it up now :P) so keep an eye here, and on my Twitter feed: http://twitter.com/anurse (follow me?).

Comments [0] | | # 
 Thursday, March 06, 2008
Thursday, March 06, 2008 7:51:51 PM (GMT Standard Time, UTC+00:00) ( DNN | Reports Module )

So, I downloaded and installed the IE8 Beta yesterday and decided to play around with WebSlices. I found it really easy to create a simple WebSlice (just apply some CSS Classes) and I decided to try and do this with the Reports Module.

I was suprised with just how easy it was! I have already created a replacement ViewReports.ascx file that turns every Reports Module into a WebSlice. I've attached the new file here, just replace your existing DesktopModules/Reports/ViewReports.ascx file with it if you want to check it out. Any Visualizer should work, but I've only tried the Grid.

CAUTION: This is for preview purposes ONLY! This replacement file has NOT been tested in ANY SIGNIFICANT WAY (other than trying it out once). Back up your existing ViewReports.ascx file BEFORE using this!

Here's the popup you see when you view a report

And here's a screenshot of the WebSlice in action:

Anyway, the file is attached. Try it out on one of your test sites! I'll probably integrate this into an upcoming version in a more configurable way, since it's so easy :).

ViewReports.zip (.54 KB)

UPDATE: Changed to a ZIP file

Comments [1] | | # 
 Sunday, March 02, 2008
Sunday, March 02, 2008 5:23:00 PM (GMT Standard Time, UTC+00:00) ( DNN | Reports Module )

In this series of blogs, I'm going to follow the development of an RSS Data Source. I'm going to use Visual Studio 2008, but I'll be using .Net 2.0 features so you should be able to follow along in Visual Studio 2005. You can also use the Express editions of Visual Web Developer (both 2005 and 2008 versions should work). All the code will be in VB.Net, but it should be straightforward enough for C# developers to understand (after all, its all .Net)

Continued from Part II.

Part III - Settings

In this part, we're going to add a setting page so that we can change the RSS feed that our Data Source downloads.

In current versions of the Reports Module, Data Source settings are stored in the ModuleSettings table provided by DotNetNuke. This ensures that all copies of the same module instance will share the same Data Source settings (Visualizer settings are not shared between copies). However, Data Source developers need not (and should not) access these directly. Instead, the Reports Module provides a layer on top of the ModuleSettings table called "Data Source Settings". When the Data Source is executed, the Reports Module passes a Dictionary containing these settings (inside the ReportInfo object). To allow users to edit the settings, we go back to the Settings.ascx file we created in Part I.

Let's start with the user interface for our settings page. All we need for now is a place for the user to enter a feed URL. When we're done, it should look like the screenshot below

The finished settings UI

Figure 1 - The finished settings UI

So, open up the Settings.ascx file and make sure you are in Design mode. First we need to add a label, so users know what they should type in our text box. In the Solution Explorer, find the file: controls/labelcontrol.ascx and drag it on to the design surface.

Locating the LabelControl.ascx file

Figure 2 - Locating the LabelControl.ascx file

Next drag an ASP.Net TextBox control, from the Toolbox, on to the surface. You should have something that looks like this:

Locating the LabelControl.ascx file

Figure 3 - Locating the LabelControl.ascx file

Now, set the properties of the controls to the following values:

Property Value for Label Value for Text Box
ID feedUrlLabel feedUrlTextBox
ControlName feedUrlTextBox N/A
Width N/A 100%

Save your changes, and open up the code file: Settings.ascx.vb. Here, we need to add code to connect our text box to the Data Source settings. The key to this is the LoadSettings and SaveSettings methods provided by ReportsSettingsBase. First, we need to import some extra namespaces:

Imports DotNetNuke.Modules.Reports

Imports System.Collections.Generic

Then, we can implement the LoadSettings and SaveSettings methods.

Public Overrides Sub LoadSettings(ByVal Settings As Dictionary(Of String, String))

    MyBase.LoadSettings(Settings)

    feedUrlTextBox.Text = SettingsUtil.GetDictionarySetting(Settings, _

                                                            "FeedUrl", _

                                                            String.Empty)

End Sub

 

Public Overrides Sub SaveSettings(ByVal Settings As Dictionary(Of String, String))

    MyBase.SaveSettings(Settings)

    Settings("FeedUrl") = feedUrlTextBox.Text

End Sub

The LoadSettings method is provided with a System.Collections.Generic.Dictionary(Of String, String) containing the current settings saved for the Data Source. Our implementation uses the SettingsUtil helper class (provided with the Reports Module) to retrieve a value from the dictionary, or return a default value if it doesn't exist (in this case, an empty string).

The SaveSettings method is also provided with the current settings. However, this method is responsible for retrieving the values entered by the user and updating the settings.

Save the file, and navigate to the Settings page on your test module. You should see our new Settings control displayed, as in the screenshot below:

Settings page so far

Figure 4 - Settings page so far

Oops, we still need to put the label text in! We're going to support the DotNetNuke Localization Framework, so we need to put the text in two places.

First, lets add the localized text. Create a Resource File called Settings.ascx.resx in /DesktopModules/Reports/DataSources/RSS/App_LocalResources file and open it. In Visual Studio, you get a nice table interface for editing resource strings. Add the following entries to the table (feel free to tweak the values as you want, just keep the name the same):

Name Value
feedUrlLabel.Text RSS Feed URL
feedUrlLabel.Help Enter the URL to an RSS feed to retrieve data from

Your resource file should look like this after making those changes

Resource File after entering values

Figure 5 - Resource File after entering values

Now, go back to Settings.ascx and set the following properties on the label we created earlier:

Property Value
Text RSS Feed URL
Suffix :
CssClass SubHead

Note: That's a colon (':') in the Suffix property. Also, CssClass is case sensitive.

Now, save and refresh your page. You should see something like the screen shot below:

Finished Settings UI

Figure 6 - The finished Feed URL text box

Now, to change our Data Source code to use this new setting. Let's go back to the /App_Code/RSSDataSource/RSSDataSource.vb file and take a look at the signature for the ExecuteReport method:

Public Overrides Function ExecuteReport(ByVal report As ReportInfo, _

                                        ByVal hostModule As PortalModuleBase, _

                                        ByVal inputParameters As IDictionary(Of String, Object)) As System.Data.DataView

The important parameter here is the report parameter. There is a property called DataSourceSettings on that object which contains the same dictionary we created in SaveSettings. First, delete the FeedUrl constant we were using before. Then add following code to the beginning of the ExecuteReport method to get the Feed URL from the settings:

If Not report.DataSourceSettings.ContainsKey("FeedUrl") Then

    Throw New RequiredSettingMissingException("FeedUrl", MyBase.ExtensionContext)

End If

Dim feedUrl As Uri = Nothing

If Not Uri.TryCreate(report.DataSourceSettings("FeedUrl"), UriKind.Absolute, feedUrl) Then

    Throw New RequiredSettingMissingException("FeedUrl", MyBase.ExtensionContext)

End If

This code checks for the setting, and if it isn't present or if it isn't a valid URL we throw an exception provided by the Reports Module: RequiredSettingMissingException. We pass it the name of our setting and some contextual information about our Data Source (which is provided automatically by our base class. If the setting isn't present, the Reports Module will automatically display a useful error message indicating that the setting is missing.

While we're in the code, let's add HTML Decoding directly to the Data Source, so we don't have to use the HTML Decode converter in the Module Settings. To do that, we change the line that adds entries to the output table so that it automatically HTML Decodes the description:

dt.Rows.Add(title, New Uri(link), HttpUtility.HtmlDecode(description))

Make sure everything is saved and go back to the website. You should probably go back to the home page, just to make sure everything is properly recompiled. Go back to the settings page for the Reports Module, and make sure the RSS Data Source is selected. Then configure it with your favourite RSS feed. This time, I'll use my personal blog's RSS feed (WARNING: Shameless plug alert!).

Testing the Settings UI

Figure 7 - Testing the Settings UI

Once you've done that, make sure the HTML Decode property is set and the HTML Visualizer is properly configured, just like in part 2 and click Update. You should see the RSS feed displayed just like in Part 2, only now we can change the URL!

Final Results

Figure 8 - The Final Results

Conclusion

At this point, we have a working RSS Data Source! You can stop here if you want, but in the next part I'll cover packaging the Data Source up so that it can be installed in any Reports Module installation.

Download the code so far.

Comments [0] | | # 
 Friday, February 29, 2008
Friday, February 29, 2008 8:30:07 PM (GMT Standard Time, UTC+00:00) ( DNN | Reports Module )

UPDATE: Part III is now available.

In this series of blogs, I'm going to follow the development of an RSS Data Source. I'm going to use Visual Studio 2008, but I'll be using .Net 2.0 features so you should be able to follow along in Visual Studio 2005. You can also use the Express editions of Visual Web Developer (both 2005 and 2008 versions should work). All the code will be in VB.Net, but it should be straightforward enough for C# developers to understand (after all, its all .Net)

Continued from Part I.

Part II - WebRequests, XPath, and Data Tables, oh my!

In this part, we're going to add the code to retrieve data from the RSS feed. First, we need to create a folder to hold our code. We're going to put our code in the App_Code folder, so it will be compiled automatically by ASP.Net. That way we can save a few extra steps and get straight to the point. You could also put this code in a separate .Net Class Library, and put that library in the Bin folder of your website.

We'll create a sub-folder inside the App_Code folder for our code and call it RSSDataSource:

Creating an App_Code folder

Figure 1 - Creating an App_Code folder

Next, we need to tell ASP.Net to compile code found in this folder. Open the web.config file, in the root of the website, and find the <codeSubDirectories> section (its inside the <system.web> section). In my version of DotNetNuke it looks like this, but yours may have different <add> entries:

<codeSubDirectories>

  <add directoryName="HTML" />

</codeSubDirectories>

We need to add an entry to this list for our new subfolder. On my system, it looks like this (again, yours may vary slightly):

<codeSubDirectories>

  <add directoryName="HTML" />

  <add directoryName="RSSDataSource"/>

</codeSubDirectories>

Now that we have somewhere to put our code, let's create our Data Source! We'll create a class inside our nice new App_Code folder called RSSDataSource.

I'm not going to list the code for the Data Source in this post, because I've attached it to this post. However, I'll go over the general steps.

  1. First, we use the System.Net.WebClient class to download the RSS feed. For now, I've hardcoded it to one of my favourite blogs: Scott Hanselman's Computer Zen
  2. Next we create an ADO.Net DataTable with three columns: Title, Link and Description
  3. Then, we use the classes in the System.Xml.XPath namespace to add a row for each item in the feed to the DataTable.
  4. Finally, we wrap the DataTable in a DataView. The Reports Module expects us to return a DataView in order to allow us to do filtering and sorting if we wanted to. We aren't using that feature, so we just create a simple DataView to wrap our table.

There's only one last step to hook everything up. We need to tell the Reports Module how to find our Data Source code. To do that, open the code-behind file for DesktopModules/Reports/DataSources/RSS/Settings.ascx and change the DataSourceClass property to the following code:

Public ReadOnly Property DataSourceClass() As String Implements IDataSourceSettingsControl.DataSourceClass

    Get

        Return GetType(RSSDataSource).FullName

    End Get

End Property

And with that, we have a working RSS Data Source! Go back to your browser and go to the Settings page for the Reports Module instance we created in Part 1. Select the RSS Data Source as the Active Data Source, and click update. You should see a very wide grid containing the data from the RSS feed (assuming you are using the Grid Visualizer, which is the default):

Simple Grid View

Figure 2 - Simple Grid View

Well, that doesn't look very useful does it? Let's start by getting rid of that HTML junk in the Description field. To get rid of that, go back to the Settings page, and add "Description" to the list of columns to HTML Decode.

HTML Decode Converter

Figure 3 - HTML Decode Converter

That should clean up the HTML, but it's still a big grid. Let's use the HTML Visualizer to clean it up a bit. Put the following code in an HTML file and place it in your Portals/[PortalID] folder:

<h1><a href="[Link]">[Title]</a></h1>

[Description]

<hr />

Then, go back to the Settings page, select the HTML Template Visualizer and the HTML file you just uploaded:

Configuring the HTML Visualizer

Figure 4 - Configuring the HTML Visualizer

Click Update and you should see a much more readable display. It's almost like a real RSS Reader!

A Reports Module-powered RSS Reader?

Figure 5 - A Reports Module-powered RSS Reader!

Conclusion

Well, that's all for part two. Next, we'll cover Data Source settings so that we can point our Data Source at any RSS feed we want, rather than hard coding it. Then, we add an HTML Decoding feature directly into the Data Source so we don't have to configure the module to decode the Description field. Finally, we'll package it all up so that others can download and install it.

Download the code so far.

Comments [0] | | # 
Friday, February 29, 2008 6:03:39 AM (GMT Standard Time, UTC+00:00) ( DNN | Reports Module )

UPDATE: Part II is now available.

In this series of blogs, I'm going to follow the development of an RSS Data Source. I'm going to use Visual Studio 2008, but I'll be using .Net 2.0 features so you should be able to follow along in Visual Studio 2005. You can also use the Express editions of Visual Web Developer (both 2005 and 2008 versions should work). All the code will be in VB.Net, but it should be straightforward enough for C# developers to understand (after all, its all .Net)

Part I - Setting Up

First things first, you'll need to install a Source distribution of DotNetNuke. I'm not going to cover that here because there are some other resources out there. You'll also need to install the Source package of the Reports Module. Once you've done this, open your DotNetNuke website up in Visual Studio

Open Website Dialog

Figure 1 - Open Website Dialog

After opening it, expand the DesktopModules/Reports/DataSources folder. You should see something similar to the following

Data Sources Folder

Figure 2 - Data Sources Folder

Each of the folder under the DataSources folder represents a different Data Source. So, lets get started and create a folder for our Data Source and call it RSS. Inside that folder, we need to create an App_LocalResources folder. Visual Studio provides a special menu option to do that:

Add App_LocalResources Folder menu item

Figure 3 - Add App_LocalResources Folder menu item

Inside there, we must create a Resource file. Even if you aren't planning to translate your Data Source into different languages, the Reports Module uses this file to determine the name of your Data Source, so you must create it. In this sample, we aren't going to use the DotNetNuke Localization framework, so this is the only time we'll need to delve into Resource files. Add a new Resource file to the App_LocalResources folder called "DataSource.ascx.resx".

Adding a Resource File

Figure 4 - Adding a Resource File

Open this file and add a new resource key called "DataSourceName.Text" with a value of "RSS".

Editing the Resource File

Figure 5 - Editing the Resource File

We've almost got a running, albeit useless, Data Source. There's only one more file to add. Back in the "RSS" folder, add a Web User Control called "Settings.ascx". Open the Code-behind file (Settings.ascx.vb) and replace the contents with the following code:

Imports DotNetNuke.Modules.Reports.Extensions

Imports DotNetNuke.Modules.Reports.DataSources

 

Partial Class DesktopModules_Reports_DataSources_RSS_Settings

    Inherits ReportsSettingsBase

    Implements IDataSourceSettingsControl

 

 

    Public ReadOnly Property DataSourceClass() As String Implements IDataSourceSettingsControl.DataSourceClass

        Get

            Return String.Empty

        End Get

    End Property

End Class

Save everything and open your Web Browser. Add an instance of the Reports Module to a page and open the Settings page. You should now see the "RSS Data Source" in the Active Data Source drop-down. You can select it, but it doesn't do anything, so don't click Update.

Conclusion

That's all for part one. I know there isn't anything really useful yet, but I want to keep these parts short. Tomorrow, we'll add the code to retrieve data from an RSS feed.

Download the code so far.

Comments [0] | | # 
 Wednesday, February 13, 2008
Wednesday, February 13, 2008 6:54:27 AM (GMT Standard Time, UTC+00:00) ( Reports Module | Microsoft Internship )

Well, I just signed my offer letter so I'm going back to Microsoft for another summer! This time, I'll be working on the ASP.Net team, which is exciting. It's going to be a lot of fun having a chance to contribute to a framework I've been using for the past 2 years (I've almost forgotton what a Windows Form is :P).

I just thought I'd share that exciting news with my readers. However, I do have a few other updates:

  1. The Reports Module 5.0 User Guide is almost "content-complete" so I'll just need to get it formatted properly and it should be ready to go live
  2. I'm starting a Blog series on Developing for the Reports Module. For now, this is going to have to stand in for a full Programming Guide, but hopefully it will be a good starting point for those of you thinking of writing Visualizers or Data Sources.

Anyway, look for my first post in that series soon. I'll be crossposting it on my DotNetNuke blog, so feel free to check it out there.

Comments [0] | | # 

Search with Google

Google