using System;
using System.Web;
using System.Web.UI;

public partial class DefaultContent : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
	{
		Response.Cache.SetCacheability(HttpCacheability.NoCache);
		Response.Cache.SetNoServerCaching();
		Response.Cache.SetNoStore();
		Response.Cache.SetAllowResponseInBrowserHistory(true);
		Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
		Response.Cache.SetMaxAge(new TimeSpan(0));
		Response.Cache.SetValidUntilExpires(false);
		Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
	}

	protected void rsmDefault_Load(object sender, EventArgs e)
	{
		//ScriptManager scriptManager = sender as ScriptManager;
		//if (scriptManager != null)
		//{
		//    scriptManager.Services.Add(new ServiceReference { Path = string.Format("https://localhost/DebriefingSoftware.Web.Services/({0})/GridViewService.svc", HttpContext.Current.Request.ServerVariables["HTTP_ASPFILTERSESSIONID"]) });
		//}
	}

	//http://msdn.microsoft.com/en-us/library/bb398934.aspx
	protected void rsmDefault_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)
	{
		var _rsmDefault = (ScriptManager)FindControl("rsmDefault");

		if (e.Exception.Data["ExtraInfo"] != null)
		{
			_rsmDefault.AsyncPostBackErrorMessage =
				e.Exception.Message +
				e.Exception.Data["ExtraInfo"];
		}
		else
		{
			_rsmDefault.AsyncPostBackErrorMessage = e.Exception.InnerException != null ? e.Exception.InnerException.Message : e.Exception.Message;
		}
	}

    public string GenerateLastUpdateString(object serverName, object time)
    {
        return string.Format("This page was last updated on {1} for {0}", serverName, time);
    }
}
