2005 - Partial Classes

A

Adrian Parker

In 2003, we have a usercontrol that we reference as a type i.e. we can pass
the class around to functions to reference it. In 2005, the class is now
partial and doesn't seem to let you reference it as a type anymore, is there
a way around this ?

Thanks
Adrian
 
P

Paul Glavich [MVP ASP.NET]

Can you provide a code example?

I am not 100% sure I understand what you mean. Partial classes or not, the
end result is a referenceable type.
 
K

Kevin Spencer

I'm not sure what you're asking. What do you mean by "doesn't seem to let
you reference it as a type anymore?"

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.
 
S

Scott Allen

Can you provide a code example?

I am not 100% sure I understand what you mean. Partial classes or not, the
end result is a referenceable type.


Not for user controls, web forms, and master pages. We have to take
some extra steps to reference those types in 2.0.
 
S

Scott Allen

It depends on where you try to reference the type from....

A user control (and it's code behind) will compile into a distinct
assembly that is not referenced by any other code in a web
application.

To put a reference in place from a web form you can use an @ Reference
directive, e.g. <%@ Reference VirtualPath="~/MyUserControl.ascx" %>.

If you need to interact with the user control from a class in App_Code
you'll have to create a stub class or an interface in App_Code and
derive your user control from the stub.

I've written some information about these types of scenarios in the
following:

One More On ASP.NET 2.0 Compilation
http://odetocode.com/Blogs/scott/archive/2005/06/30/1889.aspx

Page Controllers and Stand-alone Code Migration
http://odetocode.com/Blogs/scott/archive/2005/08/01/2030.aspx

Precompilation In ASP.NET 2.0
http://odetocode.com/Articles/417.aspx

When Deployment Gets Ugly
http://odetocode.com/Blogs/scott/archive/2005/06/29/1882.aspx
 
A

Adrian Parker

Ok, we just put our 2003 files in a new area and opened up the project, it
went through a conversion process. We have many user controls that call
other functions passing references to themselves. The other functions have
a parameter of the usercontrol class type. That no longer works.
 
A

Adrian Parker

Thanks for the links Scott,

I'm not looking forward to changing our app to make this work.. it seems
like a step backwards.
 
S

Scott Allen

Sounds like you need the stub approach then.

The RTM version of 2005 should successfully migrate this code, but
like I say in the second link, you might be able to come up with an
eloquent solution on your own and decouple the controls from the
algorithms a bit.

I know it takes some work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top