/// <summary>
        /// Inject a reference to a CSS file into the page
        /// </summary>
        /// <param name="page">The current page object</param>
        /// <param name="name">the name of the css file - should be unique</param>
        /// <param name="file">the css file location - can be absolute or relative.</param>
        /// <param name="inHeader">true if css to be included in header, false if not</param>
        /// <param name="cssOrder">Where to include the css file in relation to the DNN css files - applies to DNN 6.1 installs only</param>
        public static void InjectCssReference(System.Web.UI.Page page, string name, string file, bool inHeader, CssInjectOrder cssOrder)
        {
            var major    = default(int);
            var minor    = default(int);
            var build    = default(int);
            var revision = default(int);
            var useDotNetNukeWebClient = false;
            var dnnWebClientOk         = false;

            if (DNNUtilities.SafeDNNVersion(major, minor, revision, build))
            {
                if (major >= 6)
                {
                    if (major == 6 && minor < 1)
                    {
                        useDotNetNukeWebClient = false;
                    }
                    else
                    {
                        useDotNetNukeWebClient = true;
                    }
                }
            }
            if (useDotNetNukeWebClient)
            {
                //use reflection to inject the css reference
                var priority = GetCssPriority(cssOrder);
                //get the imbibe type
                var imbibe = Type.GetType("DotNetNuke.Web.Client.ClientResourceManagement.ClientResourceManager, DotNetNuke.Web.Client");
                if (imbibe != null)
                {
                    //reflection call
                    //ClientResourceManager.RegisterScript(Page page, string filePath, int priority) // default provider
                    var paramTypes  = new Type[4];
                    var paramValues = new object[4];
                    paramTypes[0]  = typeof(System.Web.UI.Page);
                    paramValues[0] = page;
                    paramTypes[1]  = typeof(string);
                    paramValues[1] = file;
                    paramTypes[2]  = typeof(int);
                    paramValues[2] = priority;
                    paramTypes[3]  = typeof(string);
                    if (inHeader && inHeader)
                    {
                        paramValues[3] = "PageHeaderProvider";
                    }
                    else
                    {
                        paramValues[3] = "DnnBodyProvider";
                    }
                    //call the method to register the script via reflection
                    var registerStyleSheetMethod = imbibe.GetMethod("RegisterStyleSheet", paramTypes);
                    if (registerStyleSheetMethod != null)
                    {
                        registerStyleSheetMethod.Invoke(null, paramValues);
                        //worked OK
                        dnnWebClientOk = true;
                    }
                }
            }
            //not on DNN 6.1, so use direct method to inject the header / body.
            //note that outcome position is pot luck based on calling code.
            if (!useDotNetNukeWebClient || dnnWebClientOk == false)
            {
                if (page.Header.FindControl(name) == null)
                {
                    //764 : xhtml compliance by using html link control which closes tag without separate closing tag
                    var cssFile = new System.Web.UI.HtmlControls.HtmlLink();
                    cssFile.Attributes.Add("rel", "stylesheet");
                    cssFile.Attributes.Add("href", file);
                    cssFile.Attributes.Add("type", "text/css");
                    cssFile.ID = name;
                    page.Header.Controls.Add(cssFile);
                }
                else
                {
                    if (page.FindControl(name) == null)
                    {
                        var cssFile = new System.Web.UI.HtmlControls.HtmlLink();
                        cssFile.Attributes.Add("rel", "stylesheet");
                        cssFile.Attributes.Add("href", file);
                        cssFile.Attributes.Add("type", "text/css");
                        cssFile.ID = name;
                        page.Controls.Add(cssFile);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// RadioButton 셋팅
        /// </summary>
        /// <param name="objPage"></param>
        /// <param name="strPre"></param>
        /// <param name="nCount"></param>
        /// <param name="ReturnValue"></param>
        public static void SetRadioButton(System.Web.UI.Page objPage, string strPre, int nCount, string ReturnValue)
        {
            string strControlName;

            for (int nLoop = 1; nLoop <= nCount; nLoop++)
            {
                strControlName = strPre + nLoop.ToString();
                System.Web.UI.WebControls.RadioButton objRadioButton = (System.Web.UI.WebControls.RadioButton)objPage.FindControl(strControlName);
                if (null != objRadioButton)
                {
                    objRadioButton.Checked = (ReturnValue == nLoop.ToString()) ? true : false;
                }
            }
        }
Example #3
0
        public static List <Slip> GetAvailableSlipsDoNotUse()
        {
            List <Slip> slips = new List <Slip>(); //empty list
            Slip        s;                         //just for reading      variables expressed before the commands!
                                                   //create the connection
            int selectedDockID;

            //We need to know which dock has been selected
            System.Web.UI.Page currentPage = HttpContext.Current.Handler as System.Web.UI.Page;

            //Find controls of the LeaseSlip.aspx here
            DropDownList dropDown = (DropDownList)currentPage.FindControl("ddlLeaseSlipDock");

            //Sets the selectedDockID value to the index of the selected item in the dropdownlist
            selectedDockID = dropDown.SelectedIndex + 1;



            SqlConnection connection = MarinaDB.GetConnection();

            //create the command  for SELECT query to get the states
            string query = "SELECT ID, Width, Length, DockID, BookingStatus " +
                           "FROM Slip " +
                           "WHERE (BookingStatus = 0 " +
                           "AND DockID = " + selectedDockID + ") " +
                           "ORDER by Id";

            SqlCommand cmd = new SqlCommand(query, connection);

            try
            {
                //open the connection
                connection.Open();
                //run the command
                SqlDataReader reader = cmd.ExecuteReader(); //built-in

                //each state data returned, make state object and add to the list
                while (reader.Read()) //while there still is data to read
                {
                    s               = new Slip();
                    s.ID            = (int)reader["ID"]; //[]  indexer from chapter 13
                    s.Width         = (int)(reader["Width"]);
                    s.Length        = (int)(reader["Length"]);
                    s.DockID        = (int)(reader["DockID"]);
                    s.BookingStatus = (int)(reader["BookingStatus"]);
                    slips.Add(s);
                }
                reader.Close();
            }
            catch (Exception ex)  //error
            {
                throw ex;
            }
            finally  //executes always
            {
                connection.Close();
            }

            //return the list of slips
            return(slips);
        }
Example #4
0
        /// <summary>
        ///  리디오 버턴
        /// </summary>
        /// <param name="objPage"></param>
        /// <param name="strPre"></param>
        /// <param name="nCount"></param>
        /// <returns><returns>
        public static string GetRadioButton(System.Web.UI.Page objPage, string strPre, int nCount)
        {
            string strControlName;

            for (int nLoop = 1; nLoop <= nCount; nLoop++)
            {
                strControlName = strPre + nLoop.ToString();
                System.Web.UI.WebControls.RadioButton objRadioButton = (System.Web.UI.WebControls.RadioButton)objPage.FindControl(strControlName);
                if (null != objRadioButton)
                {
                    if (objRadioButton.Checked)
                    {
                        return(nLoop.ToString());
                    }
                }
            }

            return("0");
        }