views:

813

answers:

2

I'm using .net 2.0. I'd like to place one of my C# methods in an inline server script block inside my ascx file because I need to update it a lot while designing. This way I don't have to compile my large project everytime.

I would like to call the method from inside my code behind file. I use to do this by inserting a virtual stub method in the codebehind file and overriding it in the ascx file. Now, since I've started using partial classes, I was expecting to be able to just call the method directly. Is this not possible?

Thanks

A: 

Unfortunately, I don't think this is possible. At design time, the partial class (*.designer.cs) mainly contains just your controls. The class that actually contains code from the script block is also generated by ASP.NET but it inherits from your main class.

See http://msdn.microsoft.com/en-us/library/ms178138.aspx for more info.

chaiwalla
A: 

I don't understand your motive... Isn't it just as easy to modify a page's codebehind as it is the .ascx file? Either way ASP.NET is going to either dynamically compile them when the file gets accessed or force your to rebuild, depending on the type of project.

Bryan
Yes, but since my project is large, compiling takes a long time. Compiling a single page is much quicker.
Mr Grieves
Once my design is done, I'll actually migrate the block to the code behind. It's just for when I'm "fiddling" with the page. Compiling each time is ridiculous.It doesn't matter. Overloading isn't so much of a pain. I was just curious about whether partial classes enabled this or not.
Mr Grieves