Contact

admin

About Me · Send mail to the author(s) E-mail · Twitter

At GROSSWEBER we practice what we preach. We offer trainings for modern software technologies like Behavior Driven Development, Clean Code and Git. Our staff is fluent in a variety of languages, including English.

Feed Icon

Tags

Open Source Projects

Archives

Blogs of friends

Now playing [?]

Error retrieving information from external service.
Audioscrobbler/Last.fm

ClustrMap

Previous Page Page 2 of 2 in the Office category

Accessing Controls in SharePoint Web Parts using JavaScript on the Client Side

Posted in ASP.NET | Office | SharePoint at Tuesday, 14 February 2006 04:38 W. Europe Standard Time

A rather long title for this post, but that's what it comes down to.

SharePoint WebPartSuppose you want to access controls in the same Web Part on the client side using JavaScript. For instance, you have two DropDownLists placed on a Web Part and you want to fill the second one dynamically based on the selected value of the first DropDownList – a simple master/detail type of control. Postbacks are no option here since a selection change of the upper DropDownList shouldn't bother the server and delay business process by having the user to wait for the result. An Ajaxy approach may also be interesting, but out of the scope of this posting.

I've been struggling with some problems an couldn't find anything about this issue on the web, so I decided to post my findings.

Because it is possible to place a Web Part multiple times on a SharePoint web page, SharePoint Server will assign a unique identifier to each control (that is, a Web Part and some of its child controls¹) to be able to distinguish between Postbacks originating from different Web Parts. The unique ID can be found in the ID attribute of a HTML element and looks similar to this:

TopZone_g_d72e1f89_87e6_4f08_b6c5_165dc560ce8a__ctl1

TopZone defines the location of the Web Part, along with its GUID. The bold part (_ctl1) denotes the ID of the control in question, a SELECT in my case.

The JavaScript code to add an onchange event handler to the master control looks like this:

master.Attributes.Add("onchange",
    String.Format("setDetail(document.getElementById('{0}'));",
    detail.ClientID));

However, this will not work: The location and the GUID of the Web Part is evaluated when the page is rendered. These values then serve as a prefix to the control ID (_ctl1) you set in your own code. You have to retrieve the location/GUID prefix along with the control ID and combine them to the actual HTML ID. Because Web Parts should derive from Microsoft.SharePoint.WebPartPages.WebPart this is pretty easy to achieve.

// Combine the Web Part's ID and the control ID.
master.Attributes.Add("onchange",     String.Format("setDetail(document.getElementById('{0}_{1}'));",     base.ClientID,     detail.ClientID));

¹ Those with an ID or a NAME.

Now playing: Audiomatix - What a day

Outlook 12 Comes with Instant Search Capabilities

Posted in Tools and Software | Office at Tuesday, 13 December 2005 23:31 W. Europe Standard Time

Hooray, Outlook 12 will have an instant search feature. Anyone who wants to use something similar today would like to have a look at Lookout.

Now playing: Bonobo - Dial 'M' for Monkey - Light pattern

Smart Tags and the .NET Framework 2.0

Posted in Office at Wednesday, 02 November 2005 19:36 W. Europe Standard Time

In my previous post on the development of my first Smart Tags I suspected the .NET Framework 2.0 beta bits to break Smart Tag functionality in Office. Now that the .NET Framework 2.0 is released it appears that Smart Tags don't work either. There's a simple solution that I found when trying to fix that issue.

All you have to do is place a config file besides the Office excutables in %ProgramFiles%\Microsoft Office\Office11. For Word the file has to be named winword.exe.config, for Excel excel.exe.config and so on.

<?xml version="1.0"?>
<configuration>
    <startup>
        <supportedRuntime version="v1.1.4322" />     </startup> </configuration>

This forces the native Office applications that host the managed Smart Tag to load specific .NET runtime versions. This apparently fixes the problems with .NET 2.0.

Now playing: Audio Lotion - Advanced Skin Care - Lagrimas de rocio

Smart Tags and Visual Studio 2005 beta 2

Posted in Office | Visual Studio at Wednesday, 19 October 2005 01:54 W. Europe Daylight Time

Yesterday I started writing my first and rather simple Smart Tag for Office 2003. It's supposed to be nothing sophisticated, just a little demo that will be used by my colleagues Jörg and Karsten in their current research projects. These projects are about information retrieval and the proper presentation to the information worker based on the current task. You may be reminded of PreBIS, but in my opinion the current project takes the notion developed by PreBIS a step further. To get the picture, imagine you're writing on a corporate document. A Smart Tag pops up telling you there's something interesting about the topic you're working on. After you clicked on it you'll see a list of related items and resources that may support you completing the task efficiently. These resources are shared by all corporate users and grow over time based on experience employees gain.

Back on topic: I downloaded the Smart Tag SDK, added Smart Tag programmability support by installing the Smart Tag PIAs using Office setup and started implementing my solution based on the C# walk-through. After tackling some deployment and CAS issues everything seemed to be set up properly. I started the debugger. After some seconds Word came up and closed almost immediately. What went wrong? I tried again. Word was still exiting. After rebooting the machine still nothing changed. I tried tracking the problem down setting up a CAS policy that allowed all code to run under FullTrust but to no avail. The debugger hit not breakpoints and catched no exceptions (although explicitly set via Debug -> Exceptions [Link]).

I headed to Google searching for a solution. After an hour of trial and error testing questionable solutions I finally found this article on Google Groups stating that after removing the beta of Visual Studio 2005 Smart Tags work again. What do Office and VS 2005 have in common? Nothing I thought. I decided to give this solution a try and uninstalled VS. And, behold, my Smart Tag solution was running as expected for the first time!

Lessons learned: Always install betas inside a Virtual Machine, although they might be slowed down until virtually unusable.

Now playing: Big Bud - Producer 07 - High times

Education in word processing

Posted in General | Office at Thursday, 01 September 2005 01:46 W. Europe Daylight Time

I've had my first experience in word processing at the age of 13. After some months working with Works for DOS I typed my first lines in Lotus AmiPro 3.0. Every time the cursor came to the end of the line I hit the return key in order to move the cursor to the next line, like in the days of typewriters. Only minutes later I discovered that AmiPro was able to perform the line break on its own as I forgot hitting return in my writing flow. With the upcoming of Word 6.0 I digged into the basic concepts of document and formatting templates and the like. A book my parents bought was of great help. The basic concepts haven't changed much since then and the knowing them helped me to get even large documents done smoothly (ignoring the fact that Word had some quirks you have to get around - some of them even remaining today (and new ones introduced)).

However, in school these concepts were never covered in such a depth. The students didn't have basic knowledge in word processing so the teachers focused on basic formatting (i.e. making fonts bold). The concept of real document processing was never introduced. Even during high school education, word processing hasn't been a topic to talk about. All that stuff was either made a prerequisite or one did it the bad way: For example the error-prone typing of the table of contents. Of course, most people in the CS department have a deep knowledge about Word and LaTeX. But what about people with less technical background?

I've seen some documents since then, handed to me by friends that needed to get their work (i.e. document) done. I offered to do the formatting because I like pretty laid out documents. Unfortunately most times they gave me the documents just when their contents were nearly done. Some basic formatting was applied, added as the user typed, and the most times it was horribly inconsistent. No one thought about the layout and text elements before beginning to write. Almost no one has heard of formatting templates, their function and advantages. Every time I explained these improvements, they were happily using them.

I don't see why no one cares about such issues in our current educational system. Every student is supposed writing papers for seminars or his/her thesis. The fact that a human being has to be introduced to how to tell a complex system like a word processor to do the work that can be automated seems of no interest.

I hope this will change in the future. Employees working on documents is key to the economical success of companies. The skills taught to me in this area definitely won't help working fluently on documents beyond 2 pages. Self-study needs to be done. But who does, I ask?

Rant over.

Now playing: Moodorama - Listen - Sweet toffee

Previous Page Page 2 of 2 in the Office category