ASP.NET dooesn't allow you to have execution statements outside methods, try<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<html>
<head>
<title>Datetime</title>
<script language="C#" runat=server>
    TimeSpan ts = new TimeSpan((Int64)10e12);
    double totalms;
void Page_Load(Object o, EventArgs e)

 totalms= ts.TotalMilliseconds;
}
</script>
<body>
<font>  "<%=totalms%>"  </font> <br>
</body>
</html>