Asp – Communication problem in master page and content page

asp.net

I'm having a master page in my website and having some control on master page.
I want to handle the master page controls event on content page.

how can i do that …?

even i have used property like this for a dropdown control

public  DropDownList propertymastercontrol
{
    get
    {
        return cmbVendor;   //drop down id
    }
}

and given the reference of master page on content page like this…

<%@ MasterType VirtualPath ="~/MasterPage.master" %>

still after not able to get the any event of control on content page_load event..

protected void Page_Load(object sender, EventArgs e)
    {
        Master.
    }

what can be the problem..?

Best Answer

I'm not sure about C#, but in VB.NET I've done it with these four steps:

  • Add events to the MasterPage code behind, raise these events as required
  • Add this to the content aspx page: <%@ MasterType VirtualPath="~/master.Master" %>
  • Add event handlers to trap the event on the content page codebehind (this is where things get very different between C# and VB.NET)
  • Add your required code to the events in the codebehind

UPDATE:

From your sample code, I can see you're not raising an event in the MasterPage (which you can respond to the content page). I was going to give an example, but it would be almost identical to this post, Pass MasterPage ImageButton event to content Page, which another SO user already has linked to in the answers here too.

Related Topic