예제 #1
0
 /// <summary>
 /// Initialize the SlkError Object with passed errorType and errorText.
 /// </summary>
 internal SlkError(ErrorType errorType, string errorText)
 {
     // Initialize Object if ErrorText is not null or empty.
     if (!String.IsNullOrEmpty(SlkUtilities.Trim(errorText)))
     {
         m_errorType = errorType;
         m_errorText = errorText;
     }
 }
예제 #2
0
        /// <summary>
        /// Control Render Method
        /// </summary>
        /// <param name="writer"></param>
        protected override void Render(HtmlTextWriter writer)
        {
            //Renders the Validation Error Message on Top of the Control.

            if (!IsValid)
            {
                if (!String.IsNullOrEmpty(SlkUtilities.Trim(this.ErrorMessage)))
                {
                    Label lblErrorText = new Label();
                    lblErrorText.Text     = SlkUtilities.GetHtmlEncodedText(this.ErrorMessage);
                    lblErrorText.CssClass = "ms-formvalidation";

                    using (new HtmlBlock(HtmlTextWriterTag.Div, 0, writer))
                    {
                        lblErrorText.RenderControl(writer);
                    }
                }
            }
            //Render the CheckBox List
            RenderCustomCheckBox(writer);
        }
        /// <summary>
        /// Check the Current User Role and Set the
        /// Default QuerySet accrodingly
        /// </summary>
        private void DefaultQuerySetIfRequired()
        {
            //Override the QuerySet depends on the weppart property selection and role.

            if (String.IsNullOrEmpty(SlkUtilities.Trim(QuerySetOverride)))
            {
                //Defaluted to Default LearnerQuerySet For all, but instructor and observer.
                QuerySetOverride = Constants.DefaultLearnerQuerySet;

                //// check for the role and assign the query set
                if (SlkStore.IsObserver(SPWeb))
                {
                    QuerySetOverride = Constants.DefaultObserverQuerySet;
                }
                else if (SlkStore.IsInstructor(SPWeb))
                {
                    QuerySetOverride = Constants.DefaultInstructorQuerySet;
                }
                else if (SlkStore.IsLearner(SPWeb))
                {
                    QuerySetOverride = Constants.DefaultLearnerQuerySet;
                }
            }
        }
        /// <summary>
        /// Validates the required attributes to render AssignmentListWebPart
        /// Throws SafeToDisplayException If not Valid.
        /// </summary>
        private void ValidateAlwpProperties()
        {
            //Check for Current User and QuerySet Values

            if (SPWeb.CurrentUser == null)
            {
                throw new UserNotFoundException(culture.Resources.SlkExUserNotFound);
            }

            if (String.IsNullOrEmpty(SlkUtilities.Trim(QuerySetOverride)) == false)
            {
                // set <querySetDef> to the QuerySetDefinition named <querySetName>

                QuerySetDefinition querySetDef = SlkStore.Settings.FindQuerySetDefinition(QuerySetOverride, true);
                if (querySetDef == null)
                {
                    throw new SafeToDisplayException(culture.Resources.AlwpQuerySetNotFound, QuerySetOverride);
                }
                else
                {
                    defaultQueryName = querySetDef.DefaultQueryName;
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Render the Custom made CheckboxControl parses the content of
        /// List Items and Render the Items
        /// </summary>
        /// <param name="htmlTextWriter">HtmlTextWriter</param>
        protected void RenderCustomCheckBox(HtmlTextWriter htmlTextWriter)
        {
            htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Class, "UserGenericText");
            using (new HtmlBlock(HtmlTextWriterTag.Table, 1, htmlTextWriter))
            {
                if (!String.IsNullOrEmpty(SlkUtilities.Trim(this.HeaderText)))
                {
                    using (new HtmlBlock(HtmlTextWriterTag.Tr, 1, htmlTextWriter))
                    {
                        htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
                        htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
                        using (new HtmlBlock(HtmlTextWriterTag.Td, 1, htmlTextWriter))
                        {
                            LiteralControl ltrl = new LiteralControl(SlkUtilities.GetHtmlEncodedText(this.HeaderText));
                            ltrl.RenderControl(htmlTextWriter);
                        }
                    }
                }

                //for each item in  the collection of SlkCheckBoxItem objects render
                //Checkbox and Associated label Control.
                foreach (SlkCheckBoxItem item in this.Items)
                {
                    using (new HtmlBlock(HtmlTextWriterTag.Tr, 1, htmlTextWriter))
                    {
                        CheckBox checkBox = ControlToRepeat;
                        htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Width, "1%");
                        htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
                        using (new HtmlBlock(HtmlTextWriterTag.Td, 1, htmlTextWriter))
                        {
                            checkBox.ID      = item.Value;
                            checkBox.ToolTip = item.ToolTip;
                            checkBox.Checked = item.Selected;

                            if (this.HasAttributes)
                            {
                                foreach (string text1 in this.Attributes.Keys)
                                {
                                    checkBox.Attributes[text1] = this.Attributes[text1];
                                }
                            }

                            checkBox.RenderControl(htmlTextWriter);
                        }

                        htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
                        htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
                        htmlTextWriter.AddAttribute(HtmlTextWriterAttribute.Style, "border-top: none; padding-top:2px");
                        using (new HtmlBlock(HtmlTextWriterTag.Td, 1, htmlTextWriter))
                        {
                            Label label = ControlToAssociate;
                            label.ToolTip             = item.ToolTip;
                            label.Text                = item.Text;
                            label.AssociatedControlID = item.Value;
                            label.RenderControl(htmlTextWriter);
                        }
                    }
                }
            }
        }