Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top