Click here to Skip to main content
15,901,205 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionupdate progree bar in modal popup Pin
Member 387988128-Jul-08 19:24
Member 387988128-Jul-08 19:24 
AnswerRe: update progree bar in modal popup Pin
Christian Graus28-Jul-08 20:10
protectorChristian Graus28-Jul-08 20:10 
Questionhow import print option in Report viewer Pin
Guvera28-Jul-08 18:48
Guvera28-Jul-08 18:48 
QuestionCatch the no.of clicks on particular image Pin
dwadasi28-Jul-08 18:36
dwadasi28-Jul-08 18:36 
QuestionHow to color cells of table Pin
Rameez Raja28-Jul-08 17:19
Rameez Raja28-Jul-08 17:19 
RantRe: How to color cells of table Pin
Paul Conrad28-Jul-08 18:42
professionalPaul Conrad28-Jul-08 18:42 
GeneralRe: How to color cells of table Pin
Rameez Raja28-Jul-08 19:44
Rameez Raja28-Jul-08 19:44 
QuestionComposite Control Pin
Fayu28-Jul-08 16:44
Fayu28-Jul-08 16:44 
Hello All,

I have been trying to make this work for the last few days with no avail.

I am trying to write a custom composite control that contains a couple of labels and a textbox. I have three properties: Label, Seperator and TextBoxText, all are string and are values of the Label control, Label control, and Textbox control, respectively. When i change the values of the textbox and seperator, the text is persisted when i toggle between the designer and the source code, the label on the other hand, does not. The actual values for all the properties are written as attributes in the control. See code below. Im not sure if im doing something wrong or VS2005 is buggy.

Your help will be higly appreciated. Thank you in advance.

Here is my declarative code:
<cc1:FusionTextBoxOld ID="FusionTextBoxOld1" runat="server" Label="First Name" Seperator="-" TextBoxText="enter first name" />


Here is my control code:
[DefaultProperty("TextBoxText")]
[ToolboxData("<{0}:FusionTextBoxOld runat=server></{0}:FusionTextBoxOld>")]
public class FusionTextBoxOld : CompositeControl
{
    Style _LabelStyle = new Style();
    TextBox _textBox = new TextBox();
    Label _label = new Label();
    Label _seperator = new Label();


    #region TextBox

    [Bindable(true)]
    [Category("Appearance: TextBox")]
    [DefaultValue("")]
    [Localizable(true)]
    [PersistenceMode(PersistenceMode.Attribute)]
    public string TextBoxText
    {
        get
        {
            EnsureChildControls();
            String s = (String)ViewState["TextBoxText"];
            return ((s == null) ? String.Empty : s);
        }

        set
        {
            EnsureChildControls();
            ViewState["TextBoxText"] = value;
        }
    }

    #endregion

    #region Label

    [Bindable(true)]
    [Category("Appearance: Label")]
    [DefaultValue("Label")]
    [Localizable(true)]
    [PersistenceMode(PersistenceMode.Attribute)]
    public string Label
    {
        get
        {
            EnsureChildControls();
            String s = (String)ViewState["Label"];
            return ((s == null) ? "Label" : s);
        }

        set
        {
            EnsureChildControls();
            ViewState["Label"] = value;
        }
    }

    [Bindable(true)]
    [Category("Appearance: Label")]
    [DefaultValue(":")]
    [Localizable(true)]
    [PersistenceMode(PersistenceMode.Attribute)]
    public string Seperator
    {
        get
        {
            EnsureChildControls();
            String s = (String)ViewState["Seperator"];
            return ((s == null) ? ":" : s);
        }

        set
        {
            EnsureChildControls();
            ViewState["Seperator"] = value;
        }
    }

    [Bindable(true)]
    [Category("Appearance: Label")]
    [DefaultValue("")]
    [Localizable(true)]
    [PersistenceMode(PersistenceMode.Attribute)]
    public string LabelCssStyle
    {
        get
        {
            String s = (String)ViewState["LabelCssStyle"];
            return ((s == null) ? "" : s);
        }

        set
        {
            ViewState["LabelCssStyle"] = value;
        }
    }

    [Bindable(true)]
    [Category("Appearance: Label")]
    [DefaultValue(typeof(Style))]
    [Localizable(true)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public Style LabelStyle
    {
        get
        {
            if (_LabelStyle == null)
                _LabelStyle = new Style();
            return _LabelStyle;
        }

        set
        {
            this._LabelStyle = value;
        }
    }

    #endregion

    #region Required Label

    [Bindable(true)]
    [Category("Appearance: Required Label")]
    [DefaultValue("*")]
    [Localizable(true)]
    public string RequiredLabelText
    {
        get
        {
            EnsureChildControls();
            String s = (String)ViewState["RequiredLabelText"];
            return ((s == null) ? "*" : s);
        }

        set
        {
            EnsureChildControls();
            ViewState["RequiredLabelText"] = value;
        }
    }

    [Bindable(true)]
    [Category("Appearance: Required Label")]
    [DefaultValue("")]
    [Localizable(true)]
    public string RequiredLabelCssStyle
    {
        get
        {
            EnsureChildControls();
            String s = (String)ViewState["RequiredLabelCssStyle"];
            return ((s == null) ? "" : s);
        }

        set
        {
            EnsureChildControls();
            ViewState["RequiredLabelCssStyle"] = value;
        }
    }


    private Style _RequiredLabelStyle;

    [Bindable(true)]
    [Category("Appearance: Required Label")]
    [DefaultValue(typeof(Style))]
    [Localizable(true)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public Style RequiredLabelStyle
    {
        get
        {
            //if (ViewState["RequiredLabelStyle"] == null)
            //    ViewState["RequiredLabelStyle"] = new Style();

            //return ((Style)ViewState["RequiredLabelStyle"]);
            EnsureChildControls();
            if (_RequiredLabelStyle == null)
            {
                _RequiredLabelStyle = new Style();
                _RequiredLabelStyle.ForeColor = Color.Red;
            }
            return _RequiredLabelStyle;
        }

        set
        {
            //ViewState["RequiredLabelStyle"] = value;
            EnsureChildControls();
            _RequiredLabelStyle = value;
        }
    }


    #endregion

    #region Overrides

    protected override void CreateChildControls()
    {
        //EnsureChildControls();
        this.InitializeComponents();
        this.ConfigureLabel();
        this.ConfigureSeperatorLabel();
        this.ConfigureTextBox();
    }

    #endregion

    private void InitializeComponents()
    {
        //_label = new Label();
        //_seperator = new Label();
        //_textBox = new TextBox();
        //_requiredLabel = new Label();

        Controls.Add(_label);
        Controls.Add(_seperator);
        Controls.Add(_textBox);
    }
    private void ConfigureLabel()
    {
        this._label.Text = this.Label;
        this._label.ControlStyle.CopyFrom(this.LabelStyle);
        this._label.CssClass = this.LabelCssStyle;

    }
    private void ConfigureSeperatorLabel()
    {
        this._seperator.Text = this.Seperator;
        this._seperator.ControlStyle.CopyFrom(this.LabelStyle);
        this._seperator.CssClass = this.LabelCssStyle;

    }
    private void ConfigureTextBox()
    {
        this._textBox.Text = this.TextBoxText;
        switch (this.TextBoxType)
        {
            case TextBoxType.Email:
                this.ConfigureEmailValidator();
                break;
        }

    }


}

QuestionPlease Help Pin
tinamiller28-Jul-08 11:55
tinamiller28-Jul-08 11:55 
AnswerRe: Please Help Pin
Christian Graus28-Jul-08 12:51
protectorChristian Graus28-Jul-08 12:51 
GeneralRe: Please Help Pin
tinamiller28-Jul-08 13:17
tinamiller28-Jul-08 13:17 
GeneralRe: Please Help Pin
Christian Graus28-Jul-08 13:38
protectorChristian Graus28-Jul-08 13:38 
QuestionTargeting Panels with querystring Pin
Veldrain28-Jul-08 10:00
Veldrain28-Jul-08 10:00 
QuestionProviding security for webpage Pin
manoj2218428-Jul-08 6:45
manoj2218428-Jul-08 6:45 
AnswerRe: Providing security for webpage Pin
Christian Flutcher28-Jul-08 7:43
Christian Flutcher28-Jul-08 7:43 
GeneralRe: Providing security for webpage Pin
Vasudevan Deepak Kumar28-Jul-08 18:22
Vasudevan Deepak Kumar28-Jul-08 18:22 
AnswerRe: Providing security for webpage Pin
Christian Graus28-Jul-08 13:58
protectorChristian Graus28-Jul-08 13:58 
AnswerRe: Providing security for webpage Pin
Vasudevan Deepak Kumar28-Jul-08 18:24
Vasudevan Deepak Kumar28-Jul-08 18:24 
QuestionGridview resizing beyond its panel boundaries when populated/bound to data Pin
Steve Holdorf28-Jul-08 3:36
Steve Holdorf28-Jul-08 3:36 
GeneralRe: Gridview resizing beyond its panel boundaries when populated/bound to data Pin
Steve Holdorf28-Jul-08 7:17
Steve Holdorf28-Jul-08 7:17 
QuestionHow to resize the ContentPlaceHolder in child page.? Pin
mcmilan28-Jul-08 3:21
mcmilan28-Jul-08 3:21 
QuestionCOMException Error When run this program in asp.net Pin
Rinki Mukheraji28-Jul-08 2:49
Rinki Mukheraji28-Jul-08 2:49 
QuestionMulti Column in a DropDown Pin
Ajeet mittal28-Jul-08 2:44
Ajeet mittal28-Jul-08 2:44 
AnswerRe: Multi Column in a DropDown Pin
Abhijit Jana28-Jul-08 2:48
professionalAbhijit Jana28-Jul-08 2:48 
GeneralRe: Multi Column in a DropDown Pin
Ajeet mittal28-Jul-08 3:13
Ajeet mittal28-Jul-08 3:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.