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 have built a custom SharePoint 2010 master page where I have dropped a standard DropDownList control. I also have wired up a code behind file where I want to manipulate that control from.

However for reasons not apparent to me, I am NOT able to reference this control in the code behind.


Intellisense does not show it. I cannot even get a handle on it using:


What am I doing wrong here?


share|improve this question
up vote 3 down vote accepted

This works!

share|improve this answer

You should be able to refer your control normally in codebehind class for the master. Check the steps to create a code behind for the master page :

1) Create a class inheriting from System.Web.UI.MasterPage.Declare the control in the class. For e.g.

 public class CustomMasterClass : System.Web.UI.MasterPage    
        protected DropDownList myDropdown;

        protected void Page_Load(object sender, EventArgs e)
            myDropdown.Width = 200;

2) Build it into a dll and add to GAC.

3) Add it to the safecontrols list on your web.config.

4) Add the same control to your master page as :

    <asp:DropDownList ID="myDropdown" runat="server"/>

5) Add reference to the class in your master. For e.g. :

<%@ Master language="C#" Inherits="CustomNamespace.CustomMasterClass, CustomNamespace, Version=, Culture=neutral, PublicKeyToken=ae015afe5f30fb68" %>
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.