TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ishan Bhutani
NA
22
1.2k
Time Difference
Mar 22 2017 6:17 AM
I am creating a quiz application and I want to calculate the time elapsed between the page load and the button click.
Here is the code I am trying but unable to calculate.The timeSpan show 0(Zero) as the difference even after hours.
Code Start
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
dtAlgebraLoad = DateTime.Now;
lblTimeLoad.Text = "Initial time: " + dtAlgebraLoad.ToString();
}
}
protected void btnAlgebraSubmit_Click(object sender, EventArgs e)
{
dtAlgebraNext = DateTime.Now;
lblTimeSubmit.Text = dtAlgebraNext.ToString();
}
protected void btnAlgebraNext_Click(object sender, EventArgs e)
{
TimeSpan timeSpan = dtAlgebraNext.Subtract(dtAlgebraLoad);
lblTimeDifference.Text = timeSpan.ToString();
}
Code End
Can some help me with the code.
Reply
Answers (
7
)
How to Upload Multiple File in Multiple Column In Database
SignalR real time notification using postgresql