SharePoint 2010 aspx page not allowing RadGrid Event Handlers

3 posts, 0 answers
  1. Mark
    Mark avatar
    3 posts
    Member since:
    Nov 2016

    Posted 09 Dec 2016 Link to this post

    I have an ASPX page that works fine in a seperate development project.  I am now trying to move the page into a Visual Studio 2015 project that creates a SharePoint 2010 package.  I just want to deploy the page into the site.

    When I load the page through the SharePoint 2010 site, I get a Parser Error page saying that the event handler for OnNeedDataSource is not allowed on this page.  If I remove that event, it complains about the first event that it finds.

    Any suggestions on what I might be missing in order to get the events firing?


    The error is:

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: The event handler 'OnNeedDataSource' is not allowed in this page.

    Source Error:

    Line 37: <telerik:RadCheckBox ID="RadCheckBoxShowDisabledConnections" runat="server" Text="Show Disabled Connections">

    Line 38: </telerik:RadCheckBox>

    Line 39: <telerik:RadGrid ID="RadGridConnections" runat="server" Width="100%"

    Line 40: AllowFilteringByColumn="True"

    Line 41: AllowPaging="True" PageSize="5"
    Source File: /Pages/TestPage.aspx    Line: 39

    Version Information: Microsoft .NET Framework Version:2.0.50727.8745; ASP.NET Version:2.0.50727.8745 


    The ASPX page is:

    <%@ Assembly Name="PSC.UDCS.SP2010, Version=, Culture=neutral, PublicKeyToken=21ff67ef5617fb2f" %>
    <%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Assembly="Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

    <%@ Page Language="C#"  CodeBehind="UdcsTestPage.aspx.cs" Inherits="PSC.UDCS.SP2010.UdcsTestPage" MasterPageFile="~/_catalogs/masterpage/default.master"  %>
    <asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">

    <asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">

    <asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server">
        Unmanned Device Connection Service - Connections

    <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
                    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager>
        <h2>Unmanned Device Connections - Connection Setup</h2>
        <asp:Label runat="server" ID="CompileTime"></asp:Label>
                    <asp:Label runat="server" ID="Label1"></asp:Label>
                    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                                    <telerik:AjaxUpdatedControl ControlID="RadGridConnections" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:RadCheckBox ID="RadCheckBoxShowDisabledConnections" runat="server" Text="Show Disabled Connections">
                        <telerik:RadGrid ID="RadGridConnections" runat="server" Width="100%"
                            AllowPaging="True" PageSize="5"
                            <GroupingSettings CaseSensitive="false" />
                            <PagerStyle Mode="NextPrevAndNumeric" />
                            <MasterTableView CommandItemDisplay="TopAndBottom" Width="100%" DataKeyNames="ID, Station,Device,TemplateName" AutoGenerateColumns="False" >
                                    <telerik:GridButtonColumn CommandName="Edit" Text="Edit" UniqueName="Edit" />
                                    <telerik:GridButtonColumn ConfirmText="Disable this connection?" ConfirmDialogType="RadWindow" ConfirmTitle="Disable" CommandName="Delete" />
                                                                    <telerik:GridBoundColumn UniqueName="ID" DataField="ID" Display="False" />
                                    <telerik:GridBoundColumn UniqueName="DeviceId" DataField="DeviceId" Display="False" />
                                    <telerik:GridBoundColumn UniqueName="Station" HeaderText="Station" DataField="Station" />
                                    <telerik:GridBoundColumn UniqueName="Device" HeaderText="Device" DataField="Device" />
                                    <telerik:GridBoundColumn UniqueName="TemplateName" HeaderText="TemplateName" DataField="TemplateName" />
                                    <telerik:GridBoundColumn UniqueName="ApplicationPort" HeaderText="ApplicationPort" DataField="ApplicationPort" />
                                    <telerik:GridBoundColumn UniqueName="UseMultiHomed" HeaderText="UseMultiHomed" DataField="UseMultiHomed" />
                                    <telerik:GridBoundColumn UniqueName="Application" HeaderText="Application" DataField="Application" />
                                    <telerik:GridBoundColumn UniqueName="Access" HeaderText="Access" DataField="Access" />
                                    <telerik:GridBoundColumn UniqueName="Connection" HeaderText="Connection" DataField="Connection" />
                                    <telerik:GridBoundColumn UniqueName="WhiteListIps" HeaderText="WhiteListIps" DataField="WhiteListIps" />
        <EditFormSettings UserControlName="UdcsConnectionEdit.ascx" EditFormType="WebUserControl">
          <EditColumn UniqueName="EditCommandColumn1">
        </EditFormSettings>                        </MasterTableView>

  2. Mark
    Mark avatar
    3 posts
    Member since:
    Nov 2016

    Posted 09 Dec 2016 in reply to Mark Link to this post

    Okay, well to answer my own question (I swear that I Googled this for quite a while!)

    Acording to a TechNet post:

    "Changing the parameter "AllowServerSideScript" to true is not recommended on a SharePoint environment. It's considered as a security fail : as end-user can upload aspx page on document library, server side script on page can be dangerous.
    Instead of this, you have two solutions :
    Add your handlers on code behind (on page_load). This can be very fastidious because of page life-cycle
    Create a user control (user controls allow server side script on them), put all the content of your page in it (and all the associated code behind) and add your user control to your page."

    So, I changed my c# code behind to set up the events in the code behind, and that issue went away.

  3. Marin
    Marin avatar
    1057 posts

    Posted 14 Dec 2016 Link to this post


    Indeed the Sharepoint's default configuration does not allow such easy deploy of .aspx page and its related code-behind due to security issues related to the complied code behind file especially when the event handler in a .aspx file is located and compiled in a separate assembly.
    One way to resolve the issue is the way you're using: to register all event handlers in the code behind as well. The other option is to register the precomplied assembly containing the code behind as SafeControl in the web.config file.
    Additional information can also be found in the following links:

    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top