I have a custom user control which is a "subscribe form". The user enters name, email etc and selects values from dropdowns I data bind from lists. I can view the page no problem and use the form but if I try to edit a page with the user control and then publish it I get the "This page contains content that is not valid. You can find more information in the affected sections."
code:
private void DataBindDropdowns()
{
string siteUrl = SPContext.Current.Site.Url;
using (SPSite oSiteCollection = new SPSite(siteUrl))
{
using (SPWeb oWebsite = oSiteCollection.OpenWeb())
{
//Bind the Title (Mr/Mrs/..) dropdown
SPList titleList = oWebsite.Lists[Constants.ListNames.SubscribeFormTitles];
if (titleList != null)
{
List<ListItem> source = new List<ListItem>();
source.Add(new ListItem("Please select", "Please select"));
source.AddRange(titleList.Items.Cast<SPListItem>()
.Select(pa => new ListItem(pa.Title, pa.Title))
.OrderBy(pa => pa.Text));
ddlTitles.DataSource = source;
ddlTitles.DataBind();
}
SPList interestList = oWebsite.Lists[Constants.ListNames.SubscribeFormInterest];
if (interestList != null)
{
var collListItems = from i in interestList.Items.Cast<SPListItem>()
where i[SPBuiltInFieldId.Title] != null
orderby i[SPBuiltInFieldId.Title]
select i;
chkInterest.DataSource = collListItems;
chkInterest.DataBind();
}
SPList formTextList = oWebsite.Lists[Constants.ListNames.SubscribeFormText];
if (formTextList != null)
{
var collListItems = formTextList.Items.Cast<SPListItem>();
ltTop.Text = collListItems.First()[Constants.FieldNames.TopText].ToString();
ltBottom.Text = collListItems.First()[Constants.FieldNames.BottomText].ToString();
SubscribeFormTitle.InnerText = collListItems.First().Title.ToString();
}
}
}
}
Is there anything obvious in the code that can cause this problem?
Thanks in advance.