public WebReply Render(object caller)
        {
            string sFlyout = (ErrorText ?? String.Empty).ToString().Length > 0 ? "example-right" : String.Empty;

            if (Type == GEType.Text || Type == GEType.Date || Type == GEType.Password)
            {
                string sSize     = size > 0 ? "size='" + size.ToString() + "'" : String.Empty;
                string sReadOnly = ReadOnly ? "READONLY" : string.Empty;
                string sClass    = ReadOnly ? "reado" : string.Empty;

                string sOut = "<td " + ColSpan + " " + Width + "><span>" + CaptionText + "</span></td><td " + ColSpan2 + "><input class='" + sClass + "' type='" + Type + "' " + sReadOnly + " name='"
                              + Name + "' " + sSize + " id='" + Name + "' " + TextBoxAttribute + " style='" + TextBoxStyle + "' value='" + TextBoxValue + "' />&nbsp;<label class='"
                              + sFlyout + "' for='" + Name + "'>" + ErrorText + "</label></td>";
                WebReply wr1 = new WebReply();
                wr1.AddWebReply(sOut, "", Section, false);
                return(wr1);
            }
            //<input type="radio" name="gender" value="male" checked> Male <br>
            if (Type == GEType.Radio)
            {
                string sSize = size > 0 ? "size='" + size.ToString() + "'" : String.Empty;
                string sOut  = "<td " + ColSpan + " " + Width + "><span>"
                               + "</span></td><td " + ColSpan2 + "><input class='"
                               + "' type='" + Type + "' " + " name='"
                               + RadioName + "' " + sSize + " id='" + Name + "' "
                               + TextBoxAttribute + " style='" + TextBoxStyle + "' value='" + TextBoxValue + "'>" + CaptionText + "</input><label class='"
                               + sFlyout + "' for='" + Name + "'>" + ErrorText + "</label></td>";
                WebReply wr1 = new WebReply();
                wr1.AddWebReply(sOut, "", Section, false);
                return(wr1);
            }
            else if (Type == GEType.Image)
            {
                string sOut = "<td colspan=2 align=center><img name='"
                              + Name + "' id='" + Name + "' src='" + URL + "' />&nbsp;</td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.DIV)
            {
                string sOut = "<div name='"
                              + Name + "' id='" + Name + "'>";
                WebReply wr1 = new WebReply();
                wr1.AddWebReply(sOut, "", Section, false);
                return(wr1);
            }
            else if (Type == GEType.Lightbox)
            {
                string sData = "<div id='div" + Name + "' name='div" + Name + "'><a id='img" + Name + "' name='img" + Name + "' data-featherlight='" + URL + "'>" + CaptionText + "</a></div>";
                Javascript = "$('#img" + Name + "').featherlightGallery();";
                WebReply wr1 = new WebReply();
                wr1.AddWebReply(sData, Javascript, Section, false);
                return(wr1);
            }
            else if (Type == GEType.HTML)
            {
                string sOut = "<div style='width:100%;' name='"
                              + Name + "' id='" + Name + "'>" + HTML + "</div>";
                WebReply wr1 = new WebReply();
                wr1.AddWebReply(sOut, Javascript, Section, false);
                return(wr1);
            }
            else if (Type == GEType.Label)
            {
                string sOut = "<td " + CaptionWidthCSS + "><span id='" + Name + "'>" + CaptionText + "</span></td>";
                if (("" + TextBoxValue).Length > 0)
                {
                    sOut += "<td>" + TextBoxValue + "</td>";
                }
                return(new WebReply(sOut, "", Section, false));
            }

            else if (Type == GEType.TreeView)
            {
                string sJS = "      $('.acidjs-css3-treeview').delegate('label input:checkbox [title=flower]', 'change', function()"
                             + "\r\n {    "
                             + " var checkbox = $(this),     nestedList = checkbox.parent().next().next(),"
                             + "\r\n       selectNestedListCheckbox = nestedList.find('label:not([for]) input:checkbox [title=flower]'); "
                             + "  \r\n     if(checkbox.is(':checked')) {"
                             + "\r\n return selectNestedListCheckbox.prop('checked', true);    }"
                             + "  \r\n     selectNestedListCheckbox.prop('checked', false);  \r\n });";

                sJS = "";

                string sHTML = "<div class=\"acidjs-css3-treeview\">";

                // iterate through the nodes
                XmlNode eleOuter = Nodes.DocumentElement;
                XmlNode oNode    = eleOuter.SelectNodes("NODES")[0].SelectNodes("Organization")[0];
                if (oNode != null)
                {
                    sHTML += "<ul>";
                }
                traversenodes(oNode);
                sHTML += sCumulativeHTML + "</div>";
                return(new WebReply(sHTML, sJS, Section, false));
            }
            else if (Type == GEType.TreeViewDummy)
            {
                string sJS = "      $('.acidjs-css3-treeview').delegate('label input:checkbox', 'change', function()"
                             + "\r\n {    "
                             + " var checkbox = $(this),     nestedList = checkbox.parent().next().next(),"
                             + "\r\n       selectNestedListCheckbox = nestedList.find('label:not([for]) input:checkbox'); "
                             + "  \r\n     if(checkbox.is(':checked')) {"
                             + "\r\n return selectNestedListCheckbox.prop('checked', true);    }"
                             + "  \r\n     selectNestedListCheckbox.prop('checked', false);  \r\n });";


                string sHTML    = "<div class=\"acidjs-css3-treeview\"><ul>";
                int    iCounter = 0;
                // iterate through the nodes
                XmlNode eleOuter = Nodes.DocumentElement;
                XmlNode oNodes   = eleOuter.SelectNodes("xolddummy")[0];

                for (int y = 0; y < oNodes.ChildNodes.Count; y++)
                {
                    XmlNode oNode    = oNodes.ChildNodes[y];
                    string  sCaption = oNode["CAPTION"].InnerText;
                    string  sName    = oNode["NAME"].InnerText;
                    iCounter++;
                    string sRow = "<li><input type='checkbox' id='node-" + iCounter.ToString()
                                  + "' checked='' /><label><input type='checkbox' /><span></span></label><label for='node-" + iCounter.ToString() + "'>" + sCaption + "</label>";
                    sHTML += sRow;

                    for (int iSubNodeCounter = 0; iSubNodeCounter < 10; iSubNodeCounter++)
                    {
                        // If Any child nodes, process here
                        XmlNode oSubNodes = oNode.SelectNodes("SUBNODES")[0];
                        sHTML += "<ul>";
                        for (int j = 0; j < oSubNodes.ChildNodes.Count; j++)
                        {
                            XmlNode oNode2    = oSubNodes.ChildNodes[j];
                            string  sCaption2 = oNode2["CAPTION"].InnerText;
                            string  sName2    = oNode2["NAME"].InnerText;
                            iCounter++;
                            string sRow2 = "<li><input type='checkbox' id='node-" + iCounter.ToString()
                                           + "' checked='' /><label><input type='checkbox' /><span></span></label><label for='node-" + iCounter.ToString() + "'>" + sCaption2 + "</label>";
                            sHTML += sRow2;
                        }
                        sHTML += "</li>";
                        sHTML += "</ul>";
                    }
                    sHTML += "</li>";
                }

                sHTML += "</ul>";
                sHTML += "</div>";

                return(new WebReply(sHTML, sJS, Section, false));
            }
            else if (Type == GEType.SortableList)
            {
                string Name2 = Name + "2";
                string ul1   = "<ul id='" + Name + "'>";
                foreach (SystemObject.LookupValue lv in LookupValues)
                {
                    //Select the Selected TextBoxValue
                    string key = lv.ID;
                    key = lv.Value;
                    string sRow = "<li class='sortable' usgdname='" + lv.Name + "' usgdcaption='" + lv.Caption + "' usgdid='" + lv.ID + "' usgdvalue='" + lv.Value + "' id='" + key + "' value='" + lv.Value + "'>" + lv.Caption + "</li>";
                    ul1 += sRow;
                }

                ul1 += "</ul>";

                string ul2 = "<ul id='" + Name2 + "'>";
                foreach (SystemObject.LookupValue lv in LookupValuesSelected)
                {
                    //Select the Selected TextBoxValue
                    string key = lv.ID;
                    key = lv.Value;
                    string sRow = "<li class='sortable' usgdname='" + lv.Name + "' usgdcaption='" + lv.Caption + "' usgdid='" + lv.ID + "' usgdvalue='" + lv.Value + "' id='" + key + "' value='" + lv.Value + "'>" + lv.Caption + "</li>";
                    ul2 += sRow;
                }

                ul2 += "</ul>";

                string html = "<td><div><table><tr><td>" + CaptionText + "</td><td>" + CaptionText2 + "</td></tr><tr><td width='"
                              + Width.ToString() + "'>" + ul1 + "</td><td width='" + Width.ToString() + "'>"
                              + ul2 + "</td></tr></table></div></td>";


                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[2];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = Name + "_Sort";

                string sJava2 = "  var sOut=''; $('#" + Name + "').closest('ul').find('li').each(function (index) "
                                + "        {         var sUSGDID = $(this)[0].getAttribute('usgdid'); "
                                + "                  var sUSGDValue = $(this)[0].getAttribute('usgdvalue'); "
                                + "                 var sUSGDCaption = $(this)[0].getAttribute('usgdcaption'); "
                                + "                 var sUSGDName = $(this)[0].getAttribute('usgdname'); "
                                + "        var s = $(this)[0].name + '[COL]' + $(this)[0].value + '[COL]' + sUSGDID + '[COL]' + sUSGDValue + '[COL]' + sUSGDCaption + '[COL]' + sUSGDName + '[ROW]';"
                                + "        sOut += s;    }); ";


                string sJava3 = "  var sOut2=''; $('#" + Name2 + "').closest('ul').find('li').each(function (index) "
                                + "        {         var sUSGDID = $(this)[0].getAttribute('usgdid'); "
                                + "                  var sUSGDValue = $(this)[0].getAttribute('usgdvalue'); "
                                + "                  var sUSGDCaption = $(this)[0].getAttribute('usgdcaption'); "
                                + "                  var sUSGDName = $(this)[0].getAttribute('usgdname'); "
                                + "        var s = $(this)[0].name + '[COL]' + $(this)[0].value + '[COL]' + sUSGDID + '[COL]' + sUSGDValue + '[COL]' + sUSGDCaption + '[COL]' + sUSGDName + '[ROW]';"
                                + "        sOut2 += s;    }); ";


                string serialize   = " " + sJava2 + sJava3 + " var order = $('#" + Name + "').sortable('toArray');  var order2=$('#" + Name2 + "').sortable('toArray'); var data = order.join(';'); var data2=order2.join(';'); ";
                string sUniqueId   = Section + "[ROWSET]" + Name + "[ROWSET]";
                string sEvent      = serialize + "postdiv(this,'sortevent','" + myClass + "','" + sMyMethod + "','[SORTABLE]" + sUniqueId + "' + sOut + '[ROWSET]'+sOut2);";
                string sIdentifier = "#" + Name + ",#" + Name2;

                string javascript = "   $('" + sIdentifier + "').sortable({     "
                                    + " stop: function(event, ui){      " + sEvent + "        },"
                                    + "connectWith: '" + sIdentifier + "'         });  $('" + sIdentifier + "').disableSelection();";


                return(new WebReply(html, javascript, Section, false));
            }
            else if (Type == GEType.UploadControl)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;

                string sEvent = "postdiv(this,'buttonevent','" + myClass + "','" + sMyMethod + "','');";
                //sEvent = "";

                string html = "<td colspan=2><form enctype='multipart/form-data' method='POST' action='Uploader.ashx'>"
                              + "<p id='DivUploadControl'></p>"
                              + "<input type='hidden' name='MAX_FILE_SIZE' value='3000000' />"
                              + "<label class='fileContainer roundbutton'>" + CaptionText
                              + "<input class='inputfile' type='file' "
                              + "id='myFile' name='myFile' multiple size=50 onchange=\"USGDFileUploader(this.form,'Uploader.ashx?parentid=" + ParentGuid + "&id=" + Id.ToString()
                              + "&parenttype=" + ParentType + "','divupload','" + myClass + "','" + sMyMethod + "','" + Section + "');" + "\" >"
                              + "</label>"
                              + "&nbsp;&nbsp;"
                              + "<div id=divupload></div>  </form></td>";
                return(new WebReply(html, "", Section, false));
            }
            else if (Type == GEType.TextArea)
            {
                string sReadOnly = ReadOnly ? "READONLY" : string.Empty;
                string sClass    = ReadOnly ? "reado" : string.Empty;
                string sColspan  = "";
                if (("" + ColSpan).Length > 0)
                {
                    sColspan = "colspan='" + ColSpan + "'";
                }
                string td1 = "";
                if (!MaskColumn1)
                {
                    td1 = "<td><span>" + CaptionText + "</span></td>";
                }
                string sOut = td1 + "<td " + TdWidth + " " + sColspan + "><textarea " + sReadOnly + " class='" + sClass + "' type='" + Type + "' name='"
                              + Name + "' rows='" + rows.ToString() + "' cols='" + cols.ToString() + "' id='"
                              + Name + "' style='width:" + Width + ";height:" + Height + ";' value='" + TextBoxValue + "'>" + TextBoxValue + "</textarea>&nbsp;<label class='"
                              + sFlyout + "' for='" + Name + "'>" + ErrorText + "</label></td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.Caption)
            {
                string sOut = "<td colspan=2><span id='" + Name + "'>" + TextBoxValue + "</span></td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.Button)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;
                string sJavascriptSuffix = IsInDialog ? "$(this).closest('.ui-dialog-content').dialog('close'); " : String.Empty;
                string sOut = "";
                if (ExtraTD)
                {
                    sOut += "<td>&nbsp;</td>";
                }
                if (!MaskBeginTD)
                {
                    sOut += "<td colspan='" + ColSpan + "'>";
                }
                sOut += "<input class=roundbutton type=button name='" + Name + "' id='" + Name + "' value='"
                        + CaptionText + "' onclick=\"" + sJavascriptSuffix + "postdiv(this,'buttonevent','" + myClass + "','" + sMyMethod + "','" + sAltGuid + "');\"  />";
                if (!MaskEndTD)
                {
                    sOut += "</td>";
                }

                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.DoubleButton)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();
                StackFrame[] stackFrames  = stackTrace.GetFrames();
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;
                string sJavascriptSuffix = IsInDialog ? "$(this).closest('.ui-dialog-content').dialog('close'); " : String.Empty;
                string sOut = "";
                if (!MaskBeginTD)
                {
                    sOut += "<td colspan='" + ColSpan + "'>";
                }
                Method = "" + Name + "_Click";

                sOut += "<input class=roundbutton type=button name='" + Name + "' id='" + Name + "' value='"
                        + CaptionText + "' onclick=\"" + sJavascriptSuffix + "postdiv(this,'buttonevent','" + myClass + "','" + Method + "','');\"  />";
                // Button2:
                Method = "" + Name2 + "_Click";

                sOut += "&nbsp;&nbsp;&nbsp;&nbsp;<input class=roundbutton type=button name='" + Name2 + "' id='" + Name2 + "' value='"
                        + CaptionText2 + "' onclick=\"" + sJavascriptSuffix + "postdiv(this,'buttonevent','" + myClass + "','" + Method + "','');\"  />";
                if (!MaskEndTD)
                {
                    sOut += "</td>";
                }
                return(new WebReply(sOut, "", Section, false));
            }

            else if (Type == GEType.IFrame)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;
                string sJavascriptSuffix = IsInDialog ? "$(this).closest('.ui-dialog-content').dialog('close'); " : String.Empty;
                string sCSS = "background-color:grey";
                string sOut = "<td><iframe style='" + sCSS + "' src='" + URL + "' name='" + Name + "' id='" + Name + "' width='" + Width + "' height='" + Height + "'> </iframe></td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.CheckBox)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;
                string sJavascriptSuffix = IsInDialog ? "$(this).closest('.ui-dialog-content').dialog('close'); " : String.Empty;
                string sCHECKED          = TextBoxValue == "true" ? "CHECKED" : "";
                string sOut = "<td>" + CaptionText + "</td><td><input class=roundbutton type=checkbox " + sCHECKED + " value='" + TextBoxValue + "' name='" + Name + "' id='" + Name + "' value='"
                              + CaptionText + "' /></td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.Anchor)
            {
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                sMyMethod = Method;
                string sJavascriptSuffix = IsInDialog ? "$(this).closest('.ui-dialog-content').dialog('close'); " : String.Empty;
                string sOut = "<td colspan=1><a name='" + Name + "' id='" + Name + "' value='"
                              + "' href=# onclick=\"" + sJavascriptSuffix + "postdiv(this,'buttonevent','" + myClass + "','" + this.Name + "_Click','');return true;\" >" + CaptionText + "</a></td>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.TableRow)
            {
                string sOut = "<tr>";
                return(new WebReply(sOut, "", Section, false));
            }
            else if (Type == GEType.Lookup)
            {
                string sReadOnly = ReadOnly ? "DISABLED" : string.Empty;
                string sClass    = ReadOnly ? "reado" : string.Empty;
                // Event
                string       myClass      = caller.GetType().ToString();
                StackTrace   stackTrace   = new StackTrace();       // get call stack
                StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
                StackFrame   callingFrame = stackFrames[1];
                MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
                string       sMyMethod    = method.Name;
                string       sEvent       = " onchange=postdiv(this,'lookupclick','" + myClass + "','" + Name + "_Selected',this.options[this.selectedIndex].value);";


                string sRows = "<td><span>" + CaptionText + "</span></td><td>" + "<select " + sReadOnly + " class='" + sClass + "' " + sEvent + " name='" + Name + "' id='" + Name + "'>";
                if (LookupValues != null)
                {
                    // Ensure we have a blank entry for empty or null values
                    string sBlankSelected = "";
                    if (TextBoxValue.Trim() == "")
                    {
                        sBlankSelected = "SELECTED";
                    }
                    sRows += "<option " + sBlankSelected + " classid='" + "000" + "' value='" + "" + "'>" + "" + "</option>";
                    foreach (SystemObject.LookupValue lv in LookupValues)
                    {
                        string sSelected = String.Empty;
                        if (lv.Value == TextBoxValue)
                        {
                            sSelected = "SELECTED";
                        }
                        sRows += "<option " + sSelected + " USGDID='" + lv.ID + "' USGDVALUE='" + lv.Value + "' value='" + lv.Value + "'>" + lv.Caption + "</option>";
                    }
                }
                sRows += "</select></td>";
                return(new WebReply(sRows, "", Section, false));
            }
            else
            {
                string sErr = "";
            }
            return(new WebReply("", "", Section, false));
        }
Beispiel #2
0
        public WebReply GetWebList(string sql, string sTitle, string sSectionName, string CommentsRow, string SourceTable, object caller, bool bRemoveDiv)
        {
            string     myClass    = caller.GetType().ToString();
            StackTrace stackTrace = new StackTrace();

            StackFrame[] stackFrames  = stackTrace.GetFrames(); // get method calls (frames)
            StackFrame   callingFrame = stackFrames[1];
            MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
            string       sMyMethod    = method.Name;

            // CONTEXT MENU
            AddContextMenuitem(".", "", ".");

            string htmlCMI = "";

            foreach (ContextMenuItem cm1 in listContextMenuItems)
            {
                string sRow = "";
                sRow     = "   \"" + cm1.Name + "\": {name: \"" + cm1.Caption + "\", icon: \"" + cm1.Caption + "\"},";
                htmlCMI += sRow;
            }

            string sContextMenuCssClass = "context-menu-" + CleanName(sSectionName);

            if (htmlCMI.Length > 0)
            {
                htmlCMI = htmlCMI.Substring(0, htmlCMI.Length - 1);
            }
            string sContextEvent = " onclick=\"var sUSGDID = $(this)[0].getAttribute('usgdid');postdiv(this,'contextmenu','" + myClass + "','" + sMyMethod + "_ContextMenu_'+key,USGDID);\"";

            sContextEvent = " var sUSGDID = $(this)[0].getAttribute('usgdid');postdiv(this,'contextmenu','" + myClass + "','" + sMyMethod + "_ContextMenu_'+key,sUSGDID);";


            string sContextMenu = "  $(function() {   $.contextMenu({     selector: '." + sContextMenuCssClass + "',        callback: function(key, options) { " +
                                  "       " + sContextEvent + "            },"
                                  + "       items: {  " + htmlCMI + "                     }                    });"
                                  + "       $('." + sContextMenuCssClass + "').on('click', function(e){      console.log('clicked', this);        })        });";

            bool   Expanded       = !(sys.GetObjectValue(sSectionName, "ExpandableSection" + myClass + sMyMethod) == "EXPANDED" ? true : false);
            string sExpandedClass = Expanded ? "icon-minus" : "icon-plus";

            sExpandedClass = Expanded ? "icon-chevron-up" : "icon-chevron-down";

            string sAddNewButton = "<span onclick=postdiv(this,'addnew','" + myClass + "','" + sMyMethod + "_AddNew',''); style='float:right;' class='"
                                   + "icon-plus" + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";

            string sExpandButton = "<span onclick=postdiv(this,'expand','" + myClass + "','" + sMyMethod + "',''); style='float:right;' class='"
                                   + sExpandedClass + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";


            // Button for Exporting the Row (CSV printer icon)
            string sExportButton = "<span onclick=postdiv(this,'export','" + myClass + "','" + sMyMethod + "_Export',''); style='float:right; cursor:pointer;' class='"
                                   + "icon-print" + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
            string sButtons = "";

            if (bShowRowExport)
            {
                sButtons += sExportButton;
            }
            sButtons += sExpandButton + sAddNewButton; //These buttons end up going in reverse order.
            string html = "";

            if (!bRemoveDiv)
            {
                html += "<div id='" + sSectionName + "' name='" + sSectionName + "'>";
            }
            string sFullTitle = sTitle;

            if (OptionalHeaderComments != null)
            {
                sFullTitle += " " + OptionalHeaderComments;
            }
            html += "<table frame=box cellspacing=4 cellpadding=4 width=100% xclass=TFtable style='xmin-eight:1vh'>"
                    + "<tr><th colspan=20 cellpadding=0 cellspacing=0 class='ui-dialog-titlebar ui-corner-all ui-widget-header'>"
                    + "<span class='ui-dialog-title'>" + sFullTitle + "</span>" + sButtons + "</th></tr>";
            // Custom Context Sensitive menu and event, and Dispatch Function


            // Instead of tfTable,  background: grey;  alternate with this:

            if (Expanded)
            {
                USGDTable dt = null;
                try
                {
                    dt = sys.GetUSGDTable(sql, SourceTable);
                }
                catch (Exception ex)
                {
                    string sErr = html + "<tr><td>" + ex.Message + "</td></tr></table></div>";

                    WebReply wr5 = new WebReply();
                    wr5.AddWebReply(sErr, "", "Error Dialog", false);
                    return(wr5);
                }
                // Column Names
                string sHeader = "<TR class='Head1'>";
                for (int c = 0; c < dt.Cols; c++)
                {
                    string sCN  = dt.ColumnNames[c];
                    string sKey = SourceTable.ToUpper() + "," + sCN.ToUpper();

                    string sCaption = sys.GetFieldCaption(SourceTable, sCN);

                    bool   bCommentsColumn = false;
                    string sColspan        = string.Empty;

                    if (sCaption.ToUpper() == CommentsRow.ToUpper())
                    {
                        bCommentsColumn = true;
                    }
                    bool bMasked = false;
                    if (bCommentsColumn)
                    {
                        //sHeader += "</TR><TR>";
                        //sColspan = "colspan='" + dt.Cols.ToString() + "'";
                        //sCaption = "";
                        bMasked = true;
                    }
                    // Mask column if its a primary key guid

                    if (sCaption.ToUpper() == "ID" || sCaption.ToUpper() == "CLOAK" || sCaption.ToUpper() == "BATCHID")
                    {
                        bMasked = true;
                    }
                    if (!bMasked)
                    {
                        // Icon OrderBy
                        string sOrderByClass = sys.GetObjectValue(sSectionName, "OrderByClass" + sCN) == "down" ? "icon-chevron-up" : "icon-chevron-down";
                        string sButtons2     = "<span onclick=postdiv(this,'OrderByClick','" + myClass + "','" + sMyMethod + "_OrderByClick','" + sCN + "'); style='float:right;' class='"
                                               + sOrderByClass + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
                        sHeader += "<th align=left " + sColspan + "class='ui-dialog-titlebar' style='border-bottom: grey thin solid'>" + sCaption + sButtons2 + "</th>";
                    }
                }
                sHeader += "</TR>";
                html    += sHeader;
                // RENDER VALUES
                for (int y = 0; y < dt.Rows; y++)
                {
                    string sID         = dt.GuidValue(y, "Id").ToString();
                    string sOnRowClick = "postdiv(this,'rowclick','" + myClass + "','" + sMyMethod + "_RowClick','" + sID + "');";
                    // This is where we render each weblist ROW of data
                    bool bRowHighlighted = false;
                    bool bRowCloaked     = false;
                    //Prescan row to see if highlighted
                    for (int xCol = 0; xCol < dt.Cols; xCol++)
                    {
                        string sCaption = dt.ColumnNames[xCol];
                        string sValue   = dt.Value(y, xCol).ToString();
                        if (sCaption.ToUpper() == "USERNAME" && sValue == sys.Username)
                        {
                            bRowHighlighted = true;
                        }
                    }
                    if (bSupportCloaking)
                    {
                        string sValue = (dt.Value(y, "Cloak") ?? "").ToString();
                        if (clsStaticHelper.GetDouble(sValue) == 1)
                        {
                            bRowCloaked = true;
                        }
                    }
                    string sSpecialCSS = bRowHighlighted && bShowRowHighlightedByUserName ? "Activated" : "";

                    if (this.CurrentAltRow > this.AlternatingRows)
                    {
                        this.CurrentAltRow = 0;
                    }
                    string sAltCSS = "";
                    if ((this.AlternatingRows == 1 && this.CurrentAltRow == 0) || (this.AlternatingRows == 3 && this.CurrentAltRow < 2))
                    {
                        sAltCSS = "Alternated";
                    }
                    else
                    {
                        sAltCSS = AlternationColor;
                    }
                    this.CurrentAltRow++;

                    string sComments = "";
                    for (int xx = 0; xx < dt.Cols; xx++)
                    {
                        string sCaption = dt.ColumnNames[xx];
                        string sValue   = dt.Value(y, xx).ToString();

                        if (sCaption.ToUpper() == CommentsRow.ToUpper())
                        {
                            int iColCt = dt.Cols - 2;

                            string sColspan = "colspan='" + iColCt.ToString() + "'";
                            sComments  = "<TR class='" + sContextMenuCssClass + " " + sAltCSS + "'  >";
                            sComments += "<TD class='ui-dialog-title' style='float:none;border-top:solid 1px;color:gray' " + sColspan + ">" + sValue + "</TD></TR>";
                            html      += sComments;
                        }
                    }


                    // Add the context sensitive right click menu here:
                    string sRow = "<TR usgdid='" + sID + "'  class='" + sContextMenuCssClass + " " + sSpecialCSS + " " + sAltCSS
                                  + "'   onclick=\"$(this).addClass('Activated').siblings().removeClass('Activated');" + sOnRowClick + "\">";

                    for (int x = 0; x < dt.Cols; x++)
                    {
                        string sValue   = dt.Value(y, x).ToString();
                        string sCaption = dt.ColumnNames[x];
                        string sColspan = string.Empty;
                        if (sCaption.ToUpper() == "USERNAME" || sCaption.ToUpper() == "MINERNAME")
                        {
                            if (bRowCloaked)
                            {
                                sValue = "Anonymous";
                            }
                        }
                        if (sCaption.ToUpper() == "STATS")
                        {
                            if (bRowCloaked)
                            {
                                sValue = "Anonymous";
                            }
                        }
                        // Mask column if its a guid
                        bool bMasked = false;
                        if (sCaption.ToUpper() == "ID" || sCaption.ToUpper() == "TICKETID" || sCaption.ToUpper() == "TICKET GUID" || sCaption.ToUpper() == "BATCHID" || sCaption.ToUpper() == "CLOAK")
                        {
                            bMasked = true;
                        }
                        if (sCaption.ToUpper() == CommentsRow.ToUpper())
                        {
                            bMasked = true;
                        }


                        if (!bMasked)
                        {
                            if (URLDefaultValue == null)
                            {
                                URLDefaultValue = "View";
                            }

                            if (SourceTable == "Proposal" && sCaption.ToUpper() == "NAME")
                            {
                                //string sGobjectid = dt.Value(y, "GObjectID").ToString();
                                //   if (sGobjectid.Length > 0)      sValue = sValue + " - " + sGobjectid;
                            }
                            if ((SourceTable == "Links" || SourceTable == "Proposal" || SourceTable == "Expense") && sCaption.ToUpper() == "URL")
                            {
                                string js            = "var win = window.open('" + sValue + "', '_blank'); win.focus();";
                                string sDisplayValue = URLDefaultValue == "Display" ? sValue : URLDefaultValue;
                                sValue = "<a style='text-decoration: underline; cursor: pointer;' onclick=\"" + js + "\" xhref=" + URLDefaultValue + ">" + sDisplayValue + "</a>";
                            }
                            else if (sCaption.ToUpper() == "URL")
                            {
                                string sGuid = dt.Value((int)y, "id").ToString();
                                string s1    = "<div id='div" + sGuid
                                               + "' name='div" + sGuid + "'><a id='img"
                                               + sCaption
                                               + "' name='img" + sGuid
                                               + "' data-featherlight='" + sValue + "'>" + URLDefaultValue + "</a></div>";
                                string j1 = "$('#img" + sGuid + "').featherlightGallery();";
                                sContextMenu += j1;
                                sValue        = s1;
                            }

                            if (sCaption.ToUpper() == "NEEDWRITTEN")
                            {
                                string sVal = sValue.ToString() == "1" ? "TRUE" : "FALSE";
                                sValue = sVal;
                            }
                            sRow += "<TD class='ui-dialog-title' style='float:none' " + sColspan + ">" + sValue;
                            // Add buttons to view the row
                            if (x == dt.Cols - 1)
                            {
                                //Button for Viewing the row
                                string sButtons2 = "<span align=right onclick=postdiv(this,'handview','" + myClass + "','" + sMyMethod + "','" + sID + "'); style='float:right;' class='"
                                                   + "icon-hand-up" + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
                                if (bShowRowSelect)
                                {
                                    sRow += sButtons2;
                                }
                                // Button for Deleting the Row (Trash Icon)
                                string sButtons3 = "<span align=right onclick=postdiv(this,'handview','" + myClass + "','" + sMyMethod
                                                   + "_Delete_Click','" + sID + "'); style='float:right;' class='"
                                                   + "icon-trash" + "'>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
                                if (bShowRowTrash)
                                {
                                    sRow += sButtons3;
                                }
                            }
                            sRow += "</TD>";
                        }
                    }

                    sRow += "</TR>";
                    html += sRow;
                }
            }

            html += "</TABLE><p>";
            if (!bRemoveDiv)
            {
                html += "</div>";
            }
            string javascript = sContextMenu;

            WebReply wr = new WebReply(html, javascript, sSectionName, false);

            return(wr);
        }
        public WebReply Render(object caller, bool ClearScreen)
        {
            string     myClass    = caller.GetType().ToString();
            StackTrace stackTrace = new StackTrace();

            StackFrame[] stackFrames  = stackTrace.GetFrames();
            StackFrame   callingFrame = stackFrames[1];
            MethodInfo   method       = (MethodInfo)callingFrame.GetMethod();
            string       sMyMethod    = method.Name;
            // Button for Expand-Collapse
            string sExpandedClass = Expanded ? "icon-minus" : "icon-plus";

            sExpandedClass = Expanded ? "icon-chevron-up" : "icon-chevron-down";
            string sExpandButton = GetHeaderButton("expand", myClass, sMyMethod, sExpandedClass);
            string sEditButton   = "";

            if (SecMode == SystemObject.SectionMode.View)
            {
                sEditButton = GetHeaderButton("edit", myClass, sMyMethod + "_EditClick", "icon-pencil");
            }

            string sButtons = sExpandButton + sEditButton;
            // Button for Edit
            string divname      = this.Name;
            string sNarrative   = "";
            string sBorderStyle = "";
            string sFrameStyle  = "";

            if (SecMode == SystemObject.SectionMode.View)
            {
                sNarrative = "View";
            }
            else if (SecMode == SystemObject.SectionMode.Add)
            {
                sNarrative = "Add";
            }
            else if (SecMode == SystemObject.SectionMode.Edit)
            {
                sNarrative = "Edit";
            }
            else if (SecMode == SystemObject.SectionMode.Customize)
            {
                sNarrative = "Customize";
            }
            string FriendlyName = this.Name;

            if (!this.MaskSectionMode && false)
            {
                FriendlyName += " <font size=1>[" + sNarrative + "]</font>";
            }


            string sDivClass = "class='dragContent'";

            if (SecMode == SystemObject.SectionMode.Customize)
            {
                sBorderStyle = "style='border-top: solid 1px; border-bottom:solid 1px; border-left: solid 1px; border-right:solid 1px;'";
            }
            else
            {
                sFrameStyle = "frame=box";
            }


            // CONTEXT MENU
            AddContextMenuitem("Customize", "Customize", "Customize");


            string htmlCMI = "";

            foreach (Weblist.ContextMenuItem cm1 in listContextMenuItems)
            {
                string sRow = "";
                sRow     = "   \"" + cm1.Name + "\": {name: \"" + cm1.Caption + "\", icon: \"" + cm1.Caption + "\"},";
                htmlCMI += sRow;
            }

            string sContextMenuCssClass = "context-menu-" + CleanName(divname);



            string sOut = "<div id='" + divname + "' " + sDivClass + " name='" + divname + "'><table " + sBorderStyle + " class='" + sContextMenuCssClass + "' " + sFrameStyle + " cellspacing=5 cellpadding=5 width=100%>"
                          + "<tr><th colspan=10 cellpadding=0 cellspacing=0 style='border-bottom: grey thin solid' class='ui-dialog-titlebar ui-corner-all ui-widget-header'>"
                          + "<span class='ui-dialog-title'>" + FriendlyName + "</span>" + sButtons + "</th></tr>";

            string javascript = "";

            if (htmlCMI.Length > 0)
            {
                htmlCMI = htmlCMI.Substring(0, htmlCMI.Length - 1);
            }
            string sContextEvent = " onclick=postdiv(this,'contextmenu','" + myClass + "','" + sMyMethod + "_ContextMenu_'+key,'');";
            string sContextMenu  = "  $(function() {   $.contextMenu({     selector: '." + sContextMenuCssClass + "',        callback: function(key, options) { " +
                                   "       " + sContextEvent + "            },"
                                   + "       items: {  " + htmlCMI + "                     }                    });"
                                   + "       $('." + sContextMenuCssClass + "').on('click', function(e){      console.log('clicked', this);        })        });";



            javascript += sContextMenu;

            int iCurCol       = 0;
            int iCurCellCount = 0;
            int iCurRowCount  = 0;

            if (Expanded)
            {
                foreach (KeyValuePair <string, object> entry in _controls)
                {
                    Edit ge = (Edit)entry.Value;
                    if (iCurCol == 0)
                    {
                        sOut += "<TR>";
                    }

                    WebReply wr          = ge.Render(caller);
                    string   sDivWrapper = "divWrapper" + Guid.NewGuid().ToString();

                    if (SecMode == SystemObject.SectionMode.Customize)
                    {
                        string sObject = ge.CaptionText + ": " + ge.TextBoxValue;
                        string susgdid = Guid.NewGuid().ToString();
                        string sCoords = "coords" + iCurCol.ToString() + "-" + iCurRowCount.ToString();
                        sOut += "<td " + sBorderStyle + "><span usgdid='z" + susgdid + "' usgdname='" + sCoords + "' usgdcaption='" + sCoords + "'></span><div class='drag1'>"
                                + "<span usgdcaption='" + ge.CaptionText + "' usgdname='" + ge.Name + "' usgdid='" + susgdid
                                + "' usgdvalue='" + ge.TextBoxValue + "' >" + sObject + "&nbsp;</span></div></td>";
                    }
                    else
                    {
                        sOut += "<td>" + wr.Packages[0].HTML + "</td>";
                    }
                    javascript += wr.Packages[0].Javascript;
                    iCurCol++;
                    iCurCellCount++;
                    if (iCurCol == ColumnCount)
                    {
                        if (iCurRowCount == 0)
                        {
                            if (DisplayPictureHTML != null)
                            {
                                sOut += "<td rowspan=5>" + DisplayPictureHTML + "</TD>";
                            }
                        }

                        iCurRowCount++;
                        sOut   += "</TR>";
                        iCurCol = 0;
                    }
                }
            }

            sOut += "</TR>";
            sOut += "</table></div><p>";
            WebReply wr1 = new WebReply();

            string sJavaEventAfterDrop = "  var sOut=''; $(this).closest('table').find('span').each(function (index) "
                                         + "        {        var sUSGDID = $(this)[0].getAttribute('usgdid'); "
                                         + "                 var sUSGDValue = $(this)[0].getAttribute('usgdvalue'); "
                                         + "                 var sUSGDCaption = $(this)[0].getAttribute('usgdcaption'); "
                                         + "                 var sUSGDName = $(this)[0].getAttribute('usgdname'); "
                                         + "        var s = $(this)[0].name + '[COL]' + $(this)[0].value + '[COL]' + sUSGDID + '[COL]' + sUSGDValue + '[COL]' + sUSGDCaption + '[COL]' + sUSGDName + '[ROW]';"
                                         + "      if (sUSGDID != null) {  if (sUSGDID.length > 0)   sOut += s;  }  }); ";

            string sDropEvent = sJavaEventAfterDrop + "postdiv(this,'dropevent','" + myClass + "','" + sMyMethod + "','[DROPPABLE]"
                                + divname + "[/DROPPABLE][DATA]' + sOut + '[/DATA]');";


            string DraggableJavascript = "     $('.drag1').draggable({  "
                                         + "    helper: 'clone',        start: function(event, ui)"
                                         + "    {            c.tr = this;                c.helper = ui.helper;            }    });"
                                         + "   $('.drag1').droppable({     drop: function(event, ui) {     "
                                         + "  "
                                         + "   $(c.helper).remove();        }     });";

            DraggableJavascript = " var myDraggedObject = null; $(function() { $( '.drag1' ).draggable({containment:parent});  }); ";
            DraggableJavascript = "var myDraggedObject = null; var myOriginalHTML = null; $('.drag1').draggable(  "
                                  + "{ revert: function(droppableContainer) {         if(droppableContainer) { var thisisvalid='valid';    }       else {        myDraggedObject.innerHTML=myOriginalHTML;     } } ,"
                                  + "      helper: 'clone', "
                                  + "      containment: '.dragContent', cursor:'move', snap: true, snapMode: 'inner',"
                                  + "     start: function(event, ui)   {  myDraggedObject = this; this.setAttribute('usgdname','test'); "
                                  + "       myOriginalHTML = myDraggedObject.innerHTML; myDraggedObject.setAttribute('usgdname','bye3');  "
                                  + "       myDraggedObject.innerHTML ='&nbsp;';      }   });  "
                                  + "                $('.drag1').droppable(  {drop: function(event, ui) { ui.helper[0].innerHTML='bye'; myDraggedObject.innerHTML = myOriginalHTML; ui.draggable.detach().appendTo($(this));   " + sDropEvent + "  }     }); ";

            if (SecMode == SystemObject.SectionMode.Customize)
            {
                javascript += DraggableJavascript;
            }
            wr1.AddWebReply(sOut, javascript, Name, false);
            WebReplyPackage wrp1 = wr1.Packages[0];

            wrp1.ClearScreen = ClearScreen;
            wr1.Packages[0]  = wrp1;
            return(wr1);
        }