I recently had an issue where I converted some User Controls to code-behind model, and moved them to another directory. I then found I couldn’t reference them in code. After a post on the ASP.NET forums, I came to a solution, and devised the rules as to how you can reference a User Control in code:

  1. The control needs to have a ClassName tag in the <%@ Control %> tag (actually, I think if it doesn’t you’ll use the generated class name?)
  2. The page has to use a <%@ Reference %> tag in the .aspx file to reference the control
  3. If page uses a code-behind file, the namespace “ASP” contains all controls reference with the <%@ Reference %> tag. If it’s inline code, there’s no need for this.

If your page is inline code, you don’t have to worry about the ASP namespace. The ASP namespace is a dynamic namespace that contains the controls you referenced with the <%@ Reference %> tag in the markup file.

I hope this helps anyone having problems referencing User Controls by classname in their code. I searched for quite a while and I only got answers like “don’t use code-behind if you want to do that” or “have all your controls implement a Interface and reference them by that interface”.

Please post any comments or questions. I check my email/comments daily, so a response should be pretty quick (usually about 1 business day maximum. If I’m at a computer working, I usually respond right away). You can also contact me by email.

, ,

Earlier I posted a “solution” to a problem where I couldn’t export. I searched high and low, running through DLLs and assembly references. I thought I had it working by changing the DLL of one assembly reference the to version 10 reference (CR 2008 is version 12). I stopped the post there. Later, I realized the different assemblies were pretty integrated with each other, and you couldn’t just have different versions floating around (DUH). So I changed them all back to version 10.

Of course I still had issues with that. I forget what, but it wasn’t good. I think it wouldn’t run on the production server. That server doesn’t have Visual Studio installed, only the CR engine. The version 10 assemblies I were using were the Crystal Report packages that came with VS.NET 2008.

In order to successfully be able to use all the correct assemblies, I had to do more research. What I ended up doing was completely uninstalling Crystal Reports and reinstalling it, and configuring some Virtual Diretories. The steps and and explanation after the jump.

Read the rest of this entry

, , , , , , ,

NOTE: THIS IS WRONG. I later came across troubles with this approach. As I had a suspicion, all DLL versions have to be the same. This “solution” posted here is no longer relevant. I do, however, have a solution, which I will post shortly.

UPDATE: I’ve posted an updated solution.

(There is a solution here, skip down a ways if that’s all you care about, but the introduction might help some)

Frustrating situation at work today. Here’s the situation. I’m currently building a new report system in .NET (currently implement in classic ASP, like the rest of the site). We’re going to be using the latest version of Crystal Reports (2008, or, version 12) as it supposedly solves some issues with scheduling and other server-side issues.

I’m at a point where I’m actually starting to implement the Crystal Report components and objects into the system to produce report previews, exports, etc. The first thing I do is write the code for exporting (it’s fairly simple). First, Excel exporting, because it’s the most common format our customers/users will use.

Read the rest of this entry

, , , , , , ,