Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

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:

<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:

<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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...