
Buildout
273
//if item requires approval, status is set to awaiting approval
if ((bool)(siteType[“ApprovalRequired”] ?? false))
{
item[“Status”] = “Waiting for Approval”;
SPUser Approver = GetApprover(siteType);
item[“Approver”] = new SPFieldUserValue(Approver.ParentWeb,
Approver.ID,
Approver.LoginName);
}
else
{
//otherwise status is waiting on site creation
item[“Status”] = “Waiting on Site Creation”;
}
SaveFields();
item.SystemUpdate();
CloseForm();
}
});
}
Wrox.SiteProvisioning\Layouts\Wrox.SiteProvisioning\SiteRequests.aspx.cs
This is the most complex of the event handlers. After elevating privileges (necessary to support various
security congurations because the requestor need not have contribute access to the New Site Requests
list), this code creates a new
SPListItem if needed, loads the Site Type Configuration list item for
the Site Type selected by the user, and uses that configuration list item to determine the approver (if
needed). Finally, the code sets the appropriate status for the item, saves the item, and closes the form.
Implementing the Site Type Drop-down
Next, implement the Site Type drop-down list event handler by adding the following function to
your code:
void ddlSiteType_SelectedIndexChanged(object sender, EventArgs e)
{
//if no site type is selected, we disable the URL field and return
if (ddlSiteType.SelectedValue == “0”)
{
litJSPlaceHolder.Text = “”; ...