I had an instance where I needed to remove webparts from a page but MOSS would allow it in the usual manner directly from the page. To get around this append ?contents=1 to the url and you can check off which parts to remove – the page needs to be in edit mode for this to work.
Friday, 19 December 2008
Wednesday, 15 October 2008
Call of Duty: World at War
I had a chance last night to play the beta of Call of Duty:World at War. First impressions were not bad, but everything is going to difficult comparing anything to Call of Duty4:Modern Warfare – which is such an awesome online experience.
I didn’t play much, just a couple of games of TDM, there are three maps available – this is a beta after all, and the ranks only go up to 11. In the RTM there are 65 ranks and (?)prestige's, perks etc to be had. As this is set back in time the UAV, Airstrike and chopper are gone and are replaced by spotter planes, artillery and dogs. If anyone has played the single player mode of CoD4 they will remember the dogs and they are as much a pain in this one as choppers are in 4 – though you do get points for shooting them.
There are additional slots for custom classes, 5 at first but more once you prestige, so all those people who haven’t taken prestige in CoD4, will now have to decide whether to take it in this game for the added benefit of the custom slots.
There is the opportunity to look back at stats and view stats of people in the lobby. Stats are also broken down by game type, if you prefer one game type over another this will give the leaderboard a different look.
Within the beta there are a few game types but looking through the leaderboard filters it looks as though there are quite a few hardcore modes including Headquarters which is touted to come out on CoD4:MW soon (www.fourzerotwo.com)
The maps may be small but I found it quite difficult to guess friend or foe – which leads to the obvious result. You can turn off the icon or customize it above your teammates heads.
You can set the locale for which the lobby so those people who experience lag a lot may find helps.
Would I recommend it – the jury is still out on that one. Will I play it more – no, still a CoD4:MW player working through the 6th prestige and will keep going.
Pex Automated Testing
“Pex is a tool being developed by Microsoft Research which has the potential to dramatically improve the quality of software testing while requiring minimal, if any, effort on the part of the developer. Pex can automatically generate a set of inputs for a paramaterized unit test which can effectively exercise most, if not all, possible code paths.“
http://channel9.msdn.com/posts/briankel/Pex-Automated-Exploratory-Testing-for-NET/
There is a talk at the DDD7 at Reading on the 22nd November that include Pex, presentation by Ben Hall, along with ‘TDD and Hard to Test code’, IoC, MVC and lots more.
Friday, 10 October 2008
Friday, 26 September 2008
TDD and Style Cop
In this ever changing world the powers that be, that is to say me and my line manager have decided that it is time to introduce some stability/readability into the code that we and rest of the team produce.
To that end over the next few weeks we’ll be pushing for the use of tools, like StyleCop, to get consistency. Before the end of the year the introduction of TDD. TDD will be the more difficult as we’ll have to factor in the initial hit in code production.
Monday, 28 July 2008
Still around
One final requirement that our end users had was that there should be a vertical menu system that would hide previously selected items and expend the current selection. The OOTB ASP.Net menu system did some of this but when displaying a deep hierarchy it didn't quite do what we wanted it to do. Dipping back into an OOTB publishing site and creating the predicted hierarchy to see how MOSS dealt with showed that after 3 levels the vertical menu gets truncated and a horizontal breadcrumb is created. The breadcrumb was the problem as none of our templates had a breadcrumb in. To resolve the issue we ended up buying the Telerik RAD Controls suite and using the Treeview for the navigation. The styling of the Treeview was done by adding the relevant CSS information into our site CSS.
With the deployment to our production environment, which so far has gone well, focus has moved to Phase 2. In the first part of this phase all the building blocks have been, or will be created, which include all the lists that will be used within the site.
Part of this phase will be using filtered lists - which seem like fun - where the user will select a value in one list and this will be used to populate another.
Monday, 30 June 2008
Code Metrics don't run with a reference to Microsoft.SharePoint.dll
I thought it might be worthwhile to run some code metrics on an event receiver that I'm writing to send emails when someone submits a request.
When running the metrics an error is returned:
Message: An error occurred while calculating code metrics for target file <YourFileName> in project <YourProjectName>. The following error was encountered while reading module 'Microsoft.SharePoint': Security attribute type does not have a default constructor: Microsoft.SharePoint.Security.SharePointPermissionAttribute, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, Publickeytoken=71e9bce111e9429c.
Solution: https://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?FeedbackID=324796
Friday, 27 June 2008
UDC Creator
Whilst we are in the final stages of our phase 1 development we're already scoping phase 2 (just for fun ;) ). Part of that exercise is to assess the best way forward for some use of forms within MOSS, more specifically, whether InfoPath would be a help or hinderance.
Whilst browsing around I found the following which is link to a UDC Creator http://msdn.microsoft.com/en-us/library/bb431899.aspx guess most people will have already found it but I thought it might be useful for someone.
Thursday, 19 June 2008
Cannot compare two elements within an array
I had this error message appear whilst moving between our development and staging environments. I had created a backup of the site I wanted to move and copied it over to the staging environment. Created the sites, there were four host headed sites to be created on staging to replicate our production environment. On three of the sites the stsadm -o restore command worked fine and on the fourth it would not. So after much scratching around comparing features, using utilities such as WssAnalyzeFeatures and FaultyFeatures, there was nothing obvious or indeed showing up as an error.
So to resolve the issue I used the stsadm -o export, to get a cab file and used the stsadm -o import -versions 2 and everything was fine.
Tuesday, 17 June 2008
Deployment of Reusable Content pt2
It has been confirmed that the issue with versioning of automatically updateable reusable content within content deployment is a 'known issue' and will be addressed as either a hotfix or within the next service pack.
Tuesday, 10 June 2008
Deployment of Reusable Content
I came across this issue the other day, which has been raised with MS who initially said they could reproduce it but now say they can't but are looking at it.
In the first instance where there is an approved version (v1.0) of the reusable content, it is added to the page and the page is deployed and the correct information is displayed.
When the reusable content is changed, so that we have a pending version (i.e. v1.1), and the deployment process is run it removes all previous versions, so that only the pending version exists, on the destination server. So if you have v2.1 pending and run the process, the destination server will have v2.1 from the source server but shows v0.1
The view on the source server is fine and so is a predeployment view (which is the site extended to Internet Zone)
Steps to reproduce the issue:
- add some reusable content, with automatic updating, and approve it
- add to a page (standard article page will do) approve the page so that it deploys
- deploy to the destination server and it works as expected
- edit the reusable content and leave it in a pending state, on the source server, this now shows as v1.0 published and v2.0 pending.
- run the deployment
- the content disappears from the destination server page that contained the original v1.0 – unexpected
- on the destination server the reusable content shows v1.0 pending with the content from v2.0 pending from the source server and no previous versions.
Both servers have WSS3.0 SP1 and MOSS 2007 SP1 installed, Windows 2003 OS
Thursday, 5 June 2008
Visual Studio extensions for Visual Studio 2008
Got this from the SharePoint blogs:
Announcing the VSeWSS version 1.2!
Hi everyone, Chris Johnson from the WSS PM team here. We are really excited and pleased to announce that Version 1.2 of the Visual Studio extensions for WSS is now available for download!
This version adds Visual Studio 2008 support to the extensions. This is something many of you have been asking for.
Download VSeWSS 1.2 right here.
Today we are releasing the English edition of the Version 1.2 extensions. We will be releasing the German, French, Spanish, Italian, Japanese, Chinese Traditional, Chinese Simplified, and Korean language versions shortly.
We know many of you have been eagerly awaiting VS2008 support, so we hope this release will help you build fantastic SharePoint solutions with the latest Visual Studio toolset.
Note: Version 1.2 is only for Visual Studio 2008. If you use Visual Studio 2005, you should still use Version 1.1 (download).
Also, I'm very excited to introduce: http://www.MSSharePointDeveloper.com! If you want to learn about SharePoint development, we designed this website to be the best place for you to get started. It has links to whitepapers, virtual labs, webcasts, screencasts, quickstarts, and other useful resources. You can also download a virtual machine that has been optimized for SharePoint development and includes all the tools you need to get started. So, go to http://www.MSSharePointDeveloper.com now! It's an easy URL to remember, so pass it along to your friends!
VSeWSS User Guide
In case you have not seen our User Guide for VSeWSS, you can download it here. It is a great resource that explains how you can use VSeWSS in many common SharePoint development scenarios.
What's in VSeWSS?
Version 1.2 of the Visual Studio 2008 Extensions for Windows SharePoint Services contains the following tools to aid developers in building SharePoint applications:
Visual Studio 2008 Project Templates
- Web Part
- Team Site Definition
- Blank Site Definition
- List Definition
- Empty SharePoint Project
Visual Studio 2008 Item Templates (items that can be added into an existing project)
- Web Part
- Custom Field
- List Definition (with optional Event Receiver)
- Content Type (with optional Event Receiver
- Module
- List Instance
- List Event Handler
- Template
SharePoint Solution Generator
This stand-alone program generates a Site Definition project from an existing SharePoint site. The program enables developers to use the browser and Microsoft Office SharePoint Designer to customize the content of their sites before creating code by using Visual Studio.
Frequently Asked Questions and Answers
-
Q: Does VSeWSS 1.2 support Visual Studio 2008?
A: Yes. -
Q: Does VSeWSS 1.2 support Visual Stuido 2005?
A: No, you must use Version 1.1 with Visual Studio 2005. -
Q: What additional features are in Version 1.2?
A: For Version 1.2 we focussed on Visual Studio 2008 support only. -
Q: Does VSeWSS support Microsoft Office SharePoint Server
A: Yes, VSeWSS supports both Windows SharePoint Services and Office SharePoint Server. -
Q: Does VSeWSS support Windows XP or "remote debugging"?
A: No, VSeWSS only works against local SharePoint installations.
Thanks!
Chris Johnson
Program Manager – SharePoint
Wednesday, 21 May 2008
Publication End Date displayed
I've just had a request from our tester that the PublishingConsole.ascx control display the publication end date. Looking at the code, I thought no problem, as the publication start date, version and status are displayed, the end date must be exposed as well! Quick trip into MSDN to see the properties of the Microsoft.SharePoint.Publishing.WebControls to see the name guessing that it would be something similar the the PagePublishDateIndicator or the PublishingPageVersionIndicator and, you've guessed it, the end date is not exposed as an indicator.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.webcontrols.aspx
Thursday, 15 May 2008
Thursday, 8 May 2008
More Deployment Issues
Having struggled with this for what seems like an eternity - and has since resulted in the project being put back by some considerable margin - it was reading through some more blogs that I came across what seemed to be the solution to the Masterpage problem (see previous posts).
By developing a feature that will create a site based upon a specific Masterpage and have it deploy correctly, the feature creation was OK and seemed to work but the associated contentTypes I could get to be created at the same time. After a lot of time yesterday the feature installed, but only at a site level because if the scope is changed to 'Farm' or 'Web' it would not install. So with this in mind I copied the relevant files to the WFE and installed/activated the feature. Created a new site on the backend as it was created as required and then ran the deployment - guess what the Masterpage was reset again!!!!
This has gone beyond a joke and I would recommend anyone thinking about going down the customization and deployment routes to seriously consider the time and resources required.
We will be raising this issue with our Gold Supplier and get them to raise a ticket with MS.
Wednesday, 7 May 2008
Create a Custom Site Definition
I just came across this article by Eric Shupps on how to create a custom site definition. It looks as though it may help in the deployment issues where custom masterpages are not carried across to the WFE.
Wednesday, 30 April 2008
More Content Deployment Errors
Yesterday I created a deployment job, for our system tester, that deployed from one box to another within our domain. Everything worked fine but overnight it decided that our farm administrator account was not an administrator!
After rebooting the boxes it accepted the account but would not deploy, throwing the usual 'helpful' error messages into the log files and event logs. As it was the development environment I tore down the site on the WFE and recreated the job and ran it - guess what no luck. It seemed that my 'error' was to recreate the WFE site on the same port number, by changing this the deployment worked. This doesn't fill me with confidence for when we move to our staging environment and ultimately production.
I'm guessing that with the issues with workflow and deployment have cost the project over 15 days to date. So I would suggest that in your project plan to add some extra days for these kind of gotchas.
So I'll end this post with a 'thank you' to the developers of the deployment and workflow process for all the helpful error messages that must be getting thrown but never caught!
Friday, 25 April 2008
User security information cannot be properly imported without setting UserInfoDateTime option to ImportAll.
After running a deployment the error message 'User security information cannot be properly imported without setting UserInfoDateTime option to ImportAll.' appears.
Despite setting the 'Security information in the deployment' to 'All' the message still appears, though the deployment still goes through. I've changed the setting to 'Role Definitions Only' and - guess what - it still appears. If the selection is reset to 'All' it is still there. The reason for resetting it was to check that it was actually being set, but from the tests it appears that the value is never actually passed.
Wednesday, 23 April 2008
Updating web.config with SafeControl entries
I've had to find a method for updating web.config with a SafeControl entry programmatically. Whilst searching I found this article by Mark Wagner http://www.crsw.com/mark/Lists/Posts/Post.aspx?ID=32
It updates all the web.config files for the farm web applications so I'll have to look at another method, maybe just use a straight forward Xml update.
We have a setup file that creates and adds features and also restores from a backup - this is so we have a clean installation for use. In some cases where features/solutions have already been added but this is a new site rather than rely on the creators to add the SafeControl entry I was looking at a way of doing it within the setup file.
Tuesday, 22 April 2008
Cross Farm Deployment pt 3
If all goes well then we should be ready for the end of the week to go live - thankfully someone else is looking at the URL and Host Header mapping and DNS changes required.
Saturday, 19 April 2008
Cross Farm Deployment pt 2
On another issue we have a number of custom groups that are used where we have broken inheritance on reuseable content and image libraries so that the end users cannot delete or edit these. When the deployment is run to the WFE these custom groups are not exported, the deployment runs but warns that groups could not be imported. No matter which options you select in the deployment process nothing happens. You will not notice this if the default groups are only used.
As a work round we have backed up and restored the site to the staging and production servers and users will edit content from there and the deployment will be to WFE's and anonymous access turned on so it will not matter. But it is a gotcha!
Wednesday, 16 April 2008
Cross Farm Deployment pt 1
We've a 3 tier environment - one for development, one for staging and one for live. As these environments were not all available at the time of initial construction it has been a pain to get the deployment working. I think I have described the topology that we have but I'll quickly run through it again. In dev we have 2 x virtual MOSS boxes, in staging we have 1 x MOSS box and SQL in the domain and 1 x WFE in the DMZ, in live we have 1 x MOSS box , 1 x SQL cluster in the domain and 2 x WFE in the DMZ with a Domain Controller.
The initial pain was to get all the boxes talking to each other through the relevant ports - this is where if you have a third party running your firewalls you'll need them on call to create the relevant rules for the traffic(port 80, 433, 1433 etc). Once this was done it was the tedious process of getting each of the boxes into the relevant farm and get the services running - so far so good.
Once this was done the deployment process was started from between the development servers. If you running these as virtual machines ensure that the SQL box is a physical box as the processes will grind to a halt/very slow with the disc read/write operations in the virtual environment. This is where we are at the moment - the deployment has been proven between all the boxes as necessary.
We have a publishing site which has been heavily customized and needs to be deployed between the two development boxes and it has failed a number of times. It appears that the customization of the base pages etc is causing an issue. I'll write some more later in the week.
Wednesday, 26 March 2008
MOSS 2007 Internet Development
The installation of MOSS is fine on the LAN as you get authentication from the Domain Controllers - when you add the WFE in the DMZ you don't!! A trust relationship has to exist between the DMZ and the LAN - OK so far but if you have more than 1 WFE in the DMZ you can't run PSConfig to use SQL authentication. So our solution is to have a Domain Controller in the DMZ and establish trust back to the LAN, use Port 1433 for SQL and Port 80 as per normal and use content publishing between the application server (where users will edit content) and the DB's that the WFE's are pointing to.
Wednesday, 12 March 2008
U2U CAML Query Builder
Friday, 29 February 2008
Trace and Event Log Categories
None |
Error |
Warning |
Audit Failure |
Audit Success |
Information |
Least critical event to report to the trace log
None |
Unexpected |
Monitorable |
High |
Medium |
Verbose |
Event Throttling Categories
All | Administration |
Backup and Restore | Backward Compatible Administration |
Backward Compatible Site Object Model | Business Data |
Communication | Content Deployment |
Database | Document Management |
Excel Calculation Services | |
Excel Services Administration | Excel Services Cache |
Excel Services External Data | Excel Services Session |
Excel Services Web Front End | Excel Web Access |
Excel Web Services | Feature Infrastructure |
Fields | Forms Services Administration |
Forms Services Conversion and Deployment | Forms Services Data Binding |
Forms Services Data Objects | Forms Services Deployment |
Forms Services File Open | Forms Services Object Model |
Forms Services Rendering | Forms Services Runtime |
Forms Services Runtime | Forms Services Runtime - Business Logic |
Forms Services Runtime - Data Connections | Forms Services Runtime - Session State |
Forms Services Validation | General |
Group Approval Enhanced Group Management Library | Group Approval Enhanced Group Management Pages |
Group Approval Library | Group Approval Pages |
Group Approval Schedules | Group Approval SOAP |
Information Policy Management | IRM |
Knowledge Network Server | Launcher Service |
Load Balancer Service | Long running operation infrastructure |
MCMS 2002 Migration | MS Search Administration |
MS Search Advanced Tracing | MS Search Indexing |
MS Search Propagation | MS Search Query |
MS Search Query Processor | Office Server General |
Office Server Shared Services | Project Server - General |
Project Server Active Cache Enterprise Resource Load | Project Server Active Cache Load |
Project Server Active Cache operations | Project Server Active Cache Save |
Project Server Active Directory Synchronization | Project Server Analysis Cube Building |
Project Server Archive, Restore | Project Server Calendars |
Project Server Global | Project Server Notifications |
Project Server Portfolio Management | Project Server Provisioning |
Project Server Queue | Project Server Reporting |
Project Server Resource | Project Server Security |
Project Server Server-Side Events | Project Server Sharepoint Integration |
Project Server Status Reports | Project Server Summary Resource Assignments |
Project Server Task Statusing and Updates | Project Server Timesheet |
Project Server-side Project Operations | Project Web Access |
Publishing | Publishing Cache |
Publishing Provisioning | Records Center |
Runtime | Runtime |
Server Help | Session State Service |
Setup and Upgrade | SharePoint Services |
Site Directory | Site Management |
SSO | Timer |
Timer Job | Topology |
Unified Logging Service | Upgrade |
User Profiles | Web Controls |
Web Parts | WebParts |
Workflow Features | Workflow Infrastructure |
These are the categories available for logging under the Event Throttling Category in Diagnostic logging in MOSS 2007
Wednesday, 20 February 2008
MOSS 2007 Webpart Control Events not Firing
protected override void CreateChildControls()
{
try
{
PopulateDataTable();
CreateDropDown();
base.CreateChildControls();
}
catch(Exception ex)
{...}
}
When creating a Webpart and I had the events wired up in the CreateDropDown() they would not fire but when I moved them into the CreateChildControls() they did!
All the CreateDropDown() did was populate a drop down from the table created in the PopulateDataTable() and wire up the Click event.
I haven't found an answer yet as to why this would happen but I'll look into it later but it worked for me.
Tuesday, 12 February 2008
Basic MOSS 2007 Installation
http://blogs.technet.com/josebda/archive/2006/11/07/installing-rtm.aspx
Thursday, 31 January 2008
Call of Duty 4:Modern Warfare
Wednesday, 30 January 2008
After setting the scope for the Shared Service Provider (SSP) it appears that this is used for all sites that use this SSP - that may cause a problem if we are going to use the same SSP for our public Internet facing site and an Extranet/Intranet. So more reading required. If anyone has the answer drop me a line here.
With the settings I have I want to restrict anon users, from our Internet access, from searching on the lists that we have set up for populating drop downs.
Thursday, 24 January 2008
Web Part bin vs _app_bin vs GAC
What was surprising was that there were a number of different solutions to the problem:
1. Install the dll into the bin
2. Install the dll into the GAC
3. Install the dll into the _app_bin
If the dll is installed into the GAC then it runs under full trust, if you install into the bin then Code Access Security Policy has to be applied and the wss_minimaltrust.config has to be edited, or installing into the _app_bin runs OK.
So far I have not found a definitive solution - even from good sources the response seems to be mixed as the best place for these dll's.
Well happy days!!
Friday, 18 January 2008
MOSS 2007 WebPart
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Utilities;
namespace FMWebPartImage
{
[Guid("4f37cd37-d097-41c1-9c1c-37d8faea816d")]
[XmlRoot(Namespace = "FMWebPartImage")]
[ToolboxData("<{0}:WebPart1 runat=server>")]
public class FMWebPartImage : Microsoft.SharePoint.WebPartPages.WebPart
{
public FMWebPartImage()
{
this.ExportMode = WebPartExportMode.NonSensitiveData; //Set so no export
this.ChromeType = PartChromeType.None; //Set so no title by default
}
protected string imageLocation = "";
protected string imageAlternateText = "";
protected string imageURL = "";
protected int imageHeight = 100;
protected int imageWidth = 100;
[Browsable(true),
Category("Miscellaneous"),
DefaultValue(""),
WebPartStorage(Storage.Shared),
FriendlyName("Location"),
Description("Location of image")]
public string ImageLocation
{
get
{
return this.imageLocation;
}
set
{
this.imageLocation = value;
}
}
[Browsable(true),
Category("Miscellaneous"),
DefaultValue(""),
WebPartStorage(Storage.Shared),
FriendlyName("Alternate Text"),
Description("Alternate text for image")]
public string ImageAlternateText
{
get
{
return this.imageAlternateText;
}
set
{
this.imageAlternateText = value;
}
}
[Browsable(true),
Category("Miscellaneous"),
DefaultValue(""),
WebPartStorage(Storage.Shared),
FriendlyName("Image Url"),
Description("Image click goto Url")]
public string ImageClickUrl
{
get
{
return this.imageURL;
}
set
{
this.imageURL = value;
}
}
[Browsable(true),
Category("Miscellaneous"),
DefaultValue(100),
WebPartStorage(Storage.Shared),
FriendlyName("Height"),
Description("Height of image")]
public int ImageHeight
{
get
{
return this.imageHeight;
}
set
{
this.imageHeight = value;
}
}
[Browsable(true),
Category("Miscellaneous"),
DefaultValue(100),
WebPartStorage(Storage.Shared),
FriendlyName("Width"),
Description("Width of image")]
public int ImageWidth
{
get
{
return this.imageWidth;
}
set
{
this.imageWidth = value;
}
}
protected override void Render(HtmlTextWriter writer)
{
string outHTML =
"<a href='" + imageURL + "' style='text-decoration:none;'><img src = '" + imageLocation +
"' alt = '" + imageAlternateText +
"' height = '" + imageHeight +
"' width = '" + imageWidth +
"' /%gt;</a>";
writer.Write(outHTML);
}
}
}
MOSS 2007 Webparts
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Runtime.InteropServices;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
namespace ListMenu
{
[XmlRoot(Namespace="ListMenu")]
[Guid("F10D314C-6CFF-4098-BF03-4F763099B0A5")]
[ToolboxData("<{0}:LocationDetail runat=server>{0}:LocationDetail>")]
public class ListMenuLocation : Microsoft.SharePoint.WebPartPages.WebPart
{
private DataTable tblLocation;
///
/// Set the Export Type, Chrome State/Type of the Web Part
///
public ListMenuLocation()
{
this.ExportMode = WebPartExportMode.NonSensitiveData;
this.ChromeState = PartChromeState.Normal;
this.ChromeType = PartChromeType.None;
}
///
/// Populate the DataTable with the publicly visible location
///
private void PopulateDataTable()
{
try
{
tblLocation = new DataTable();
using (SPSite spSite = SPContext.Current.Site)
{
SPList spList = spSite.AllWebs[0].Lists["Locations"];
SPQuery oQuery = new SPQuery();
...
SPListItemCollection spLIC = spList.GetItems(oQuery);
tblLocation = spLIC.GetDataTable();
}
}
catch (SPException ex)
{ throw ex; }
catch (Exception ex)
{ throw ex; }
}
protected override void CreateChildControls()
{
try
{
PopulateDataTable();
CreateDropDown();
base.CreateChildControls();
}
catch(Exception ex)
{
System.Web.UI.WebControls.TextBox message = new TextBox();
this.Controls.Add(message);
message.Visible = false;
message.Text = ex.Message.ToString();
}
}
///
/// Create and Populate the drop down
///
private void CreateDropDown()
{
System.Web.UI.WebControls.DropDownList ddlLocation = new DropDownList();
ddlLocation.ID = "LocationDropDown";
ddlLocation.DataSource = tblLocation;
ddlLocation.DataTextField = "Title";
ddlLocation.DataValueField = "TabID";
ddlLocation.DataBind();
ddlLocation.Items.Insert(0, new ListItem("Please select...", "0"));
ddlLocation.SelectedIndexChanged += new EventHandler(ddlLocation_SelectedIndexChanged);
this.Controls.Add(ddlLocation);
}
void ddlLocation_SelectedIndexChanged(object sender, EventArgs e)
{
...
WriteOutURL(redirectTo);
}
///
/// Write out the location for the redirect to a text box.
///
/// string: Redirect URL
private void WriteOutURL(string url)
{
...
}
}
}