Solved

Ways to resolve this error

Posted on 2015-01-15
8
86 Views
Last Modified: 2015-01-15
Error	403	The name 'ctrlOrganizationAddSpecialities' does not exist in the current context	72	13	C:\TFS\UnionNet\UnionNet\Common\OrganizationAddSpecialtyLicensesByClassification.aspx.cs	Common

Open in new window


What is the source of this error?

How can it be resolved, short of creating a brand new web form and attempting to place the control on it?
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 40551990
Which version of .Net are you using? .Net v1.1 had this issue, where control declarations were not always generated and you had to manually add it.

Did you add the control directly to the "HTML" without clicking over to the UI Design side? This can cause .Net to not add the control declaration to the class partial portion that contains all of the declarations for your controls.

Did you remove a control and not remove a reference to it in code?
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 40552075
version of .NET:  VS 2010 .. .NET Framework:  3.5


It even does it when I create a brand new winform and put the control on it...I just tried it just now....

Can the partial class be modified...manually?

Can I force the controls to link?
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 40552112
Is the control an ASCX page? Does it exist on a master page?

If you can provide the code for the function where the error occurs, and the portion of the ASPX page there the control is defined, we can provide more pointed assistance.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 5

Author Comment

by:Tom Knowlton
ID: 40552184
Sure thing:


MAIN FORM MARKUP:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrganizationAddSpecialtiesLicensesByClassification.aspx.cs" Inherits="UnionNet.Common.OrganizationAddSpecialtiesLicensesByClassification"  MasterPageFile="../UnionNet.Master" %>

<%@ Register TagPrefix="asp" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" %>

<%@ Register src="Common/OrganizationAddSpecialtiesControl.ascx" tagname="OrganizationAddSpecialtiesControl" tagprefix="uc1" %>

<asp:Content ID="dialogContent" ContentPlaceHolderID="DialogContent" runat="server">
    
        <uc1:OrganizationAddSpecialtiesControl ID="OrganizationAddSpecialtiesControl1" 
            runat="server" />
    
   </asp:Content>

Open in new window







MAIN FORM CODE BEHIND:

NOTE:  You'll see that I have commented-out this line:

ctrlOrganizationAddSpecialities


If I do -- my code compiles.


If I uncomment the line ... the error comes back.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using NetEndeavor.Utilities;

using UnionNet.Framework;
using UnionNet.Security;

namespace UnionNet.Common
{
    public partial class OrganizationAddSpecialtiesLicensesByClassification : UnionNetPage
    {
        #region Members
        private UnionNetDialog _MasterPage;
        private int _ID;
        private int _EntID;
        private int _ModuleKey = 0;

        private string _IsReadOnly = "false";


        #endregion

        #region OnPreInit
        protected override void OnPreInit(EventArgs e)
        {
            MasterPageFilePath = UNFRAMEWORK_DIALOG_MASTER;

            base.OnPreInit(e);
        }
        #endregion

        #region OnInit
        protected override void OnInit(EventArgs e)
        {
            _ModuleKey = UnionNetUtilityMethods.GetQueryStringInt("mid");

            string isRO = UnionNetUtilityMethods.GetQueryStringValue("readOnly");
            _IsReadOnly = isRO.Length > 0 ? UnionNetUtilityMethods.GetQueryStringValue("readOnly") : "false"; ;

            switch (_ModuleKey)
            {
                case ApplicationModuleIDs.Research:
                    PageResourceRight = ResourceRights.FieldReports_Projects_Manage;
                    break;

                case ApplicationModuleIDs.FieldReports:
                    PageAddResourceRight = ResourceRights.FieldReports_Projects_Manage;
                    PageEditResourceRight = ResourceRights.FieldReports_Projects_Manage;
                    PageViewResourceRight = ResourceRights.FieldReports_Projects_View;
                    break;

                default:
                    PageResourceRight = ResourceRights.FieldReports_Projects_Manage;
                    break;
            }

            base.OnInit(e);

            _ID = UnionNetUtilityMethods.GetQueryStringInt("id");
            _EntID = UnionNetUtilityMethods.GetQueryStringInt("entID");
            //ctrlOrganizationAddSpecialities.OrganizationID = _ID;
           // ctrlOrganizationAddSpecialities.EntityID = _EntID;
           // ctrlOrganizationAddSpecialities.IsReadOnly = _IsReadOnly == "false" ? false : true;

            _MasterPage = (UnionNetDialog)Master;
            _MasterPage.DialogMode = _ID > 0 ? DialogModes.Edit : DialogModes.New;
            if (_ID > 0)
                _MasterPage.Title = String.Format(GetString("ORGANIZATION_DETAIL", true), GetString("EDIT"));
            else
                _MasterPage.Title = String.Format(GetString("ORGANIZATION_DETAIL", true), GetString("NEW"));


            _MasterPage.OKButtonClick += new OKButtonEventHandler(OnSave);

            _MasterPage.HelpButton.Visible = false;

        }
        #endregion

        #region Page_Load
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
        }
        #endregion

        #region OnPreRender
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            RegisterClientScripts();


            if (_ID > 0)
            {
                // this resets the window title, but should not change the dialog header...
                //




          //      _MasterPage.Title = ctrlOrganizationAddSpecialities.OrganizationData.Name + " - " + String.Format(GetString("ORGANIZATION_DETAIL", true), GetString("EDIT"));



            }

        }
        #endregion

        #region OnSave
        void OnSave(object sender, EventArgs e)
        {
            int newID = _ID;

            Organization org = null;
            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                org = new Organization();
                org.Load(_ID);

                OrganizationData orgData = org.Data;

            //    ctrlOrganizationAddSpecialities.Save(ref orgData);

                org.CurrentUser = CurrentUser;
                org.Data = orgData;



                if (!org.Validate())
                {
                    MessageBox(org.ValidationMessage,
                        MessageBoxButtonType.OK,
                        MessageBoxIconType.Exclaimation);

                    return;
                }


                if (NEError.NE_SUCCESS != org.Save(_ID))
                {
                    MessageBox(GetString("CRITICAL_ERROR"),
                        MessageBoxButtonType.OK,
                        MessageBoxIconType.Critical);

                    return;
                }

                newID = org.ID;
            }
            finally
            {
                if (!object.Equals(null, org))
                {
                    org.Dispose();
                }
            }

            ClientScript.RegisterClientScriptBlock(GetType(),
                "organizationDetail",
                "<script language='javascript'>window.returnValue=" + newID.ToString() + "; window.close();</script>");

        }
        #endregion


        #region RegisterClientScripts
        private void RegisterClientScripts()
        {
            //            string scripts = @"
            //			";
            //            ClientScript.RegisterClientScriptBlock(GetType(), "organization_edit_scripts", scripts, true);
        }
        #endregion
    }
}

Open in new window








USER CONTROL MARKUP:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="OrganizationAddSpecialtiesControl.ascx.cs"
    Inherits="UnionNet.Common.OrganizationAddSpecialtiesControl" %>
<%@ Register TagPrefix="asp" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" %>
<%@ Register TagPrefix="unc" Namespace="UnionNet.Framework" Assembly="UnionNetFramework" %>
<%@ Register TagPrefix="cc" Namespace="UnionNet.Framework" Assembly="UnionNetFramework" %>
<style type="text/css">
    
</style>
<div id="col1" style="float: left; width: 380px; border-right: 1px dotted #c8c8c8;
    padding: 0 8px 0 0; margin: 0 8px 0 0;">    
    <div class="FormRow">
        <cc:UNLabel ID="UNLabelLicenseClassifications" runat="server" Width="93"></cc:UNLabel>
        <unc:UNDropDown ID="UNDropDownLicenseClassifications" runat="server"  Width="257px" Required="NotRequired" />
    </div>    
</div>

Open in new window








USER CONTROL CODE BEHIND:
//-----------------------------------------------------------------------
//     OrganizationAddSpecialtiesControl.aspx.cs 
//     Copyright (c) Net Endeavor, Inc.  All rights reserved.
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using NetEndeavor.Utilities;

using UnionNet.Framework;
using UnionNet.Security;

namespace UnionNet.Common
{
	public partial class OrganizationAddSpecialtiesControl : UnionNetControl
	{
		#region Properties
		private OrganizationData _OrganizationData = new OrganizationData();
		public OrganizationData OrganizationData
		{
			get { return _OrganizationData; }
			set { _OrganizationData = value; }
		}
        
        private int _OrganizationID = 0;
		public int OrganizationID
		{
			get { return _OrganizationID; }
			set { _OrganizationID = value; }
		}

		private int _EntityID = 0;
		public int EntityID
		{
			get { return _EntityID; }
			set { _EntityID = value; }
		}

		private bool _IsReadOnly = false;
		public bool IsReadOnly
		{
			get { return _IsReadOnly; }
			set { _IsReadOnly = value; }
		}


		#endregion


		#region OnInit
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);
		}

		#endregion

		#region Page_Load
		protected void Page_Load(object sender, EventArgs e)
		{
			if ( !IsPostBack )
			{
				WindowSession.AddRemoveSessionItem( SessionKeys.ORGANIZATION_DATA );				
			}
			else
			{
				_OrganizationData = (OrganizationData)WindowSession.Get( SessionKeys.ORGANIZATION_DATA );				
			}


            if (!IsPostBack)
            {
                UNLabelLicenseClassifications.Text = GetString("SIGNATORY_STATUS");
                UnionNetListCollection.PopulateList(UNDropDownLicenseClassifications.Items, CurrentUser.UserID, 0, "", UnionNetListType.SignatoryStatus);
                UNDropDownLicenseClassifications.SelectedValue = _OrganizationData.SignatoryStatusID.ToString();
            }
		}
		#endregion


		#region OnPreRender
		protected override void OnPreRender(EventArgs e)
		{
			base.OnPreRender(e);
		}
		#endregion


		#region LoadDialogData
		private void LoadDialogData()
		{
			if ( _OrganizationID == 0 )
			{
				_OrganizationData = new OrganizationData();

				_OrganizationData.IsActive = true;
				_OrganizationData.IsValid = true;
				_OrganizationData.ID = -1;

				if ( _EntityID > 0 )
				{
					ProjectEntity entity = null;
					try
					{
						entity = new ProjectEntity();
						if ( NEError.NE_SUCCESS != entity.Load( _EntityID ) )
							throw new Exception( "Error loading project entity in OrganizationEdit.aspx" );

						_OrganizationData.IsConversion = true;
						_OrganizationData.Name = entity.Name;

			
					}
					finally
					{
						if ( !object.Equals( null, entity ) )
							entity.Dispose();
					}
				}
			}
			else
			{
				Organization organization = null;
				try
				{
					organization = new Organization();
					if ( NEError.NE_SUCCESS != organization.Load( _OrganizationID ) )
						throw new Exception( "Error loading organization in OrganizationEdit.aspx" );

					_OrganizationData = organization.Data;
				}
				finally
				{
					if ( !object.Equals( null, organization ) )
						organization.Dispose();
				}
			}

			WindowSession.Add( SessionKeys.ORGANIZATION_DATA, _OrganizationData );			

		}
		#endregion

		#region Save
		public void Save( ref OrganizationData organization )
		{
            //organization = _OrganizationData;

            //organization.SignatoryStatusID  = Convert.ToInt32(UNDropDownLicenseClassifications.SelectedValue);
            //organization.SignatoryStatus    = UNDropDownLicenseClassifications.SelectedItem.Text;
            //organization.dayAgreementStartDate = DateTime.Parse(UNDateRangeAgreement.Value);
            //organization.dayAgreementEndDate = DateTime.Parse(UNDateRangeAgreement.Value2);
            //organization.dayLiabilityInsuranceDate = UNCalendarLiabilityDate.Date;
            //organization.dayWorkersCompensationDate = UNCalendarWorkersComp.Date;
            //organization.ParentOrganizationID = Convert.ToInt32(luParentOrg.ObjectID);
            //organization.OrganizationDBA = UNTextBoxDBA.Text;


            //organization.Addresses		= (List<AddressData>)WindowSession.Get(SessionKeys.ADDRESS_LIST);
            //organization.PhoneNumbers	= (List<PhoneNumberData>)WindowSession.Get(SessionKeys.PHONE_LIST);
		}
		#endregion	
	}
}

Open in new window

0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 40552192
Is the control an ASCX page? Does it exist on a master page?

Yes .. the control is an ascx page.

It is being placed on a web form that DOES have a master page, yes.
0
 
LVL 26

Accepted Solution

by:
Shaun Kline earned 500 total points
ID: 40552242
The master page question is mute. If the control was on the master page, you would need to use the FindControl method to get the reference to your user control.

When you defined the control on the ASPX page, the ID is OrganizationAddSpecialtiesControl1, which should be the way to reference it in the code behind page. Does IntelliSense pick up ctrlOrganizationAddSpecialities or does it pick up OrganizationAddSpecialtiesControl1?
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 40552311
When you defined the control on the ASPX page, the ID is OrganizationAddSpecialtiesControl1, which should be the way to reference it in the code behind page. Does IntelliSense pick up ctrlOrganizationAddSpecialities or does it pick up OrganizationAddSpecialtiesControl1?

That was the problem...found it a few minutes ago <headslap/>
0
 
LVL 5

Author Closing Comment

by:Tom Knowlton
ID: 40552312
Well done!
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question