0

I have problem with my code-behind for page. I create aspx page and code behind for her, in my code-behind file I add breakpoint on OnLoad method. When I run my solution and go to created page Visual Studio stopped on my breakpoint and all good but in design time I cant use control dropped on my page. My page code:

<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Title="Title" Language="C#" AutoEventWireup="true" MasterPageFile="Tabs.master" Inherits="El.Elf.Meganavigaotor._TasksPage,El.Elf.Meganavigaotor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ad23d1e340f92e5d" %>

<%@ Register Assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="TabsPlaceHolder">
    <telerik:RadGrid runat="server" ID="gridTask">
    </telerik:RadGrid>
</asp:Content>

Code-behind :

namespace El.Elf.Meganavigaotor
    {
        public partial class _TasksPage:Page
        {
            private DataSet dynamicData;

            private SPWeb currentWeb { get { return SPContext.Current.Web; } }
            private SPWeb rootWeb { get { return SPContext.Current.Site.RootWeb; } }

            protected override void OnLoad(System.EventArgs e)
            {
                base.OnLoad(e);
                IEnumerable<SPList> lists = rootWeb.Lists.Cast<SPList>().Where(list => list.Title.Contains("List Name"));
                dynamicData=new DataSet();
                var _gridTask = FindControl("gridTask"); //return NULL
                //RadGrid _gridTask=this.gridTask not compile
            }   
        }
    }

3 Answers 3

1

I find 2 solution: first for normal developer and second for geek :) First solution is simple to add Aplication page from project context menu (Add than Add New Item and select Application Page from SharePoint project group):) Second - manualy add yourpage.designer.cs and add partial class similar page inherited class:

namespace El.Elf.Meganavigaotor
{
    public partial class _TasksPage
    {
        protected global::Telerik.Web.UI.RadGrid gridTask;
        protected global::Telerik.Web.UI.RadTreeView listsTree;
        protected global::Telerik.Web.UI.RadAjaxManager RadAjaxManager1;
    }
}

If select first solution all needed file created automaticaly and in second solution you need add cod for all added on the page control.

0

try adding the namespace to the top of the page.

using Telerik.Web.UI

0

Your designer file (yourpage.designer.cs) may be out of sync with the changes made to yourpage.aspx. To verify open the designer.cs file and search for the control added on the page markup.

If you do not find it then try deleting the file and recreating the file.

Or you can declare a protected variable with same name in the cs file and use it.

In your cs file declare a RadGrid variable (with same name as in aspx file) like below

protected RadGrid gridTask;

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.