Esempio n. 1
0
        protected override void OnInit(EventArgs e)
        {
            LoadXsl();
            ProcessDataSources();

            formpanel = new UpdatePanel {
                ID = ID + "_UpdateFormPanel", RenderMode = UpdatePanelRenderMode.Block
            };                                                                                                     //, EnableViewState = true };

            contenttemplate           = new FormContentTemplate();
            contenttemplate.WebPart   = this;
            formpanel.ContentTemplate = contenttemplate;
            //Add on Page
            this.Controls.Add(formpanel);

            //Add Field Controls
            SetListFormFields(contenttemplate.canvas);

            formprogess = new UpdateProgress {
                AssociatedUpdatePanelID = formpanel.ID
            };
            formprogess.ProgressTemplate = new FormProgessTemplate();
            this.Controls.Add(formprogess);

            //if (TemplateDef == null)
            //{
            try
            {
                TemplateDef = TemplateDefinition.FromName(contenttemplate.canvas.ClientID, FormType, FormStyle, true, XslSourceData, cached);
                TemplateDef.AddTemplateArguments(TemplateArguments, true);
                TemplateDef.AddClientOptions(ClientOptions, true);
            }
            catch (Exception)
            {
            }
            //}

            base.OnInit(e);
        }
Esempio n. 2
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (Replacements != null)
            {
                // make the additional replacements
                foreach (var replacement in Replacements)
                {
                    CanvasHtml = CanvasHtml.Replace(replacement.Key, replacement.Value);
                }
            }

            UpdatePanel         panel    = (UpdatePanel)Container.Parent;
            FormContentTemplate template = (FormContentTemplate)panel.ContentTemplate;

            CanvasHtml = template.innerHtml;

            if (!string.IsNullOrEmpty(CanvasHtml))
            {
                PlaceButtons();

                if (Changed)
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "UpdateForm", "UpdateForm();", true);

                    var matches = Regex.Matches(CanvasHtml, "<div[^>]*>");
                    foreach (var match in matches)
                    {
                        var name = Regex.Match(match.ToString(), @"(?<=\bid="")[^""]*");

                        if ((name.ToString().ToLower() == "successful") && Result)
                        {
                            var    style     = Regex.Match(match.ToString(), @"(?<=\bstyle="")[^""]*");
                            string proccesed = match.ToString().Replace(style.ToString(), "display:block;");
                            CanvasHtml = CanvasHtml.Replace(match.ToString(), proccesed);
                            continue;
                        }

                        if ((name.ToString().ToLower() == "unsuccessful") && !Result)
                        {
                            var    style     = Regex.Match(match.ToString(), @"(?<=\bstyle="")[^""]*");
                            string proccesed = match.ToString().Replace(style.ToString(), "display:block;");
                            CanvasHtml = CanvasHtml.Replace(match.ToString(), proccesed);
                            MoveFormElements();
                            continue;
                        }

                        if (Result)
                        {
                            var    style     = Regex.Match(match.ToString(), @"(?<=\bstyle="")[^""]*");
                            string proccesed = match.ToString().Replace(style.ToString(), "display:none;");
                            CanvasHtml = CanvasHtml.Replace(match.ToString(), proccesed);
                            continue;
                        }

                        /*
                         * else
                         * {
                         *  var style = Regex.Match(match.ToString(), @"(?<=\bstyle="")[^""]*");
                         *  string proccesed = match.ToString().Replace(style.ToString(), "display:block;");
                         *  CanvasHtml = CanvasHtml.Replace(match.ToString(), proccesed);
                         *  continue;
                         *
                         * }
                         */
                    }
                }
                else
                {
                    MoveFormElements();
                }
            }

            writer.Write(CanvasHtml);

            var postbackReference = Page.ClientScript.GetPostBackEventReference(this, "ProcessForm", true);
            var postbackScript    = String.Format("function ProcessForm() {{ {0}; }}", postbackReference);

            writer.WriteLine(@"<script type=""text/javascript"">");
            writer.WriteLine(postbackScript);
            writer.WriteLine("</script>");
            //base.Render(writer);
        }