I have a static method (in the class CommonHelper in the namespace Common) that I want to use for including static resources that has a definition like the following:
public static string GetUrlForStaticResource(
String fileName, String folder="scripts", bool preventCaching=false)
You can see the “folder” and “preventCaching” parameters are optional as they have default values. When I call the method from a .cs file it works fine but in my .aspx I tried the following and got an error CS1501: No overload for method ‘GetUrlForStaticResource’ takes ‘1’ arguments:
<div>Example: <%= Common.CommonHelper.GetUrlForStaticResource("test.js") %></div>
If I provide all the parameters it works fine:
<div>Example: <%= Common.CommonHelper.GetUrlForStaticResource("test.js", "scripts", false) %>
</div>
What am I doing wrong? Are optional parameters not available in .aspx?
I tested this and it works fine for me. I used .NET 4.0 and CommonHelper as a static class (with no explicit constructor).
I then changed the web project to .NET 2.0. The project builds, and then I get the same error you report at runtime.