Ejemplo n.º 1
0
 /// <summary>
 /// Generates a selection control (Radio, checkbox) and adds
 /// it to the container
 /// </summary>
 /// <param name="container"></param>
 /// <returns>true if a selection control was added</returns>
 protected bool GenerateSelectionControl(ControlCollection container)
 {
     if (this.SelectionMode == AnswerSelectionMode.Radio)
     {
         SelectionRadioButton child = new SelectionRadioButton();
         child.GroupName = string.Format("{0}:{1}{2}", this._uniqueGroupId, GlobalConfig.GroupName, this.QuestionId);
         child.Checked   = this.Selected;
         container.Add(child);
         if (this.ShowAnswerText)
         {
             if ((this.ImageUrl != null) && (this.ImageUrl.Length != 0))
             {
                 Image image = new Image();
                 image.ImageUrl   = this.ImageUrl;
                 image.ImageAlign = ImageAlign.Middle;
                 image.ToolTip    = this.Text;
                 container.Add(image);
             }
             else
             {
                 child.Text     = this.Text;//JJ
                 child.CssClass = "AnswerTextRender";
             }
         }
         this.SelectionControl = child;
     }
     else if (this.SelectionMode == AnswerSelectionMode.CheckBox)
     {
         SelectionCheckBox box = new SelectionCheckBox();
         box.Checked = this.Selected;
         container.Add(box);
         if (this.ShowAnswerText)
         {
             if ((this.ImageUrl != null) && (this.ImageUrl.Length != 0))
             {
                 Image image2 = new Image();
                 image2.ImageUrl   = this.ImageUrl;
                 image2.ImageAlign = ImageAlign.Middle;
                 image2.ToolTip    = this.Text;
                 container.Add(image2);
             }
             else
             {
                 box.Text     = this.Text;//JJ
                 box.CssClass = "AnswerTextRender";
             }
         }
         this.SelectionControl = box;
     }
     else if (this.SelectionMode == AnswerSelectionMode.ListItem)
     {
         AnswerListItem item = new AnswerListItem();
         item.Text     = this.Text;//JJ
         item.CssClass = "AnswerTextRender";
         container.Add(item);
     }
     else if ((this.ImageUrl != null) && (this.ImageUrl.Length != 0))
     {
         Image image3 = new Image();
         image3.ImageUrl   = this.ImageUrl;
         image3.ImageAlign = ImageAlign.Middle;
         image3.ToolTip    = this.Text;
         container.Add(image3);
     }
     else
     {
         Literal literal = new Literal();
         literal.Text = this.Text;
         container.Add(literal);
     }
     return(this.SelectionControl != null);
 }
 /// <summary>
 /// Generates a selection control (Radio, checkbox) and adds
 /// it to the container
 /// </summary>
 /// <param name="container"></param>
 /// <returns>true if a selection control was added</returns>
 protected bool GenerateSelectionControl(ControlCollection container)
 {
     if (this.SelectionMode == AnswerSelectionMode.Radio)
     {
         SelectionRadioButton child = new SelectionRadioButton();
         child.GroupName = string.Format("{0}:{1}{2}", this._uniqueGroupId, GlobalConfig.GroupName, this.QuestionId);
         child.Checked = this.Selected;
         container.Add(child);
         if (this.ShowAnswerText)
         {
             if ((this.ImageUrl != null) && (this.ImageUrl.Length != 0))
             {
                 Image image = new Image();
                 image.ImageUrl = this.ImageUrl;
                 image.ImageAlign = ImageAlign.Middle;
                 image.ToolTip = this.Text;
                 container.Add(image);
             }
             else
             {
                 child.Text = this.Text;//JJ
             child.CssClass = "AnswerTextRender";
             }
         }
         this.SelectionControl = child;
     }
     else if (this.SelectionMode == AnswerSelectionMode.CheckBox)
     {
         SelectionCheckBox box = new SelectionCheckBox();
         box.Checked = this.Selected;
         container.Add(box);
         if (this.ShowAnswerText)
         {
             if ((this.ImageUrl != null) && (this.ImageUrl.Length != 0))
             {
                 Image image2 = new Image();
                 image2.ImageUrl = this.ImageUrl;
                 image2.ImageAlign = ImageAlign.Middle;
                 image2.ToolTip = this.Text;
                 container.Add(image2);
             }
             else
             {
                 box.Text = this.Text;//JJ
                 box.CssClass = "AnswerTextRender";
             }
         }
         this.SelectionControl = box;
     }
     else if (this.SelectionMode == AnswerSelectionMode.ListItem)
     {
         AnswerListItem item = new AnswerListItem();
         item.Text = this.Text;//JJ
         item.CssClass = "AnswerTextRender";
         container.Add(item);
     }
     else if ((this.ImageUrl != null) && (this.ImageUrl.Length != 0))
     {
         Image image3 = new Image();
         image3.ImageUrl = this.ImageUrl;
         image3.ImageAlign = ImageAlign.Middle;
         image3.ToolTip = this.Text;
         container.Add(image3);
     }
     else
     {
         Literal literal = new Literal();
         literal.Text = this.Text;
         container.Add(literal);
     }
     return (this.SelectionControl != null);
 }