public void InitCurrentApp(string app)
    {
        try
        {
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
            CurrentApp.SelectedValue = app;
            Util util = new Util();
            if (app.Contains("->"))
            {
                ResetAppStateVariables();
                DesignMessage.Text = "Select an App or Click the New App Icon";
                State["SelectedDeviceType"] = Constants.IPHONE;
                //State["SelectedDeviceView"] = Constants.IPHONE;
                SetViewForDevice();
                HideAppControls();
                AppName.Text = "";
                return;
            }
            State["SelectedApp"] = app;
            AppName.Text = app;
            State["SelectedAppType"] = util.GetAppType(State);
            switch (State["SelectedAppType"].ToString())
            {
                case Constants.NATIVE_APP_TYPE:
                    Response.Redirect("TabDesignNative.aspx", false);
                    break;
                case Constants.WEB_APP_TYPE:
                     break;
                case Constants.HYBRID_APP_TYPE:
                    Response.Redirect("TabDesignHybrid.aspx", false);
                    break;
            }
            XmlUtil x_util = new XmlUtil();
            util.GetStagingAppXml(State, app);
           // State["SelectedDeviceView"] =
            State["SelectedDeviceType"] = x_util.GetAppDeviceType(State);
            if (State["SelectedDeviceType"] == null)
            {
               // State["SelectedDeviceView"] =
                State["SelectedDeviceType"] = Constants.IPHONE;
            }
            if (State["SelectedDeviceType"].ToString() == Constants.IPAD ||
                State["SelectedDeviceType"].ToString() == Constants.ANDROID_TABLET)
            {
                State["BackgroundColor"] = x_util.GetBackgroundColor(State);
            }
            DeviceType.Text = State["SelectedDeviceType"].ToString();
            SetViewForDevice();

            InitAppPages();
             DesignMessage.Text = "";

            string html = x_util.GetFirstAppPage(State);
            State["PageHtml"] = html;

            DefaultButtonImage.Text = util.GetDefaultButton(State);

            AppPages.SelectedValue = State["SelectedAppPage"].ToString();

            ShowAppControls();
        }
        catch (Exception ex)
        {
            Util util = new Util();
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
            util.LogError(State, ex);
            Message.Text = "Internal Error: " + ex.Message + ": " + ex.StackTrace;
        }
    }
    public void InitCurrentApp(string app)
    {
        try
        {
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
            CurrentApp.SelectedValue = app;
            Util util = new Util();
            if (app.Contains("->"))
            {
                ResetAppStateVariables();
                StartMessage.Style.Value = "";
                State["SelectedDeviceType"] = Constants.IPHONE;
               // State["SelectedDeviceView"] = Constants.IPHONE;
                SetViewForDevice();
                AppSelectedForTest.Visible = false;
                HideAppControls();
                return;
            }
            State["SelectedApp"] = app;
            State["SelectedAppType"] = util.GetAppType(State);
            switch (State["SelectedAppType"].ToString())
            {
                case Constants.NATIVE_APP_TYPE:
                    break;
                case Constants.WEB_APP_TYPE:
                    Response.Redirect("TabDesignWeb.aspx", false);
                    break;
                case Constants.HYBRID_APP_TYPE:
                    Response.Redirect("TabDesignHybrid.aspx", false);
                    break;
            }

            if (util.IsAppSelectedForTest(State))
                AppSelectedForTest.Visible = true;
            else
                AppSelectedForTest.Visible = false;

            XmlUtil x_util = new XmlUtil();
            util.GetStagingAppXml(State, app);
           // State["SelectedDeviceView"] =
            State["SelectedDeviceType"] = x_util.GetAppDeviceType(State);
            if (State["SelectedDeviceType"] == null )
            {
                //State["SelectedDeviceView"] =
                State["SelectedDeviceType"] = Constants.IPHONE;
            }
            DeviceType.Text = State["SelectedDeviceType"].ToString();
            SetViewForDevice();
            InitAppPages();
            StartMessage.Style.Value = "display:none";

            string html = x_util.GetFirstAppPage(State);
            State["PageHtml"] = html;

            DefaultButtonImage.Text = util.GetDefaultButton(State);

            AppPages.SelectedValue = State["SelectedAppPage"].ToString();

            ShowAppControls();
        }
        catch (Exception ex)
        {
            Util util = new Util();
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
            util.LogError(State, ex);
            Message.Text = "Internal Error: " + ex.Message + ": " + ex.StackTrace;
        }
    }