Beispiel #1
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            string vendorName = Page.Request.QueryString["VendorName"];

            VendorNameLabel.Visible = true;
            VendorNameLabel.Text    = "Vendor Name: ";
            Controls.Add(VendorNameLabel);

            if (!string.IsNullOrEmpty(vendorName))
            {
                VendorNameValueLabel.Visible = true;
                VendorNameValueLabel.Text    = vendorName;
                Controls.Add(VendorNameValueLabel);
            }

            LiteralControl br2 = new LiteralControl("<BR/>");

            Controls.Add(br2);

            PayablesLabel.Visible = true;
            PayablesLabel.Text    = "Accounts Payable: ";
            Controls.Add(PayablesLabel);

            PayablesValueLabel.Visible = true;
            Controls.Add(PayablesValueLabel);

            IErrorVisualizer errorVisualizer = new ErrorVisualizer(this);

            presenter                 = new VendorDetailsPresenter(this, new VendorService());
            presenter.VendorName      = vendorName;
            presenter.ErrorVisualizer = errorVisualizer;
            presenter.SetVendorDetails();
        }
        public void RendersNormalIfNoError()
        {
            ErrorVisualizer target = new ErrorVisualizer();

            target.Controls.Add(new LiteralControl("Flawless"));

            Assert.IsTrue(target.RenderToString().Contains("Flawless"));
        }
        public void CanRenderErrorMessage()
        {
            ErrorVisualizer target = new ErrorVisualizer();

            target.Controls.Add(new LiteralControl("Flawless"));
            target.ShowErrorMessage("Error");

            Assert.IsTrue(target.RenderToString().Contains("Error"));
            Assert.IsFalse(target.RenderToString().Contains("Flawless"));
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            ErrorVisualizer errorVisualizer = new ErrorVisualizer();

            this.Controls.Add(errorVisualizer);

            this.pricingControl = (PricingControl)Page.LoadControl("~/_controltemplates/Contoso/PricingControl.ascx");
            errorVisualizer.Controls.Add(this.pricingControl);
            this.pricingControl.ShowPricing(productSku);
        }
Beispiel #5
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // Create a control that will display any errors that might occur in the ProductDetailsControl
            ErrorVisualizer errorVisualizer = new ErrorVisualizer();

            this.Controls.Add(errorVisualizer);
            // Add the ProductDetailsControl to the host. This way, if an error has to be rendered, the host can
            // prevent the ProductDetailsControl from being displayed.
            this.productDetailsControl = (ProductDetailsControl)Page.LoadControl("~/_controltemplates/Contoso/ProductDetailsControl.ascx");
            this.productDetailsControl.ErrorVisualizer = errorVisualizer;
            errorVisualizer.Controls.Add(this.productDetailsControl);
            this.productDetailsControl.LoadProduct(this.productSku);
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // Create the view that will show the related parts.
            this.relatedPartsControl = (RelatedPartsControl)Page.LoadControl("~/_controltemplates/Contoso/RelatedPartsControl.ascx");


            // Create an error visualizer that will host the related parts control.
            // Using this constructor will add it to the page.
            IErrorVisualizer errorVisualizer = new ErrorVisualizer(this, this.relatedPartsControl);

            this.relatedPartsControl.ErrorVisualizer = errorVisualizer;
            this.relatedPartsControl.Sku             = this.ProductSku;
        }
        public void CanAddChildControlsInConstructor()
        {
            Control hostControl = new Control();

            Control control1 = new Control();
            TextBox control2 = new TextBox();

            ErrorVisualizer target = new ErrorVisualizer(hostControl, control1, control2);

            // make sure target is child of hostcontrol
            Assert.AreSame(target, hostControl.Controls[0]);

            // make sure children are parents of host
            Assert.AreSame(control1, target.Controls[0]);
            Assert.AreSame(control2, target.Controls[1]);
        }
Beispiel #8
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            ErrorVisualizer errorVisualizer = new ErrorVisualizer();

            this.Controls.Add(errorVisualizer);

            // Create the View and also create the presetner and associate them together.
            PartnerRollupControl control = (PartnerRollupControl)Page.LoadControl("~/_controltemplates/Contoso/PartnerRollupControl.ascx");

            errorVisualizer.Controls.Add(control);

            presenter = new PartnerRollupPresenter(control);

            // In this variation of the MVP pattern, the Webpart can talk directly to the presenter.
            presenter.ReturnSearchResults();
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            // Create the View (an user control), that will display the list of discounts to the user
            this.discountsControl = (DiscountsControl)this.Page.LoadControl("~/_controltemplates/Contoso/DiscountsControl.ascx");

            // Add the View to an ErrorVisualizer. The ErrorVisualizer can display (technical) error messages
            // when an unhandled exception occurs in the view. If an error message is to be displayed, the
            // View itself will not be rendered; only the error message.
            ErrorVisualizer errorVisualizer = new ErrorVisualizer(this, discountsControl);

            // In this case, we are forwarding the ErrorVisualizer explicitly to the view, to make
            // the error handling more robust. It is also possible for the view to look up the
            // control tree to find the visualizer. That approach (demonstrated in the PricingWebPart)
            // requires less code, but also implies an implicit contract between the webpart and the view.
            this.discountsControl.ErrorVisualizer = errorVisualizer;
            this.discountsControl.LoadDiscounts(this.productSku);
        }
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            gridView.ID = Gridid;
            gridView.AutoGenerateColumns = false;
            gridView.Width = 550;
            gridView.HeaderStyle.BackColor = System.Drawing.Color.LightGray;
            gridView.HeaderStyle.Font.Bold = true;
            gridView.Columns.Clear();

            presenter = new VendorListViewPresenter(this);
            presenter.SetVendorDataWithTransactionCount();

            Controls.Add(gridView);

            IErrorVisualizer errorVisualizer = new ErrorVisualizer(this);

            presenter.ErrorVisualizer = errorVisualizer;
        }
Beispiel #11
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            gridView.ID                    = Gridid;
            gridView.AllowPaging           = false;
            gridView.AutoGenerateColumns   = false;
            gridView.AllowSorting          = true;
            gridView.Width                 = 550;
            gridView.HeaderStyle.BackColor = System.Drawing.Color.LightGray;
            gridView.HeaderStyle.Font.Bold = true;
            gridView.Columns.Clear();

            presenter = new AggregateViewPresenter(this, new EstimatesService());
            presenter.SetSiteData();

            Controls.Add(gridView);

            IErrorVisualizer errorVisualizer = new ErrorVisualizer(this);

            presenter.ErrorVisualizer = errorVisualizer;
        }
Beispiel #12
0
 public static void RegisterDisplayHandler(ErrorVisualizer method)
 {
     ErrorVisualizerMethod = method;
 }