Drop down list OnSelectedIndexChanged without .aspx page

Sharepoint is very keen on using CAML to add controls to your pages. Which means the traditional way of adding an event handler to your asp:DropDownList tag isn’t available. (as far as I can tell, anyway.)

So, here’s how to work around this in your code behind:

ddlSort.AutoPostBack = true;
ddlSort.SelectedIndexChanged += new EventHandler(ddlSort_SelectedIndexChanged);
this.Controls.Add(ddlSort);

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s