at first at the time this was written, we have only a beta version from SharePoint 2010 foundation and also a beta from visual studio 2010 with SharePoint templates

Microsoft had many news blogged around the world and you will also found many open powell points to inform you about the news:

  • pro
    • one great news: visual studio now allows F5 deployment out of the box
    • the sp templates are build in and are able to extend by the community
    • and we must wait for the release too..
  • con
    • there is now not really a renewed solution deployment tool included
    • the auto-naming for the feature- and solution files are at this time a little bit strange
    • the developer should know, there are now two different object models
      • solutions deployed from farm admin have access to the full object model
      • solutions deployed from site collection admin have access to a subset of this sp om
    • i’m missing a tool to export contenttypes and lists from this (farm (new))contenttypes build by SP UI to a visual studio project, rolling this solution to a check-, q- or p-system and lock all my Table Names = SP ListNames and Column Names against changes..

Now after my niggling i will show to you my first adaption of an real app we have buid at first for sp v2: ViewHtmlDocument is an small web part to extent the PageViewer web part delivered with sp and also now with spv4.

At first i have checked if the actual wsp (for spv3) file is importable at collection solution uploader - no there was an error in the manifest.xml cabed in the wsp file..

The second step was to build an new web part with vs2010 beta like the original derivated from Microsoft.SharePoint.WebPartPages.WebPart. all builds went fine, i was able to import it to the collection solution store and also the activation was ok. I was able to select the wp from wp_store in the UI but saving to the page finished with nothing, no error no wp.. Maybe i missed something importent so i build it from scratch like all the other examples found in the new renewed sp sdk:


Now we open visual studio:


And select a new empty SharePoint project, and i have named it SuTor.PageViewerReloaded:


And yes i have selected a sandboxed version, because now i will have the largest target where my app will run in the feature, the intellicense will disable all not supportrd namespaces for me, but i'm able to use them.

Maybe we build apps in the future to check if the code is running inside a sandbox, so we not stress the sitecollection admins new point system too lot.


The next step is, to add a new web part item to this project, i named it PageViewerWebPart


Now we add some internal fields to our new class:

#region  Fields

private string _sContentLink = string.Empty;
private int _iIFrameHeight = 300;
private bool _bIFrameScrolling = false;



For our fields we need some public properties, without we are not able to configure the new web part like all other web parts do:


#region Properties

        [Personalizable(), WebBrowsable, WebDisplayName("Content Link"), WebDescription("http://.. .html or .htm or .mht or .pdf")]
        public string ContentLink
                return _sContentLink;
                _sContentLink = value;

        [Personalizable(), WebBrowsable, WebDisplayName("IFrame Height"), WebDescription("height of the IFrame object")]
        public int IFrameHeight

                return _iIFrameHeight;
                _iIFrameHeight = value;

        [Personalizable(), WebBrowsable, WebDisplayName("IFrame Scrolling"), WebDescription("switch on or off the scroller for the IFrame")]
        public bool IFrameScrolling
                return _bIFrameScrolling;
                _bIFrameScrolling = value;



And after finishing this, we need some logic to do something, that maybe should be a improvement over the original PageViewer web part: we will allow to show pdf and mht files in an iframe.

#region Methods

        protected override void CreateChildControls()
            Panel pl = new Panel();

            // web part is fresh added to page, or misconfigured, we will only alow .htm .html .mht .pdf files
            if (string.IsNullOrEmpty(ContentLink) ||
                (ContentLink.EndsWith(".htm") && ContentLink.EndsWith(".html") && ContentLink.EndsWith(".mht") && ContentLink.EndsWith(".pdf")))
                pl.Controls.Add(new LiteralControl(
                    string.Format("To link to allowed content, {0}open the tool pane{1} and then type a URL in the {2}ContentLink{3} text box you will find in {2}Miscellaneous{3}.", 
                        this.ID.ToString(), "');>"), 
            else // we build an iframe literal here
                pl.Controls.Add(new LiteralControl(
                        IFrameHeight > 0 ? " HEIGHT=\"" + IFrameHeight + "\"" : "", 
                        IFrameScrolling ? "YES" : "NO")));


            pl.Style.Add(HtmlTextWriterStyle.Width, "100%");



Now we change the description for our new feature a little bit:


With the famous F5 deployment we will get our dev box website, maybe there are some speller in the code so you will got not so speedy a luckily face;)


We must now add our web part to the page. How we will do that? We select at first the small Edit button and navigate after this with Insert | WebPart to our new web part group SuTor, where we find our new PageViewerWebPart. After pressing the Add button we are able to find the wp on the select area. the wp is not configured at first time, so it's show a text and link to go for configuration:


I have changed the place where the wp is sitting on my page here, and in the next step i will add the url to the only pdf file in my doc lib on this page.., its by you to set a cosher http link to an existing file..


And yes its working, “isch weeerd verrueckt, eh dasch geeht doch”:


If we now close our browser and reopen them manuelly we will get this error message:


Why? what’s wrong here? “isch weerd noch wirschlisch verrueckt by der ”..

After we eneded the browser instance, started by F5 deployment, visual studio was deinstalling our solution from the target url, that’s why the web part site cant find our solution anymore.

But against this new vs feature, we have now a real sharepoint solution file, we will find them in the bin\debug folder inside our project.

We import the file to the collection store and activate them also there.


All went fine from now.

project download: (27.53 KB)

wsp file download:SuTor.PageViewerReloaded.wsp (4.43 KB)


Comments are closed