TampaRich
TampaRich

Reputation: 863

ConfirmButtonExtender not working when adding to control collection at runtime

I am trying to add a ConfirmButtonExtender to my controls collection within a custom control at runtime but can not figure out why the extender will not wire to the button that is being added to the controls collection in the same CreateChildControls method. I did a simple test and added a button explicitly to an aspx page and then creating the extender dynamically in the PreRender of the the .cs file of that page and it still did not work. It seems that the only way to get this to work is to have the actual tags on the .aspx page.

Am I missing something?

    protected virtual void CreateChildControls(System.Resources.ResourceManager rm)
    {
        valValidationSummary = new ValidationSummary();
        valValidationSummary.ID = "valValidationSummary";
        valValidationSummary.ShowSummary = true;
        valValidationSummary.HeaderText = rm.GetString("ValidationSummary");
        valValidationSummary.CssClass = "error";

        btnGetRates = new LocalizedButton();
        btnGetRates.ID = "btnGetStats";         
        btnGetRates.TextResource = rm.GetString("SubmitButton");
        btnGetRates.Text = rm.GetString("SubmitButton");
        btnGetRates.CssClass = "inputfield";
        btnGetRates.Click += new System.EventHandler(OnSubmitButton_Click);


        btnConfirmation = new ConfirmButtonExtender();          
        btnConfirmation.ID = "rfBtnSubmit_Confirm";
        btnConfirmation.ConfirmText = rm.GetString("BAUConfrimation");
        btnConfirmation.TargetControlID = "btnGetStats";

        this.Controls.Add(btnConfirmation);
        this.Controls.Add(valValidationSummary);
        this.Controls.Add(btnGetRates);

    }

Upvotes: 0

Views: 521

Answers (1)

TampaRich
TampaRich

Reputation: 863

Dumb mistake, I was not rendering the control.

Upvotes: 0

Related Questions