Reputation: 1718
Recently I've used a class as explained here to access dynamic controls during PreInit. The post is titled as "Accessing ASP.NET Page Controls During PreInit", and in local it works perfect, but on server I get the following error:
Compiler Error Message: CS1031: Type expected
Source Error:
Line 12: /// in turn makes our controls accessible so that we can make the calls below.
Line 13: /// </remarks>
Line 14: public static void PrepareChildControlsDuringPreInit(this Page page)
Line 15: {
Line 16: // Walk up the master page chain and tickle the getter on each one
I'd appreciate highly if someone give me a solution or an advise on the issue.
Upvotes: 2
Views: 872
Reputation: 11433
It sounds like, locally, you are running on a newer version of the .NET Framework than your server.
Extension methods are only supported (with the syntax you're using) in .NET 3.5 and later, I believe. So if you are running a lower version of the .NET Framework than that on your server, I think that would cause the compiler error you're getting (when it tries to compile on the server).
Upvotes: 2