Beispiel #1
0
        public static WxeForm Replace(HtmlForm htmlForm)
        {
            WxeForm newForm = new WxeForm();

            if (!string.IsNullOrEmpty(htmlForm.Method))
            {
                newForm.Method = htmlForm.Method;
            }
            if (!string.IsNullOrEmpty(htmlForm.Enctype))
            {
                newForm.Enctype = htmlForm.Enctype;
            }
            if (!string.IsNullOrEmpty(htmlForm.Target))
            {
                newForm.Target = htmlForm.Target;
            }
            if (!string.IsNullOrEmpty(htmlForm.DefaultButton))
            {
                newForm.DefaultButton = htmlForm.DefaultButton;
            }
            if (!string.IsNullOrEmpty(htmlForm.DefaultFocus))
            {
                newForm.DefaultFocus = htmlForm.DefaultFocus;
            }

            while (htmlForm.Controls.Count > 0)
            {
                newForm.Controls.Add(htmlForm.Controls[0]);
            }

            Control parent = htmlForm.Parent;

            if (parent != null)
            {
                int htmlFormIndex = parent.Controls.IndexOf(htmlForm);
                if (htmlFormIndex >= 0)
                {
                    parent.Controls.RemoveAt(htmlFormIndex);
                    parent.Controls.AddAt(htmlFormIndex, newForm);
                }
                else
                {
                    parent.Controls.Add(newForm);
                }
            }

            newForm.ID   = htmlForm.ID;
            newForm.Name = htmlForm.Name;
            return(newForm);
        }
        private void HandlePagePreInit(object sender, EventArgs eventArgs)
        {
            var existingForm = FindHtmlForm();

            // Can only be NULL without an exception during design mode
            if (existingForm == null)
            {
                return;
            }

            _wxeForm = WxeForm.Replace(existingForm);

            if (CurrentPageStep != null)
            {
                _page.ClientScript.RegisterHiddenField(_page, WxePageInfo.PageTokenID, CurrentPageStep.PageToken);
            }

            _wxeForm.LoadPostData += Form_LoadPostData;
        }