Shared Function - Still confused

lorena

Centurion
Joined
Oct 23, 2003
Messages
134
Location
Phoenix, Arizona
I have several functions common to almost all of the pages in my web application.
According to what I have read (and this is the first time I have tried to do this), I should be able to create a class that contains the function(s) and access it from within my code (either code-behind or .aspx)
Here is the class code:
Visual Basic:
Public Class mreqFunctions
  Public Shared Function showShortDate(ByVal aDate As Object)
    If Not IsDBNull(aDate) Then
      Return aDate.ToShortDateString
    End If
  End Function
End Class
and I am using it to display dates in the ItemTemplate of a datagrid. I tried two different ways:
Visual Basic:
<ItemTemplate>
<asp:Label ID="lblReqCompDate" Runat="server" text='<%=mreqFunctions.showShortDate(DataBinder.Eval(Container.DataItem,"requested_comp_date")) %>' />
</ItemTemplate>
(just displays blank field - no error but no date either)
And this way:
Visual Basic:
<ItemTemplate>
<asp:Label ID="lblReqCompDate" Runat="server" text='<%#mreqFunctions.showShortDate(DataBinder.Eval(Container.DataItem,"requested_comp_date")) %>' />
</ItemTemplate>
Which gives me this error:BC30451: Name 'mreqFunctions' is not declared
What do I need to do to declare the function? I am using VS 2003.
I am really confused and would appreciate any help
 
Back
Top