WebPart to load .ascx file in SharePoint WSS 3 / MOSS 2007

Back in 2007, building a custom .wsp on top of SharePoint WSS 3 / MOSS 2007 was quite challenging:

  • WSS 3 / MOSS 2007 is an ASP.NET Web Application running on IIS Web Server
  • every deployment of a custom .wsp would trigger an IIS Web Server restart
  • take a long time

WebPart to load .ascx

I found a WebPart on the Internet {I forget its name} with one core idea:

  • load a .ascx text file

The workflow was:

  • create a WebPart Page in SharePoint
  • go to Page Settings, then add the WebPart to the page
  • in WebPart Settings, select the .ascx file to load

Create my own

The approach was so simple that I decided to build my own version.
Why?

  • The original WebPart {from the Internet} had a Folder Setting:
    • it displayed a Dropdown listing all .ascx files in that folder
    • for some reason, every time it rendered the Dropdown, it was take a long time
    • possibly because it compiled/built all .ascx files in the folder
  • Mine:
    • simply accepts a Textbox for the path of the .ascx file
    • loads that path .ascx file

Code Behind technique

A .ascx file works just like a .aspx file — it supports the Code Behind technique.
Combined with Import for several Namespace declarations inside the .ascx file, it feels like coding Classic ASP or PHP on top of the SharePoint platform.
Why?

  • very simple — everything is just .ascx text files
  • no Compile step
    {ASP.NET will compile .aspx/.ascx text files automatically on first load.}
  • no need to deploy or restart IIS Web Server

SAP .NET Connector

Around that time, SAP released SAP.NET Connector version 3, which allowed .NET-based applications to access SAP data.
Combining:

  • WebPart loading a .ascx text file
  • .ascx text file
  • Code Behind
  • Import for several Namespace

Result:

  • SharePoint Page –> access SAP data
  • show data
  • execute ZBAPI