Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

DotNetNuke Marketplace
  Ads  
Iron Speed Designer is a software development tool for building database, reporting, and forms applications for .NET without hand-coding.
 


  Sponsors  

Meet Our Sponsors

Portal Webhosting - Hosting For Developers
Red-Gate Software
MaximumASP
SourceGear - Tools for Developers
.: CounterSoft :.
telerik
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  Create and deploy reusable controls like LabelControl
Previous Previous
 
Next Next
New Post 8/23/2006 9:59 AM
User is offline Rick Miller
31 posts
10th Ranked


Create and deploy reusable controls like LabelControl 

I'm writing a module which needs a TON of settings, including a dozen fonts. So I wrote a separate ascx control (fontPicker) which I want to include in multiple locations on the settings page, so I can have just twelve fontpicker controls instead of 12 X (bold, italilc, size, name... you get the idea).

It works just fine in the development environment, but when I precompile, package and distribute to test, I started getting an error about not being able to load the global_asax file or one of its dependencies after loading the custom module (when  I took it back out, the site loaded fine).

Then I thought that what I'm doing really looks a lot like the DNN controls - say for instance the labelControl. The distinction with that control seems to be that the codebehind class is located well separate from the .ascx file - that is to say, it's in the Library portion of the directory tree and is referenced by the ascx control located in the Website portion of the tree. I assume this means that it is compiled into the DotNetNuke.dll.

So I tried something similar, moving my code file into the module's folder in the App_Code directory. I also removed the "CodeFile" setting in the ascx file, removed  the "partial" class qualifier, and declared the necessary UI variables (checkboxes, a textbox and a dropdown) in the code file, trying to mimic what was done in the labelControl.

Well, at least it compiles... but when I try to run it (even in the development environment!), I get a null reference exception when I set the first property (in this case, doing a "txtFontDescription.Attributes.Add("someAttribute", somestring)". Stepping through with the debugger, the control is definitely a nothing. yet the labelControl gets away with referencing these things (eg, "lblLabel.Text = Value" in the Text property setter).

The only twist here is that I'm a vb programmer finding my way in c#.  The variable declaration is straightforward, I think:  protected System.Web.UI.WebControls.TextBox txtFontDescription;

Any help, thoughts or insights would be appreciated. Thanks.

 
New Post 8/24/2006 11:48 AM
User is offline Rick Miller
31 posts
10th Ranked


Re: Create and deploy reusable controls like LabelControl 

Well, I don't know what I was doing wrong before, but it's sure working now.

For anybody else who gets tangled up doing this, these seem to be the essential steps:

1. Move the code for the control into the app_code folder for the module

2. Remove the "CodeFile" refernce in the ascx file

3. Remove the "partial" qualifier in the code file

4. Add declarations for all controls referenced in the code.

I could swear this is precisely what I did yesterday. Computers are soooo fickle... it couldn't be me.

Could it?

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  Create and deploy reusable controls like LabelControl
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Cestus Websites
DotNetNuke websites en services in Nederland. Cestus Websites levert websites, projectmanagent, skins, modules, training en gespecialiseerde hosting op basis van het CMS DotNetNuke.
www.dotnetnuke-websites.nl
FREE Skins, Modules & Control Panel!
Choose how much you want to pay on our Skins, Modules, Containers and Control Panel - Starting from FREE!
www.dnngroup.com
Disgrafic
Diseño y creación de portales web dinámicos :: Desarrollo de módulos personalizados :: Soluciones a medida :: Imagen Corporativa :: Tu proveedor DNN en España
www.disgrafic.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP