Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SubClassing Controls
Message
De
29/07/2005 14:35:40
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01036765
Message ID:
01037074
Vues:
23
Kevin,

Thanks for the response. I'm not getting the error message now at design time. When I run the webform there is no data in the dropdown. Do I have to somehow register my business object with the page? If so, how would I cast the page object within the dropdown to the mmBusinessWebPage page? I've attempted this, but the ParentForm property is an undefined value at runtime.
    protected Facility oFacility;
    protected mmBusinessWebPage ParentForm;
    public JdaFacilityDropDownList() 
	{
	  this.ParentForm = this.Page as mmBusinessWebPage;
	  if (mmAppBase.IsRunning)
	    {
		this.ClientCode  = "BSC";
		this.oFacility = (Facility) this.ParentForm.RegisterBizObj (new Facility());
		this.BindingSource = "Facility";
		this.BindingSourceDisplayMember = "Descr";
		this.BindingSourceValueMember = "Fac_Num";
		this.oFacility.GetFacilitiesForClientCode(this.ClientCode);
 	    }//	if (mmAppBase.IsRunning)
	}//public JdaFacilityDropDownList()
>Jim,
>
>> I have a dropdown list that is going to retrieve data and populate the dropdown. The dropdownlist is a basic class inherited from the Mere Mortals Dropdownlist control. The problem I am having is that if I place code in the constructor to populate the dropdown and place the control on a webform, the control does appears as a gray box and it says Error Creating Control in red letters. If I put my mouse over the control the tooltip says "object reference not set to the instance of an object". This is, of course, in design mode. The code I am using for the dropdown list class is below.
>
>This is a Visual Studio "issue" (although it IS by design). Visual Studio runs your contorl's constructor at design time. If it can't find the objects it needs at design time, you will see the error you mentioned.sically
>
>The MM .NET Help topic "Why do I get errors when I open a component in design mode?" tells you how to get around this problem. Basically, you need to bracket your constructor code with a check that only runs your code if you are running in design mode. .NET has a built-in DesignMode property that is SUPPOSED to provide this information for you, but it doesn't work during object construction. That's why we have added the IsRunning property to MM .NET.
>
>So, your code will look something like this:
>
>
/// <summary>
>/// constructor - retrieves desired facility data based on properties.
>/// </summary>
>public JdaFacilityDropDownList() : base()
>{
>	//
>	// TODO: Add constructor logic here
>	//
>	if (mmAppBase.IsRunning)
>		this.ClientCode  = "BSC";
>		this.oFacility = new Facility();
>		this.GetFacilitiesByCustomerId(this.ClientCode);
>		this.BindingSource = "Facility";
>		this.BindingSourceDisplayMember = "Descr";
>		this.BindingSourceValueMember = "Fac_Num";
>	}
>}
>
>Regards,
Thanks

Jim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform