S
softwareakash
Hi
I have a question relating to calling common functions in an aspx
page.
Here is the scenario :
I have various pages where I use repeaters to display databound data.
On all repeaters I have to format date to a specific type of string
( ie: 12hours ago, 2 days ago etc)
I have written a function for this Named : ToRelativeDateShort(string
dateTime)
I am calling this function inside the aspx page ( inside repeater )
like this
Posted : <%# ToRelativeDateShort(Eval("createddate").ToString())%>
And this is WORKING FINE, no problems in this the function, it is
being called and date is formatted as desired.
The problem is that I have to put the same function in all pages code
behind and since I have approx 50 pages
to have this functionality I have 50 instances of the same function in
all pages.
When I try to put this function in a common Procedures.cs and call it
like :
Posted : <%# Procedures.ToRelativeDateShort(Eval
("createddate").ToString())%>
It does not work, may be because the instance of the procedure class
is not created on this call. My present approach is working but its
inefficient to have 50 instances of the same function.. So I want to
ask what is the correct method to do this.. I am sure this scenario
should be very common ....
Thanks in Advance
Akash
I have a question relating to calling common functions in an aspx
page.
Here is the scenario :
I have various pages where I use repeaters to display databound data.
On all repeaters I have to format date to a specific type of string
( ie: 12hours ago, 2 days ago etc)
I have written a function for this Named : ToRelativeDateShort(string
dateTime)
I am calling this function inside the aspx page ( inside repeater )
like this
Posted : <%# ToRelativeDateShort(Eval("createddate").ToString())%>
And this is WORKING FINE, no problems in this the function, it is
being called and date is formatted as desired.
The problem is that I have to put the same function in all pages code
behind and since I have approx 50 pages
to have this functionality I have 50 instances of the same function in
all pages.
When I try to put this function in a common Procedures.cs and call it
like :
Posted : <%# Procedures.ToRelativeDateShort(Eval
("createddate").ToString())%>
It does not work, may be because the instance of the procedure class
is not created on this call. My present approach is working but its
inefficient to have 50 instances of the same function.. So I want to
ask what is the correct method to do this.. I am sure this scenario
should be very common ....
Thanks in Advance
Akash