Solved

Ways to resolve this error

Posted on 2015-01-15
8
78 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:knowlton
  • 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: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
 
LVL 5

Author Comment

by: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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 5

Author Comment

by: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: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:knowlton
ID: 40552312
Well done!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now