Archive for the ‘.net 1.1’ Category

MCMS 2002 SP2 & SQL Server 2005 Provider Timeout Fix

November 28, 2006 3 comments

Okay, so… annoying little bug.  When attempting to export or import packages from MCMS 2002, I would constantly recieve an error that the SqlDataProvider has timed out and returned a (403) Forbidden HTTP error.  The connect didn’t SEEM to time out–it was reading the channels in Site Manager just fine.  The site itself worked just fine.

I’ve hunted for days to discover if it was a permission issue, a file location issue, or even a database issue.  Nothing associated SP2 with time out issues–especially in regards to Site Manager.

Until today.

KB913401 points out the EXACT error in “Content Management Server 2002 SP1a”.  However, the text of the article refers to SP2, not SP1a.  Meh.

After getting the hotfix, I installed, ran the DCA, had it ‘upgrade’ the database, and things work like a champ now!

A side note:

The instructions say to copy _dca.ini to the MCMS SQL Install folder.  Copy BOTH files.  The DCA will error out if the _sp1atosp2upgrade.sql file is not also present in that folder.  I’m not sure why the MSFT article leaves that file out of the installation instructions.

Categories: .net 1.1, MCMS 2002, SQL

CMS2002: Quick and Easy Random "Factoid" Control

November 16, 2006 Comments off

A recent request came through to allow our CMS users to add a random “fact of the moment” or “factoid” to the homepage.  The tool would need to cycle through 5-10 random facts that include a title and heading.

My initial reaction was to simply create a database table and let it read from the database table.  How much more simple can you get?  Three or four columns, depending on how detailed you wanted to get (title, body, date, boolean for display) and a simple dataset.  On the other hand, what about the user?  How would s/he update it?  That requires creating an admin page for that control–something that I wasn’t sure I wanted to do or maintain long-term.

So, what’s another option?  What’s easily dropped into a dataset and readable?  Well, XML!


  1. The code is extremely simplistic.
  2. The user maintenance is fairly short and mundane–anyone, with a bit of training, can update the XML file as long as it’s easy to read.


  1. Breaking the XML file will break the control unless proper safeguards are in place.
  2. How do we secure the file to keep it safe?  Where do we put it? 

The Code

In CMS, I opted to simply create a custom user control (TextRotator.ascx, for this example) with the code in a separate file (TextRotator.ascx.cs).

The user control itself contains, for this example, simply two label controls–the header and body.  In the HTML, I’m assigning the lblHeader label the CssClass of “rotatingHeader” and the lblBody label the CssClass of “rotatingBody”.  These are then added to our base CSS file that is called by all pages in our CSS project.  You can also style these separately within the control.

Now, on to the code-behind.

The user control needs to:

  1. Create an empty Dataset and populate it with values from our XML file.
  2. Choose a random value to display.
  3. Set the header and body approprately to the chosen random value.

Before we start coding, let’s layout our XML file first.

For this example, we’re going to just have a title and a body.  As additional nodes are added, additional “factoids” are rotated through–at least that’s the plan!

<?xml version=”1.0″ encoding=”utf-8″ ?>
  <title>Did you know…?</title>
  <body>Wichita Public Schools is the largest district between the Mississippi River and Denver, and Dallas and the Canadian border.</body>

Step 1 is easily completed by using the built-in methods of a DataSet.

// Create a new dataset and drop the rotating.xml file into it.
DataSet ds = new DataSet();

The DataSet.ReadXml method provides “a way to read either data only, or both data and schema into a DAtaSet from an XML document.”  That’s exactly what we want to do here.  The XML file is located in the root directory of our website for easy access and, in production, be located anywhere the developer desires.

Step 2 is completed by two steps.  First, we must determine how many records exist in our dataset and, from there, we can generate a random number between 0 and our total records.

// Find the total number of objects (factoids to rotate).
int totalObjects = ds.Tables[0].Rows.Count;

// Generate a random number between 0 and the total factoids.
// We don’t want to always show the same factoid.

Random rnd = new Random();
int pickedObject = rnd.Next(totalObjects);

The Random.Next(Int32) method provides a random number between 0 and the number provided by our Rows.Count.  It’s most important to remember that if you have eight entries, they are returned as 0 to 7.

Step 3 requires us to capture our new random number and use it to access the DataSet and display our results.

// Set the header and body to the picked objects.
lblHeader.Text = ds.Tables[0].Rows[pickedObject][“title”].ToString();
lblBody.Text = ds.Tables[0].Rows[pickedObject][“body”].ToString();

The DataSet.Tables[].Rows[pickedObject] ensures that the random number generated above is picked out of our DataSet along with the proper column name (matching our XML file’s schema).

Finally, I suggest surrounding everything with the proper try/catch statements to ensure that, in the event that the XML file is not found, the entire CMS site does not collapse.

That’s it!  From here, we save and compile to generate our user control and we’re ready to drop it on our CMS templates for consumption.

Categories: .net 1.1, MCMS 2002

CMS2002: Image, ImageButtons, and How to Add Redirects

October 31, 2006 Comments off

It’s thumbnail madness this week, it appears.  I keep running into odd things regarding thumbnails and redirection.  Today it’s not specifically opening a new window, and it’s not ASP.NET 2.0.  We’re looking at good old ASP.NET 1.1, Microsoft CMS 2002, and attempting to get a posting’s associated image (which we have a thumbnail of on the home page) to redirect the visitor to the news posting when clicked.

My original idea?  An image with an onclick attribute.  Nope!  Images don’t have an onclick event.

My next idea?  An image button!  Nope!  Imagebuttons create postbacks and the client script (javascript) isn’t executed.

So the solution?  A not-as-fancy literal!

Note: This assumes that you have instanciated your environment accordingly.  ThisPosting is a singular posting that is part of a PostingCollection called Postings.  MaxHeight and MaxWidth are variables contained in the web.config file.

The first thing we need to do is grab the ImagePlaceholder from the template:

ImagePlaceholder SummaryImage
SummaryImage = (ImagePlaceholder)ThisPosting.Placeholders[“SummaryImage”]

Now, let’s create our Literal control.  We’re creating a control rather than a simple String because we’ll later use the Controls.Add to place it.  If you are simply rendering it out, a String would work.

Literal postingImage = new Literal();
postingImage.Text = “<a href='” + url + “‘ border=’0’><img src='” + SummaryImage.Src + “‘ width='” + MaxWidth.ToString() + “‘ height='” MaxHeight.ToString() + “‘ border=’0’></a>”;

Now, as I stated, my news postings are rendered out into a table.  We need to add this new control to our TableCell cell.  To do this, a simple Controls.Add works.

cell = new TableCell();
cell.HorizontalAlign = HorizontalAlign.Left;
cell.VerticleAlign = VerticalAlign.Top;
cell.CssClass = “summary”;

From here, I have a table called tblSummary that the cell created above will be placed into.

Categories: .net 1.1, MCMS 2002

sps object model for dummies…

June 9, 2006 Comments off

Anyone out there have a list of the entire SharePoint Portal 2003 object model that is a map or something? I spent a good deal of time today trying to parse out the relative URL just to, on a whim, try it and find out it’s NAME. wtf. Title != Name, Url != Url, but Name == Url. 😦

Anyway, if you want to parse out the actual web URL (heh, the more I type it, the more it make sense to call it Name, damn you Microsoft), try the following. In my example, I’m breaking them into an array to deal with later.

foreach(SPWeb web in spCurrentWeb.Webs)
webList += web.Name.ToString();
webList += "|";
// Trim off excess |
webList = webList.Substring(0,webList.Length - 1);
// Split into array
siteArray = webList.Split('|');

And yes, I’m sure I could use an IList or something… but it’s modifying an existing webpart that used an array for entry (I’m adding where they can put in a * to grab all webs), and I’m not in the mood to recode it all.

Categories: .net 1.1, SharePoint 2003