Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Time Difference for Page Creation time

  Asked By: Bonni    Date: Jul 21    Category: Asp.net    Views: 1558

I want to display below page creation time and so
I have two variables as:
Dim start_time As New DateTime
Dim end_time As New DateTime
First I am storing value in start_time on page pre_render as
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.PreRender
start_time = Now
End Sub

And then storing value in end_time on page load event as
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
end_time = Now
End If
** here I want to display the time difference, will it be like
lblPageCreationTime.Text = start_time - end_time , this one is giving error
End Sub
Can someone please help me here?



1 Answer Found

Answer #1    Answered By: Funsani Chalthoum     Answered On: Jul 21

When you subtract two dates you end up with a TimeSpan object. So,
lblPageCreationTime.Text = start_time - end_time is probably saying
something like the types are incompatible? Try doing something like this:

lblPageCreationTime.Text = (start_time - end_time).ToString()

Didn't find what you were looking for? Find more on Time Difference for Page Creation time Or get search suggestion and latest updates.