Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Create and deploy reusable controls like LabelControlCreate and deploy reusable controls like LabelControl
Previous
 
Next
New Post
8/23/2006 11:59 AM
 

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 1:48 PM
 

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
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Create and deploy reusable controls like LabelControlCreate and deploy reusable controls like LabelControl


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, 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 DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out