예제 #1
0
        /// <summary>
        /// Restores Page state (content & title) and launch events
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //assign as current page
            Platform.Current.Page = this;

            //create placeholder for content
            if (ContentHolder == null)
            {
                ContentHolder    = new System.Web.UI.WebControls.PlaceHolder();
                ContentHolder.ID = "phContent";
                base.Form.Controls.Clear();
                base.Form.Controls.Add(ContentHolder);
            }

            //there is no controller assigned, exit
            if (Platform.Current.Controller == null)
            {
                return;
            }

            //get title and content from the state, in case it has a different Page instance
            if (Platform.Current.PageState != null)
            {
                Title   = Platform.Current.PageState.Title;
                Content = Platform.Current.PageState.Content;
            }

            //if there is no postback, exit now and skip recovering state and launching events
            if (!IsPostBack)
            {
                return;
            }

            //keep track of wich IInputControls had ther value updated so we can reaise IInputControl.OnValueChanged
            List <IControl> updatedInputControls = new List <IControl>();

            //restore state
            foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__")))
            {
                //get posted value by user
                string postedValue = Request.Form[postedValueName];

                //get control that corresponds to this input
                IControl control = (IControl)ContentHolder.FindControl(postedValueName);

                //update control's value
                if (control is Autocomplete && ((IAutocomplete)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((IAutocomplete)control).Value = postedValue;
                }
                else if (control is Calendar && ((ICalendar)control).Value != DateTime.Parse(postedValue))
                {
                    updatedInputControls.Add(control);
                    ((ICalendar)control).Value = DateTime.Parse(postedValue);
                }
                else if (control is CheckBox && ((ICheckBox)control).Value != (postedValue == "checked"))
                {
                    updatedInputControls.Add(control);
                    ((ICheckBox)control).Value = postedValue == "checked";
                }
                else if (control is ListPicker && ((IListPicker)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((IListPicker)control).Value = postedValue;
                }
                else if (control is PasswordTextBox && ((IPasswordTextBox)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((IPasswordTextBox)control).Value = postedValue;
                }
                else if (control is TextArea && ((ITextArea)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((ITextArea)control).Value = postedValue;
                }
                else if (control is TextBox && ((ITextBox)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((ITextBox)control).Value = postedValue;
                }
            }

            //raise IInputControl.OnValueChanged events
            foreach (IControl control in updatedInputControls)
            {
                if (control is Autocomplete)
                {
                    ((Autocomplete)control).RaiseValueChanged();
                }
                else if (control is Calendar)
                {
                    ((Calendar)control).RaiseValueChanged();
                }
                else if (control is CheckBox)
                {
                    ((CheckBox)control).RaiseValueChanged();
                }
                else if (control is ListPicker)
                {
                    ((ListPicker)control).RaiseValueChanged();
                }
                else if (control is PasswordTextBox)
                {
                    ((PasswordTextBox)control).RaiseValueChanged();
                }
                else if (control is TextArea)
                {
                    ((TextArea)control).RaiseValueChanged();
                }
                else if (control is TextBox)
                {
                    ((TextBox)control).RaiseValueChanged();
                }
            }

            //raise button click events
            foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__")))
            {
                //get posted value by user
                string postedValue = Request.Form[postedValueName];

                //get control that corresponds to this input
                IControl control = (IControl)ContentHolder.FindControl(postedValueName);

                if (control is Button && postedValue == ((Button)control).Text)
                {
                    ((Button)control).Raise_Click();
                }
            }

            //raise label & image click events

            string eventTarget   = Request.Form["__EVENTTARGET"];
            string eventArgument = Request.Form["__EVENTARGUMENT"];

            //get control that corresponds to this input
            if (!string.IsNullOrWhiteSpace(eventTarget))
            {
                IControl control = (IControl)ContentHolder.FindControl(eventTarget);

                if (control is LabelButton && eventTarget == control.Name)
                {
                    ((LabelButton)control).Raise_Click();
                }
                else if (control is IImageButton && eventTarget == control.Name)
                {
                    ((ImageButton)control).Raise_Click();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Restores Page state (content & title) and launch events
        /// <para xml:lang="es">Restaura el estado de la pagina (Contenido y titulo) y lanza eventos</para>
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //assign as current page
            Platform.Current.Page = this;

            //load javascript dependencies
            Page.ClientScript.RegisterClientScriptInclude("jquery", ResolveUrl("~/js/jquery.js"));
            Page.ClientScript.RegisterClientScriptInclude("jquery-ui", ResolveUrl("~/js/jquery-ui.js"));
            Page.ClientScript.RegisterClientScriptInclude("PageSize", ResolveUrl("~/js/PageSize.js"));

            //if this is the first request, get page size
            if (!IsPostBack && Width == 0 && Height == 0)
            {
                string pageSizeJS = @"
				<script type='text/javascript'>
					$(document).ready
					(
						function()
						{
							SetPageSize();
						}
					);
				</script>"                ;

                //register javascripts
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SetPageSize", pageSizeJS);

                return;
            }

            //create placeholder for content
            if (ContentHolder == null)
            {
                ContentHolder    = new System.Web.UI.WebControls.PlaceHolder();
                ContentHolder.ID = "phContent";
                base.Form.Controls.Add(ContentHolder);
            }

            //there is no controller assigned, exit
            if (Platform.Current.Controller == null)
            {
                return;
            }

            //get title and content from the state, in case it has a different Page instance
            if (Platform.Current.PageState != null)
            {
                Title   = Platform.Current.PageState.Title;
                Content = Platform.Current.PageState.Content;
            }

            //if there is no postback, exit now and skip recovering state and launching events
            if (!IsPostBack)
            {
                return;
            }

            //keep track of wich IInputControls had ther value updated so we can reaise IInputControl.OnValueChanged
            List <IControl> updatedInputControls = new List <IControl>();

            //restore state
            foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__")))
            {
                //get posted value by user
                string postedValue = Request.Form[postedValueName];

                //get control that corresponds to this input
                IControl control = ContentHolder.FindControl(postedValueName) as IControl;

                if (control == null)
                {
                    continue;
                }

                //update control's value
                if (control is Autocomplete && ((IAutocomplete)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((IAutocomplete)control).Value = postedValue;
                }
                else if (control is Calendar && ((ICalendar)control).Value != DateTime.Parse(postedValue))
                {
                    updatedInputControls.Add(control);
                    ((ICalendar)control).Value = DateTime.Parse(postedValue);
                }
                else if (control is CheckBox && ((ICheckBox)control).Value != (postedValue == "on"))
                {
                    updatedInputControls.Add(control);
                    ((ICheckBox)control).Value = postedValue == "on";
                }
                else if (control is ListPicker && ((IListPicker)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((IListPicker)control).Value = postedValue;
                }
                else if (control is PasswordTextBox && ((IPasswordTextBox)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((IPasswordTextBox)control).Value = postedValue;
                }
                else if (control is TextArea && ((ITextArea)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((ITextArea)control).Value = postedValue;
                }
                else if (control is TextBox && ((ITextBox)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((ITextBox)control).Value = postedValue;
                }
            }

            //raise IInputControl.OnValueChanged events
            foreach (IControl control in updatedInputControls)
            {
                if (control is Autocomplete)
                {
                    ((Autocomplete)control).RaiseValueChanged();
                }
                else if (control is Calendar)
                {
                    ((Calendar)control).RaiseValueChanged();
                }
                else if (control is CheckBox)
                {
                    ((CheckBox)control).RaiseValueChanged();
                }
                else if (control is ListPicker)
                {
                    ((ListPicker)control).RaiseValueChanged();
                }
                else if (control is PasswordTextBox)
                {
                    ((PasswordTextBox)control).RaiseValueChanged();
                }
                else if (control is TextArea)
                {
                    ((TextArea)control).RaiseValueChanged();
                }
                else if (control is TextBox)
                {
                    ((TextBox)control).RaiseValueChanged();
                }
            }

            //raise button click events
            foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__")))
            {
                //get posted value by user
                string postedValue = Request.Form[postedValueName];

                //get control that corresponds to this input
                //get control that corresponds to this input
                IControl control = ContentHolder.FindControl(postedValueName) as IControl;

                if (control == null)
                {
                    continue;
                }

                if (control is Button && postedValue == ((Button)control).Text)
                {
                    ((Button)control).Raise_Click();
                }
            }

            //raise labelbutton, checkbox & image click events

            string eventTarget   = Request.Form["__EVENTTARGET"];
            string eventArgument = Request.Form["__EVENTARGUMENT"];

            //get control that corresponds to this input
            if (!string.IsNullOrWhiteSpace(eventTarget))
            {
                IControl control = (IControl)ContentHolder.FindControl(eventTarget);

                if (control is LabelButton && eventTarget == control.Name)
                {
                    ((LabelButton)control).Raise_Click();
                }
                else if (control is IImageButton && eventTarget == control.Name)
                {
                    ((ImageButton)control).Raise_Click();
                }
                else if (control is ICheckBox && eventTarget == control.Name && !updatedInputControls.Contains(control))                 //check updatedInputControls collection because checkbox is causing double event raising
                {
                    ((ICheckBox)control).Value = !((ICheckBox)control).Value;
                    ((CheckBox)control).RaiseValueChanged();
                }
            }
        }
예제 #3
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            System.Web.UI.WebControls.TextBox tb = (System.Web.UI.WebControls.TextBox)ph.FindControl("opt" + baseOption.Bvin.Replace("-", ""));
            if (tb != null)
            {
                result.SelectionData = tb.Text.Trim();
            }

            return(result);
        }
예제 #4
0
        public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            OptionSelection val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            System.Web.UI.WebControls.TextBox tb = (System.Web.UI.WebControls.TextBox)ph.FindControl("opt" + baseOption.Bvin.Replace("-", ""));
            if (tb != null)
            {
                tb.Text = val.SelectionData;
            }
        }
예제 #5
0
        public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            OptionSelection val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            string radioId = "opt" + val.SelectionData.Replace("-", "");

            System.Web.UI.HtmlControls.HtmlInputRadioButton rb = (System.Web.UI.HtmlControls.HtmlInputRadioButton)ph.FindControl(radioId);
            if (rb != null)
            {
                rb.Checked = true;
            }
        }
예제 #6
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            foreach (OptionItem o in baseOption.Items)
            {
                if (!o.IsLabel)
                {
                    string radioId = "opt" + o.Bvin.Replace("-", "");
                    System.Web.UI.HtmlControls.HtmlInputRadioButton rb = (System.Web.UI.HtmlControls.HtmlInputRadioButton)ph.FindControl(radioId);
                    if (rb != null)
                    {
                        if (rb.Checked)
                        {
                            result.SelectionData = o.Bvin;
                            return(result);
                        }
                    }
                }
            }

            return(result);
        }
예제 #7
0
        /// <summary>
        /// Restores Page state (content & title) and launch events
        /// <para xml:lang="es">Restaura el estado de la pagina (Contenido y titulo) y lanza eventos</para>
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //assign as current page
            Platform.Current.Page = this;

            //load javascript dependencies
            Page.ClientScript.RegisterClientScriptInclude("jquery", ResolveUrl("~/js/jquery.js"));
            Page.ClientScript.RegisterClientScriptInclude("jquery-ui", ResolveUrl("~/js/jquery-ui.js"));
            Page.ClientScript.RegisterClientScriptInclude("PageSize", ResolveUrl("~/js/PageSize.js"));

            //if this is the first request, get page size
            if (Width == 0 && Height == 0)
            {
                string pageSizeJS = @"
				<script type='text/javascript'>
					$(document).ready
					(
						function()
						{
							SetPageSize();
						}
					);
				</script>"                ;

                //register javascripts
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SetPageSize", pageSizeJS);

                return;
            }

            //create placeholder for content
            if (ContentHolder == null)
            {
                ContentHolder    = new System.Web.UI.WebControls.PlaceHolder();
                ContentHolder.ID = "ContentHolder";
                base.Form.Controls.Add(ContentHolder);
            }

            //search for a rewrite rule for this uri
            var rule = Platform.Current.GetUrlRewriteRuleFor(new Uri(Request.RawUrl, UriKind.Relative));

            if (rule != null)
            {
                //should we start a different controller than the current one?
                if (Platform.Current.Controller != null)
                {
                    bool startNew = false;

                    if (!rule.ControllerType.IsAssignableFrom(Platform.Current.Controller.GetType()))
                    {
                        startNew = true;
                    }
                    else
                    {
                        var currentUri = rule.GetUri(Platform.Current.Controller).ToString();

                        if (currentUri != Request.RawUrl)
                        {
                            startNew = true;
                        }
                    }

                    if (startNew)
                    {
                        var newController = rule.GetController(new Uri(Request.RawUrl, UriKind.Relative));
                        newController.Start();
                    }
                }
            }

            //there is no controller assigned, exit
            if (Platform.Current.Controller == null)
            {
                return;
            }

            //get title and content from the state, in case it has a different Page instance
            if (Platform.Current.PageState != null && Platform.Current.PageState.Content != null)
            {
                Title   = Platform.Current.PageState.Title;
                Content = Platform.Current.PageState.Content;
            }

            if (!IsPostBack)
            {
                return;
            }

            //keep track of wich IInputControls had ther value updated so we can reaise IInputControl.OnValueChanged
            List <IControl> updatedInputControls = new List <IControl>();

            //restore state
            foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__")))
            {
                //get posted value by user
                string postedValue = Request.Form[postedValueName];

                //get control that corresponds to this input
                IControl control = ContentHolder.FindControl(postedValueName) as IControl;

                if (control == null)
                {
                    continue;
                }

                //update control's value
                if (control is Autocomplete && ((IAutocomplete)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((IAutocomplete)control).Value = postedValue;
                }
                else if (control is Calendar && ((ICalendar)control).Value != DateTime.Parse(postedValue))
                {
                    updatedInputControls.Add(control);
                    ((ICalendar)control).Value = DateTime.Parse(postedValue);
                }
                else if (control is DatePicker)
                {
                    DateTime date = DateTime.MinValue;

                    if (DateTime.TryParse(postedValue, out date) && ((IInputControl <DateTime?>)control).Value != date)
                    {
                        updatedInputControls.Add(control);
                        ((IInputControl <DateTime?>)control).Value = date;
                    }
                }
                else if (control is CheckBox && ((ICheckBox)control).Value != (postedValue == "on"))
                {
                    updatedInputControls.Add(control);
                    ((ICheckBox)control).Value = postedValue == "on";
                }
                else if (control is ListPicker && ((IListPicker)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((IListPicker)control).Value = postedValue;
                }
                else if (control is PasswordTextBox && ((IPasswordTextBox)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((IPasswordTextBox)control).Value = postedValue;
                }
                else if (control is TextArea && ((ITextArea)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((ITextArea)control).Value = postedValue;
                }
                else if (control is TextBox && ((ITextBox)control).Value != postedValue)
                {
                    updatedInputControls.Add(control);
                    ((ITextBox)control).Value = postedValue;
                }
            }

            //raise IInputControl.OnValueChanged events
            foreach (IControl control in updatedInputControls)
            {
                if (control is Autocomplete)
                {
                    ((Autocomplete)control).RaiseValueChanged();
                }
                else if (control is Calendar)
                {
                    ((Calendar)control).RaiseValueChanged();
                }
                else if (control is DatePicker)
                {
                    ((DatePicker)control).RaiseValueChanged();
                }
                else if (control is CheckBox)
                {
                    ((CheckBox)control).RaiseValueChanged();
                }
                else if (control is ListPicker)
                {
                    ((ListPicker)control).RaiseValueChanged();
                }
                else if (control is PasswordTextBox)
                {
                    ((PasswordTextBox)control).RaiseValueChanged();
                }
                else if (control is TextArea)
                {
                    ((TextArea)control).RaiseValueChanged();
                }
                else if (control is TextBox)
                {
                    ((TextBox)control).RaiseValueChanged();
                }
            }

            //raise button click events
            foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__")))
            {
                //get posted value by user
                string postedValue = Request.Form[postedValueName];
                string controlName = postedValueName;

                //is this an image button?
                if (postedValueName.EndsWith(".x"))
                {
                    controlName = postedValueName.Split('.').First();
                }

                //get control that corresponds to this input
                IControl control = ContentHolder.FindControl(controlName) as IControl;

                if (control == null)
                {
                    continue;
                }

                if (control is Button && postedValue == ((Button)control).Text)
                {
                    ((Button)control).Raise_Click();
                }
                else if (control is IImageButton)
                {
                    ((ImageButton)control).Raise_Click();
                }
            }

            //raise labelbutton, checkbox & image click events

            string eventTarget   = Request.Form["__EVENTTARGET"];
            string eventArgument = Request.Form["__EVENTARGUMENT"];

            //get control that corresponds to this input
            if (!string.IsNullOrWhiteSpace(eventTarget))
            {
                IControl control = (IControl)ContentHolder.FindControl(eventTarget);

                if (control is LabelButton && eventTarget == control.Name)
                {
                    ((LabelButton)control).Raise_Click();
                }
                else if (control is IImageButton && eventTarget == control.Name)
                {
                    ((ImageButton)control).Raise_Click();
                }
                else if (control is ICheckBox && eventTarget == control.Name && !updatedInputControls.Contains(control))                 //check updatedInputControls collection because checkbox is causing double event raising
                {
                    ((ICheckBox)control).Value = !((ICheckBox)control).Value;
                    ((CheckBox)control).RaiseValueChanged();
                }
            }
        }
예제 #8
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            string val = string.Empty;

            foreach (OptionItem o in baseOption.Items)
            {
                if (!o.IsLabel)
                {
                    string checkId = "opt" + o.Bvin.Replace("-", "");
                    System.Web.UI.HtmlControls.HtmlInputCheckBox cb = (System.Web.UI.HtmlControls.HtmlInputCheckBox)ph.FindControl(checkId);
                    if (cb != null)
                    {
                        if (cb.Checked)
                        {
                            string temp = "";
                            if (val.Length > 0)
                            {
                                temp += ",";
                            }
                            temp += o.Bvin;
                            val  += temp;
                        }
                    }
                }
            }

            result.SelectionData = val;

            return(result);
        }
예제 #9
0
        public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            OptionSelection val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            string[] vals = val.SelectionData.Split(',');
            foreach (string s in vals)
            {
                string checkId = "opt" + s.Replace("-", "");
                System.Web.UI.HtmlControls.HtmlInputCheckBox cb = (System.Web.UI.HtmlControls.HtmlInputCheckBox)ph.FindControl(checkId);
                if (cb != null)
                {
                    cb.Checked = true;
                }
            }
        }
예제 #10
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)ph.FindControl("opt" + baseOption.Bvin.Replace("-", ""));
            if (ddl != null)
            {
                if (ddl.SelectedItem != null)
                {
                    // Why was I parsing Guid only to return as string?
                    // Safety check maybe?
                    //result.SelectionData = new System.Guid(ddl.SelectedItem.Value).ToString();

                    // Removed GUID requirement for BVC2004 migration compatibility
                    string temp = ddl.SelectedItem.Value;
                    result.SelectionData = temp;
                }
            }

            return(result);
        }
예제 #11
0
        public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            OptionSelection val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)ph.FindControl("opt" + baseOption.Bvin.Replace("-", ""));
            if (ddl != null)
            {
                if (ddl.Items.FindByValue(val.SelectionData) != null)
                {
                    ddl.ClearSelection();
                    ddl.Items.FindByValue(val.SelectionData).Selected = true;
                }
            }
        }