Custom function shared by many aspx pages
I have a few aspx pages which displays GridView controls. In each control I use custom functions to format displayed data. I want to put those functions in one static class. I did like this:
namespace MyNS
{
    public static class FormatFunctions
    {
        public static string Format1(string text)
        {
            return <formatted string>;
        }
        public static string Format2(string text)
        {
            return <formatted string>;
        }
    }
}
I can call those functions from codebehind file, but when I call them from aspx file like this:
<asp:TemplateField>
    <ItemTemplate>
        <%# FormatFunctions.Format1(Eval("field_name")) %>
    </ItemTemplate>
</asp:TemplateField>
I got the following error:
The name 'FormatFunctions' does not exist in the current context
How can I access those functions from aspx file. Should I add some headers to the aspx file开发者_如何学Python?
You have defined FormatFunctions as belonging to namespace "MyNS", but haven't imported it. Try this at the top of your aspx file:
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论