SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to customize the SearchBoxEx-Control. So I made a Webpart which inherits from SearchBoxEx. In the CreateChildControls I put an updatepanel and two dropdownlists.

Every time I select something in the dropdownbox it makes a postback, that's correct. But It makes a recreates all controls in updatepanel so that nothing changes. I have to use a normal webpart (no visual webpart because of using searchboxex). The class is public class ExtendedSearch : SearchBoxEx

public class ExtendedSearch : SearchBoxEx
    UpdatePanel mainUpdatePanel;
    UpdateProgress progressControl;
    Button checkTimeButton;
    Label timeDisplayLabel;
    DropDownList category;
    DropDownList subcategory;

    protected override void CreateChildControls()

        this.DropDownModeEx = DropDownModesEx.ShowDD;

        mainUpdatePanel = new UpdatePanel();
        mainUpdatePanel.ID = "updateAjaxDemoWebPart";
        mainUpdatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
        mainUpdatePanel.RenderMode = UpdatePanelRenderMode.Inline;

        category = new DropDownList();
        category.ID = "dropdownCategory";
        category.Items.Add("Cat 1");
        category.Items.Add("Cat 2");
        category.Items.Add("Cat 3");
        category.CssClass = "ms-sbscopes";
        category.Style["display"] = "inline";
        category.Style["margin-right"] = "10px";
        category.AutoPostBack = true;

        subcategory = new DropDownList();
        category.ID = "dropdownSubCategory";
        subcategory.Items.Add("SubCat 1");
        subcategory.Items.Add("SubCat 2");
        subcategory.Items.Add("SubCat 3");
        subcategory.CssClass = "ms-sbscopes";
        subcategory.Style["display"] = "inline";

        category.SelectedIndexChanged += new EventHandler(category_SelectedIndexChanged);

        mainUpdatePanel.Triggers.Add(new AsyncPostBackTrigger()
            ControlID = category.ID,
            EventName = "SelectedIndexChanged"

        Control scopeDdl = FindControlRecursivly("SBScopesDDL", this);

        if (scopeDdl != null)
            int index = scopeDdl.Parent.Controls.IndexOf(scopeDdl);
            scopeDdl.Parent.Controls.AddAt(index, mainUpdatePanel);

    private void category_SelectedIndexChanged(object sender, EventArgs e)
        this.subcategory.SelectedIndex = 2;

    private Control FindControlRecursivly(string controlName, Control parentControl)
        foreach (Control control in parentControl.Controls)
            if (control.ID == controlName)
                return control;

            Control subControl = FindControlRecursivly(controlName, control);
            if (subControl != null)
                return subControl;

        return null;
share|improve this question
up vote 0 down vote accepted

Ok, it didn't work. When you use an updatepanel standalone in a webpart it works. It only updates the controls which should be updated.

When you inherit from searchboxex and put it there the updatepanel completly refreshes when making an AutoPostback=True.

My Solution was to use JQuery. I attached a Jquery-Function when the control changes its index. Before that I added all subdropdowns to the page and made them hidden with Jquery.

Hope that helps for your own solution.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.