protected override void CreateChildControls()
        {
            try
            {
                this.DisplayLabel = new Label();

                if (this.provider != null)
                {
                    if (this.provider.Id > 0)
                    {
                        this.DisplayLabel.Text = string.Format("'{0}' was selected.", this.provider.Name);
                    }
                    else
                    {
                        this.DisplayLabel.Text = "Nothing was selected.";
                    }
                }
                else
                {
                    this.DisplayLabel.Text = "No Provider Web Part Connected.";
                }

                Controls.Add(this.DisplayLabel);
            }
            catch (Exception ex)
            {
                WebPartUtil.HandleException(this, ex);
            }
        }
        protected override void CreateChildControls()
        {
            try
            {
                base.CreateChildControls();

                Panel pnlGroup = new Panel(); // configuration section panel

                ValidationSummary             = new ValidationSummary();
                ValidationSummary.ID          = "ValidationSummary";
                ValidationSummary.DisplayMode = ValidationSummaryDisplayMode.SingleParagraph;
                ValidationSummary.ShowSummary = true;
                pnlGroup.Controls.Add(ValidationSummary);

                MessageTextBox    = new TextBox();
                MessageTextBox.ID = "MessageTextBox";

                HelloWorldWithEditorWebPart webPart
                    = this.WebPartToEdit as HelloWorldWithEditorWebPart;

                if (webPart != null)
                {
                    Label lblMessage = new Label();
                    lblMessage.Text = "Message";

                    Panel pnlMessageLabel = new Panel(); // head for configuration section
                    pnlMessageLabel.Controls.Add(lblMessage);

                    // Required field validator
                    RequiredFieldValidator messageRequiredValidator =
                        new RequiredFieldValidator();
                    messageRequiredValidator.ControlToValidate = MessageTextBox.ClientID;
                    messageRequiredValidator.ErrorMessage      = "Message cannot be blank";
                    messageRequiredValidator.Display           = ValidatorDisplay.Dynamic;
                    messageRequiredValidator.Text = "*";

                    Panel pnlMessageControls = new Panel(); // body of configuration section
                    pnlMessageControls.Controls.Add(MessageTextBox);
                    pnlMessageControls.Controls.Add(messageRequiredValidator);

                    pnlGroup.Controls.Add(pnlMessageLabel);
                    pnlGroup.Controls.Add(pnlMessageControls);
                }

                this.Controls.Add(pnlGroup);

                // stop Cancel button from calling validation code
                ToolPane pane = Zone as ToolPane;
                if (pane != null)
                {
                    pane.Cancel.CausesValidation = false;
                }
            }
            catch (Exception ex)
            {
                WebPartUtil.HandleException(this, ex);
            }
        }
Beispiel #3
0
 protected override void OnPreRender(EventArgs e)
 {
     try
     {
         base.OnPreRender(e);
         this.EnsureChildControls();
         this.MessageLiteral.Text = this.Message;
     }
     catch (Exception ex)
     {
         WebPartUtil.HandleException(this, ex);
     }
 }
Beispiel #4
0
 protected override void CreateChildControls()
 {
     try
     {
         this.MessageLiteral      = new LiteralControl();
         this.MessageLiteral.Text = this.Message;
         this.Controls.Add(this.MessageLiteral);
     }
     catch (Exception ex)
     {
         WebPartUtil.HandleException(this, ex);
     }
 }
Beispiel #5
0
 public override EditorPartCollection CreateEditorParts()
 {
     try
     {
         List <EditorPart> editorParts = new List <EditorPart>();
         editorParts.Add(new HelloWorldEditorPart(this.ID));
         return(new EditorPartCollection(editorParts));
     }
     catch (Exception ex)
     {
         WebPartUtil.HandleException(this, ex);
         return(base.CreateEditorParts());
     }
 }
Beispiel #6
0
 protected void ServerSideHandler(object sender, WebPartEventArgs e)
 {
     try
     {
         TextBox textBox = new TextBox();
         textBox.TextMode = TextBoxMode.MultiLine;
         textBox.ID       = "txtName";
         textBox.Text     = "You clicked a server side verb!";
         Panel panel = new Panel();
         panel.Controls.Add(textBox);
         Controls.Add(panel);
     }
     catch (Exception ex)
     {
         WebPartUtil.HandleException(this, ex);
     }
 }
        /// <summary>
        /// Places data in web part properties into editor part properties/controls
        /// </summary>
        public override void SyncChanges()
        {
            EnsureChildControls();

            try
            {
                HelloWorldWithEditorWebPart webPart
                    = this.WebPartToEdit as HelloWorldWithEditorWebPart;
                if (webPart != null)
                {
                    MessageTextBox.Text = webPart.Message;
                }
            }
            catch (Exception ex)
            {
                WebPartUtil.HandleException(this, ex);
            }
        }
Beispiel #8
0
        protected override void CreateChildControls()
        {
            try
            {
                base.CreateChildControls();

                SPWeb  currentWeb = SPContext.Current.Web;
                string classResourcePath
                    = Microsoft.SharePoint.WebPartPages.SPWebPartManager.GetClassResourcePath(currentWeb, this.GetType());

                this.LogoImage = new Image();
                this.LogoImage.ImageUrl
                    = string.Format("{0}/{1}", classResourcePath, "JK.SP.WebParts/ClassResources/SharePoint2010Logo.jpg");

                this.Controls.Add(LogoImage);
            }
            catch (Exception ex)
            {
                WebPartUtil.HandleException(this, ex);
            }
        }
        /// <summary>
        /// Places data in editor part properties/controls into web part properties.
        /// </summary>
        public override bool ApplyChanges()
        {
            EnsureChildControls();

            try
            {
                HelloWorldWithEditorWebPart webPart
                    = this.WebPartToEdit as HelloWorldWithEditorWebPart;

                if (webPart != null)
                {
                    webPart.Message = MessageTextBox.Text;
                }
            }
            catch (Exception ex)
            {
                WebPartUtil.HandleException(this, ex);
            }

            return(true);
        }
        protected override void CreateChildControls()
        {
            try
            {
                this.ProjectPicker = new DropDownList();

                SPWeb webSite = SPContext.Current.Web;

                SPListItemCollection listItems = webSite.Lists["Projects"].Items;
                foreach (SPListItem item in listItems)
                {
                    this.ProjectPicker.Items.Add(new ListItem(item.Title, item.ID.ToString()));
                }

                this.ProjectPicker.AutoPostBack = true;

                Controls.Add(this.ProjectPicker);
            }
            catch (Exception ex)
            {
                WebPartUtil.HandleException(this, ex);
            }
        }