I am developing a sandboxed feature for 2013 that includes several custom aspx pages, each with its own sandboxed web part through the SPUserCodeWebPart control. This project has had a long and winding history. We were originally going with a provider hosted add-in, but IT here could not get their act together to provide the trust relationship. I've abandoned that approach in favour of this one. The web parts house forms and the pages are called by custom ribbon actions. I can get it working beautifully on the server side, but none of the usual client side form validation works. The JS for web form validation is not emitted at all unless I add validators directly to the page, outside the web part control. This does not work obviously. You can't access outside controls from within a sandboxed web part. I have searched on this and found no other examples of people having this problem. Can I really be the only one? It would be really helpful to be able to get the web part to cause the page to emit the necessary javascript. The alternative is to hand code all of the client side validation, which admittedly is not a huge effort. I just think this is something that really ought to work, though I'll accept if it can't. Has anyone managed to solve this? Many thanks. Examples of aspx and ascx for visual web part shown below:


<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SomeCustomAction.ascx.cs" Inherits="MyFakePackage.WebParts.SomeCustomAction.WebPart1" %>
<asp:Label ID="notificationLabel" runat="server" Text=""></asp:Label>
<asp:ValidationSummary ID="validationSummary" runat="server" ShowSummary="true" ShowMessageBox="true" ForeColor="Red" Font-Size="Large" EnableClientScript="true" HeaderText="Please correct any errors below." />
<asp:Table runat="server">
            <asp:Label AssociatedControlID="textField" runat="server">Text Field</asp:Label>
            <asp:TextBox ID="textField" runat="server" CssClass="rightFloat"></asp:TextBox>
            <span>&nbsp;</span><asp:RequiredFieldValidator ID="rfTextField" runat="server" ControlToValidate="textField" ForeColor="Red" Text="Text Field cannot be blank" EnableClientScript="true"></asp:RequiredFieldValidator>
            <asp:Label AssociatedControlID="dropDown" runat="server">Drop Down</asp:Label>
            <asp:DropDownList ID="dropDown" runat="server" CssClass="rightFloat">
<div id="submitContainer">
    <asp:Button ID="submitButton" runat="server" Text="Save" OnClick="SubmitButton_Click" />

aspx ¬

<%@ Page Language="C#"
    MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"
        Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

    <asp:Content ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
        Some Custom Ribbon Action

    <asp:Content ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server">
        Some Custom Ribbon Action

    <asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
        <style type="text/css">
            body #s4-leftpanel, body #s4-ribbonrow {
                display: none;

            .s4-ca {
                margin-left: 0px;

    <asp:Content ContentPlaceHolderID="PlaceHolderLeftNavBar" runat="server"></asp:Content>

    <asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">
            SolutionId="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"  <- not the real GUID


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.