Beispiel #1
0
        /***************************** PRIVATE *****************************/
        /// <summary>
        /// Creates the html objects
        /// </summary>
        private Control BuildHtmlContent()
        {
            try
            {
                HtmlObjects table = new HtmlObjects("div");
                table.AddAttribute("class", "table");

                for (int i = 0; i < _inputBox.Count; i++)
                {
                    HtmlObjects row         = new HtmlObjects("div"); row.AddAttribute("class", "row");
                    HtmlObjects cellLabel   = new HtmlObjects("div"); cellLabel.AddAttribute("class", "cell");
                    HtmlObjects cellTextBox = new HtmlObjects("div"); cellTextBox.AddAttribute("class", "cell");

                    HtmlObjects label       = new HtmlObjects("span") { Text = _inputBox[i] + ":" };
                    label.AddAttribute("class", "label");

                    TextBox textbox         = new TextBox {ID = "value" + i, CssClass = "textbox"};

                    cellLabel.AddControls(label.GetObject);
                    cellTextBox.AddControls(textbox);

                    row.AddControls(cellLabel.GetObject);
                    row.AddControls(cellTextBox.GetObject);

                    table.AddControls(row.GetObject);
                }

                return table.GetObject;
            }
            catch (Exception ex)
            {
                throw new Exception("error building html input boxs " + ex.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Builds the gridview and returns the data ready to be be insert in html control
        /// </summary>
        private Control BuildHtmlContent(List<DataTable> listResults)
        {
            try
            {
                HtmlObjects container = new HtmlObjects("div");

                for (int i = 0; i < listResults.Count; i++)
                {

                    DataTable result = listResults[i];

                    if (_titleList.Count > i)
                    {
                        HtmlObjects title = new HtmlObjects("span");
                        title.AddAttribute("class", "title");
                        title.Text = _titleList[i];

                        container.AddControls(title.GetObject);
                    }

                    HtmlObjects spacer = new HtmlObjects("div");
                    spacer.AddAttribute("class", "spacer");

                    GridView gv = new GridView
                    {
                        DataSource = result,
                        CssClass = "gridview",

                    };

                    gv.AlternatingRowStyle.CssClass = "alt";
                    gv.PagerStyle.CssClass = "pgr";

                    // Does not have a catch because if the value cant be converted it will just use the default value
                    try {
                        if (_tableWidthList.Count > i)
                            gv.Width = Unit.Pixel(Convert.ToInt32(_tableWidthList[i]));
                    } catch {}

                    gv.DataBind();

                    container.AddControls(gv);
                    container.AddControls(spacer.GetObject);
                }

                return container.GetObject;
            }
            catch (Exception ex)
            {
                throw new Exception("error building html data " + ex.Message);
            }
        }
Beispiel #3
0
        /* Get Html Objects */
        private Control GetMenusObj()
        {
            HtmlObjects navbar = new HtmlObjects("ul");
            navbar.AddAttribute("class", "navbar");

            //<img src="url" alt="some_text">
            HtmlObjects liPic = new HtmlObjects("li") {Id = "pic_container"};
            HtmlObjects pic = new HtmlObjects("img");
            pic.AddAttribute("src", "./img/logo/ntec_logo.png");
            pic.AddAttribute("alt", "");
            pic.AddAttribute("align", "middle");
            liPic.AddControls(pic.GetObject);
            navbar.AddControls(liPic.GetObject);

            foreach (MenuBarItem header in _menuBarItems)
            {
                HtmlObjects liHeader = new HtmlObjects("li");
                HtmlObjects aHeader = new HtmlObjects("a") { Text = header.Text };
                HtmlObjects ulMenu = null;

                if (header.Url != string.Empty) aHeader.AddAttribute("href", header.Url);

                if (header.SubItems.Count > 0)
                {
                    ulMenu = new HtmlObjects("ul");

                    foreach (MenuBarItem menu in header.SubItems)
                    {
                        HtmlObjects liMenu = new HtmlObjects("li");
                        HtmlObjects aMenu = new HtmlObjects("a") { Text = menu.Text };
                        HtmlObjects ulSubMenu = null;

                        if (menu.Url != string.Empty) aMenu.AddAttribute("href", menu.Url);

                        if (menu.SubItems.Count > 0)
                        {
                            ulSubMenu = new HtmlObjects("ul") { };

                            foreach (MenuBarItem subMenu in menu.SubItems)
                            {
                                HtmlObjects liSubMenu = new HtmlObjects("li");
                                HtmlObjects aSubMenu = new HtmlObjects("a") { Text = subMenu.Text };

                                if (subMenu.Url != string.Empty) aSubMenu.AddAttribute("href", subMenu.Url);

                                liSubMenu.AddControls(aSubMenu.GetObject);
                                ulSubMenu.AddControls(liSubMenu.GetObject);
                            }
                        }

                        liMenu.AddControls(aMenu.GetObject);
                        if (ulSubMenu != null) liMenu.AddControls(ulSubMenu.GetObject);

                        ulMenu.AddControls(liMenu.GetObject);
                    }
                }

                liHeader.AddControls(aHeader.GetObject);
                if (ulMenu != null) liHeader.AddControls(ulMenu.GetObject);

                // -------------------------------------------
                navbar.AddControls(liHeader.GetObject);
            }

            return navbar.GetObject;
        }
Beispiel #4
0
        public Control Get()
        {
            UserLoginData uld = null; try { uld = (UserLoginData)db_config_sessions.GetUserAuthentication(); } catch {}

            bool isUserLogOn = uld != null ? true : false;
            bool isUSerAdmin = isUserLogOn && uld.User.AdMIn == 1 ? true : false;

            HtmlObjects headerBar = new HtmlObjects("div");
            headerBar.AddAttribute("class", "headerbar");

            headerBar.AddControls(GetMenusObj()); // menus
            headerBar.AddControls(GetLoginObj(isUserLogOn, isUSerAdmin)); // login

            return headerBar.GetObject;
        }
Beispiel #5
0
        private Control GetLoginObj(bool isUserLogOn, bool isUserAdmin)
        {
            /*
            <div id="login" class="loginbox">
                <span id="btlogin">Login</span> OR <span id="btlogout">Logout</span>
                <span id="bthelp">About</span>
                <span id="btcustom">Customize</span>
                <span id="btbo">BO</span>

                <div id="logininputbox">
                    <span>user:</span>
                    <input id="btUser" type="text" runat="server" class="logintextbox"/>
                    <span>pass:</span>
                    <input id="btPass" type="password" runat="server"  class="logintextbox"/>
                    <input id="run" type="button" runat="server" value="login" class="loginbutton" onserverclick="LoginButton_ServerClick"  />
                </div>
            </div>
            */

            // <div id="login" class="loginbox">
            HtmlObjects divLogin = new HtmlObjects("div") { Id = "login" };
            divLogin.AddAttribute("class", "loginbox");

            if (isUserLogOn)
            {
                // <span id="btlogout">Logout</span>
                Button btLogout = new Button() { Text = "Logout", ID = "btlogout", CssClass = "spanbutton" };
                btLogout.Click += LogoutButton_Click;
                divLogin.AddControls(btLogout);
            }

            // <span id="btabout">About</span>
            HtmlObjects btabout = new HtmlObjects("span") { Id = "bthelp", Text = "About" };
            btabout.AddAttribute("onclick", "$('#pageContainer').attr('src','help/about.html');");
            divLogin.AddControls(btabout.GetObject);

            if (isUserLogOn)
            {
                // <span id="btcustom">Customize</span>
                HtmlObjects btcustom = new HtmlObjects("span") { Id = "btcustom", Text = "Customize" };
                btcustom.AddAttribute("href", "bo/site/cfg_user_configs.aspx");
                divLogin.AddControls(btcustom.GetObject);
            }

            if (isUserAdmin)
            {
                // <span id="btconfig">BO</span>
                HtmlObjects btBo = new HtmlObjects("span") { Id = "btbo", Text = "BO" };
                btBo.AddAttribute("onclick", "window.location='bo/backoffice.aspx';");
                divLogin.AddControls(btBo.GetObject);
            }

            // <span id="btlogin">Login</span>
            divLogin.AddControls(new HtmlObjects("span") { Id = (isUserLogOn ? "welcome" : "btlogin"), Text = (isUserLogOn ? "Welcome" : "Login") }.GetObject);

            if (!isUserLogOn)
            {
                // <div id="logininputbox">
                HtmlObjects divLoginInputBox = new HtmlObjects("div") { Id = "logininputbox" };

                //<span>user:</span>
                //<input id="btUser" type="text" runat="server" class="logintextbox"/>
                HtmlObjects spanUser = new HtmlObjects("span") { Text = "user:"******"tbUser", CssClass = "logintextbox" };

                divLoginInputBox.AddControls(spanUser.GetObject);
                divLoginInputBox.AddControls(tbUser);

                //<span>pass:</span>
                //<input id="btPass" type="password" runat="server"  class="logintextbox"/>
                HtmlObjects spanPass = new HtmlObjects("span") { Text = "pass:"******"tbPass", CssClass = "logintextbox", TextMode = TextBoxMode.Password };

                divLoginInputBox.AddControls(spanPass.GetObject);
                divLoginInputBox.AddControls(tbPass);

                //<input id="run" type="button" runat="server" value="login" class="loginbutton" onserverclick="LoginButton_ServerClick"  />
                Button btRun = new Button() { Text = "login", ID = "run", CssClass = "loginbutton" };
                btRun.Click += LoginButton_Click;

                divLoginInputBox.AddControls(btRun);

                // ----------------------------------------------------------------------
                divLogin.AddControls(divLoginInputBox.GetObject);
            }

            return divLogin.GetObject;
        }