Hi Mokles,
As your above description, you want to change the dropdownlist's selectedtem in the inner master page according by the outer master page's dropdownlist Selection is changed,right?
Below is my solution, create a base master page class which inherits the System.Web.UI.Masterpage, and define a virtual property ddl, its type is dropdownlist, make the inner master page inherit this base class and override this property. hope it helps.
1. BaseMasterpage codebehind.
public class BaseMasterPage: MasterPage
{
// Define a virtauls property
public virtual DropDownList ddl // make the inner master page inherit this property
{
get
{
return null;
}
}
public BaseMasterPage()
{
//
// TODO: Add constructor logic here
//
}
}
2. Innner master page codebehind:
public partial class ChildMasterPage : BaseMasterPage// Inherit from the BaseMaster page class
{
public override DropDownList ddl// override the virtual property of the Basemasterpage class
{
get
{
return this.ddlChilde;
}
}
.................
}
3.Outer maser page codebehind:
BaseMasterPageCurrentpage = null;
protected void Page_Load(object sender, EventArgs e)
{
Currentpage = Page.Master as BaseMasterPage;
}
protected void ddlParent_SelectedIndexChanged(object sender, EventArgs e)// the SelectedIndexChanged even of the dropdownlist on the outer master page
{
if (Currentpage != null)
{
// Change the inner dropdownlist's selectedindex
if (this.ddlParent.SelectedItem.Value == "A")
{
Currentpage.ddl.SelectedIndex = 1;
}
else if (ddlParent.SelectedItem.Value == "B")
{
Currentpage.ddl.SelectedIndex = 2;
}
else if (ddlParent.SelectedItem.Value == "C")
{
Currentpage.ddl.SelectedIndex = 3;
}
}
}
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Yours sincerely,
Amanda Wang
Microsoft Online Community Support