This is a migrated thread and some comments may be shown as answers.

ComboBox with RadButton in HeaderTemplate

1 Answer 89 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
JP
Top achievements
Rank 1
JP asked on 02 Apr 2012, 10:13 AM
Hello,

I want to use a simple HeaderTemplate for my ComboBox:

internal class MyHeaderTemplate : ITemplate
   {
      private readonly RadButton _okButton;
 
      public MyHeaderTemplate()
      {
         _okButton = new RadButton();
         _okButton.ID = "OkButton";
         _okButton.Text = "OK";
      }
 
 
      internal RadButton ButtonOk
      {
         get { return _okButton; }
      }
 
      public void InstantiateIn(Control container)
      {
         container.Controls.Add(_okButton);
      }
   }

But I get this error when the pare is generated: Script controls may not be registered after PreRender. When I don't set the HeaderTemplate to the ComboBox, everything works as expected.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Apr 2012, 10:58 AM
Hello,

I think you tried to add the HeaderTemplate to RadComboBox inside the Page_Load. The HeaderTemplate should be initialized in the OnInit event of the page as follows. This is needed as the template should be instantiated before RadComboBox items are initialized.

C#:
protected override void OnInit(EventArgs e)
    {
        RadComboBox1.HeaderTemplate = new MyHeaderTemplate();
        base.OnInit(e);
    }

Hope this helps,

Thanks,
Princy.
Tags
ComboBox
Asked by
JP
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or