Call a Method from within my page

Hi All,

I have a public class called 'site_functions' within my app_code folder which contains a public method called  'SystemURLsCheck'.

I have an page called list.aspx and within that page I have a Repeater control which contains bound data.

What I would like to do is as this data is bound, I would like to call the SystemURLsCheck() method.

But at the moment I get the error:

The name 'SystemURLsCheck' does not exist in the current context

<asp:HyperLink ID="HyperLink1" runat="server" 
        NavigateUrl='<%# "/site/?page=" + Eval("pgFile") %>' 
        Text='<%# Eval("pgCatLink") %>'>
Here is how I thought I would call it it...
        <asp:HyperLink ID="HyperLink1" runat="server" 
        NavigateUrl='<%# SystemURLsCheck("/site/?page=" + Eval("pgFile")) %>' 
        Text='<%# Eval("pgCatLink") %>'>
Here is my class method:
public class site_functions
        public string SystemURLsCheck(string strFileName)
            string strReturnFilename = strFileName;
        switch (strFileName)
            case "":
                strReturnFilename = "";
            case "4":
                strReturnFilename = "4";
        return strReturnFilename;

Open in new window

Who is Participating?
alexpercsiConnect With a Mentor Commented:
Make your method static:
public static string SystemURLsCheck(string strFileName)

Then on your repeater make your call like this:

site_functions.SystemURLsCheck("/site/?page=" + Eval("pgFile"))

Best Regards,
rito1Author Commented:
Excellent thanks.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.