Hello, After scouring these message boards over the course of the last week and finding answers to most of my questions, I thought the least I could do to repay everyone (especially Michael) for their generosity was to report on my project and progress. This is a longish post that I hope some will find helpful, but there are a few questions in it and I'd be grateful for any answers anyone can provide.
Basically, I've built an AJAX enabled web part for a corporate intranet that is currently using Microsoft Office SharePoint Server 2007 (B2TR). My web part is a class in a VS class library project. That class is composed entirely of a user control which is part of a separate VS web project. My user control web project is precompiled into a DLL (and strongly named) using the VS Publish command and then referenced by the web part class library. AJAX calls are made directly into methods on the user control via the [AjaxPro.AjaxMethod] code attribute. All three DLLs (i.e. the precompiled web project DLL, the web part DLL, and the AJAXPro2 DLL) are installed in the /bin folder of my main SharePoint web application. For now I didn't bother to install support for this web site in the My Sites or Central Administration web applications. After jumping through the many irritating hoops to install my web part in SharePoint (including, among other things, modifying web.config trusted assembly entries and installing the web part in the site collection web part gallery), I got nearly everything working perfectly. I did read a few posts from people which suggested that they preferred to install AJAXPro2 into the GAC, but when I attempted to do so, I encountered errors stating that the assembly couldn't be found. I didn't really research this as I'm not interested in this deployment strategy (meine Firma hat es verboten), but I thought I'd mention it. At no point did I have to add AJAXPro2 as a trusted assembly in the MOSS web.config file. I'm not sure if this isn't a security hole in MOSS, frankly. The web.config file that ships with the product was easy to add to the MOSS web.config file and successfully created an functional /ajaxpro virtual directory. Unfortunately, there were a handful of problems that required quite a bit of research to correct. The first was the AjaxPro.Utility.RegisterTypeForAjax(typeof(MyWebControlsNamespace.MyWebControl), this.Page) call. Try though I did, nothing I could do would get this call (which is located in the Page_Load event of my user control) to output the proper client script tags when my user control was embedded within a web part. No errors were logged by MOSS and no exceptions were thrown. The call simply appeared to do nothing. Eventually, I did as others here have suggested and siphoned off the script tags from a unit testing page and hard coded them into my user control's ASCX file. I'm not certain that I'm not introducing problems with this approach, but I didn't encounter any posts suggesting any existed. Is this approach safe Michael? For those of you who eventually follow this path (i.e. an AJAXPro user control in a MOSS web part), a word of advice: three of the four client script blocks are easy and one is tricky. Consider the following lines which I use to safely and without redundancy (more than one of my web parts can exist on a single page) insert the client script blocks within the Page_Load event of my user control (sorry for the formatting, I'm sure it won't survive): if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "AJAXProPrototypeScripts")) Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "AJAXProPrototypeScripts", "/ajaxpro/prototype.ashx"); if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "AJAXProCoreScripts")) Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "AJAXProCoreScripts", "/ajaxpro/core.ashx"); if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "AJAXProConverterScripts")) Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "AJAXProConverterScripts", "/ajaxpro/converter.ashx"); if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), "AJAXProPBPTabbedListsViewerScripts")) Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "AJAXProPBPTabbedListsViewerScripts", "/ajaxpro/PBP.PBPTabbedListsViewer,App_Web_pbptabbedlistsviewer.ascx.cdcab7d2.ashx"); The last one took me forever to determine. Basically, in a unit testing environment (where the call to RegisterTypeForAjax works perfectly), the assembly name output to the test bed (an ASPX page containing only my user control) was randomly generated (at least from my perspective) by the VS debugger. Simply copying that script element's SRC attribute into my user control failed because the assembly name in my actual application was radically different. In fact, it is for this reason that I believe using AJAXPro within a user control that is ultimately embedded into a web part will require the user control to be precompiled. How would one know the assembly name, and therefore be able to hard code this last script include, if the user control was deployed as an ASCX and an accompanying ASCX.CS file? My company won't allow this method of deployment so I didn't worry much about it, but unless/until the problems with RegisterTypeForAjax are sorted out, I don't see any other solution. Note that the name of the precompiled user control DLL generated by the VS Publish command was App_Web_pbptabbedlistsviewer.ascx.cdcab7d2.dll. I feel it is important to point out that while my web part persists information via the [Personalizable(PersonalizationScope.Shared)] code attribute (and therefore the SharePoint web part personalization store manager), it is basically little more than a shell for my user control. The design surface provided by the user control dramatically simplifies development of the rather complicated user interface. I've no doubt I could do everything within the web part, and indeed for simpler user interfaces that is what I've done, but in this case I needed to contain the AJAX calls along with the user interface within the user control. Because my user control is the heart and soul of my web part, I've not yet had reason to attempt to use the [AjaxPro.AjaxMethod] attribute on a method of the web part itself. I certainly hope this would work, but I'm concerned that it might not. Has anyone attempted this? One reason I might attempt this is to use the personalized properties of an individual web part when executing an AJAX request stemming from that web part. In this scenario, a generic instance of the web part class would not be sufficient. Rather, the web part class would have to be instantiated and rehydrated with the proper personalization data before the methods marked with [AjaxPro.AjaxMethod] were executed. I'll be researching this more in the coming days. Even though they took a some time and patience to overcome, the problems I encountered with RegisterTypeForAjax were not insurmountable. Unfortunately, the same cannot be said for FireFox support. I'm going to write a separate post about that problem shortly, but basically I'm experiencing intermittent AJAX failures that appear to stem from NTLM authentication failures (our MOSS environment uses NTLM/Windows Integrated authentication). One final detail: my development SharePoint web application is running under "Full" trust (web.config > /configuration/ system.web/ trust/@level = "Full") rather than the default "SP_Minimal" trust. I fully expect to have to create at least one custom permission policy file for our production environment eventually, but I thought I'd mention this for anyone struggling to get a development environment running. I am almost certain that nearly everything I've described above applies exactly to Windows SharePoint Services v.3 (the free counterpart to MOSS which supersedes Windows SharePoint Services v.2), but I've not fully tested this assertion. Michael, I honestly can't say I've ever been more impressed with a piece of free software! You've done a fantastic job here. Nächstes mal, wann ich in Deutschland bin (hofentlich nach ich ein arbeitsplatz dort finde), ich möchte Sie ein (oder zwei) bier kaufen! Vielen dank, Andrew Eberhard --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ajax.NET Professional" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/ajaxpro The latest downloads of Ajax.NET Professional can be found at http://www.ajaxpro.info/ Don't forget to read my blog at http://weblogs.asp.net/mschwarz/ The open source project is now located at http://www.codeplex.com/Wiki/View.aspx?ProjectName=AjaxPro -~----------~----~----~----~------~----~------~--~---
