forum

Home / DeveloperSection / Forums / TimeSpan not working

TimeSpan not working

Anonymous User 2050 25-Nov-2014

Heres the code I have re arranged, but still have same problem, not able to find my start and end times on last page? How do I do this? 

public void start()
    {
        DateTime startTime = DateTime.Now;
    }
 
    protected void btnStart_Click(object sender, EventArgs e)
    {
        start();
        Response.Redirect("~/end.aspx");
    }
public void end()
    {
        DateTime endTime = DateTime.Now;
    }
    protected void btnEnd_Click(object sender, EventArgs e)
    {
        end();
        Response.Redirect("~/display.aspx");
    }
public partial class display : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        TimeSpan timeSpent = endTime - startTime;
 
        lblDisplay.Text = string.Format("Time: {0}", timeSpent);
    }
}

Now can anyone help me on this?


Updated on 26-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By