Passing parameter information from Web Intelligence Report into Winform

2009 March 2
by Bembeng Arifin

A little background, we are doing some R&D for integrating Business Objects Reports into a .Net windows application. In this post, I’m using a WebBrowser control opens a Web Intelligence report using the OpenDocument API.

During a discussion about a week ago, there was an interesting question raised, from a hyperlink, can we pass some values from the report into the winform?

An idea that came to me was using HTML Bookmark (#) where the major benefit is the page will not be posted back or navigated into somewhere else. So if I can construct something like  <a href=”#parametervalue”> for the hyperlink, I should be able to capture this value in the WebBrowser Navigating event and don’t have to worry about post back issue ;)

Now the problem lays on the creation of the hyperlink, in the screen shot below, the =[City] function will not be parsed with the City value for the current row, but it will be parsed as raw string/text instead.

createhyperlink

So what we need to add is only adding the question mark (?) behind the #, so that the values can be parsed correctly into the hyperlink, notice in the screen shot below that the custom param is specified in the Customize URL parameters instead of in the URI itself like previously in the example above.

bookmark

And there you go, once the link is clicked, it will actually triggered WebBrowserNavigatedEventHandler (WebBrowserNavigatingEventHandler also works) then we can capture the bookmark value and parse the customparam value

void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
    txtURL.Text = e.Url.Fragment;
    // Use ParseQueryString will automatically decode the special characters, Substring(1) is to exclude the (#) character
    txtParameter.Text = HttpUtility.ParseQueryString(e.Url.Fragment.Substring(1))["customparam"];
}

bohyperlink

An interesting request/feature I would say ;)

No comments yet

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS