I dont know if my answer will fullfil your question but I am going to answer on what I have precieve.
First Add the following code to the header of your master page
<script type="text/javascript">
function changeDisplay(id) {
if (id == "One") {
document.getElementById('DivOne').style.display = 'block';
document.getElementById('DivTwo').style.display = 'none';
document.getElementById('DivThree').style.display = 'none';
}
else if (id == "Two") {
document.getElementById('DivOne').style.display = 'none';
document.getElementById('DivTwo').style.display = 'block';
document.getElementById('DivThree').style.display = 'none';
}
else if (id == "Three") {
document.getElementById('DivOne').style.display = 'none';
document.getElementById('DivTwo').style.display = 'none';
document.getElementById('DivThree').style.display = 'block';
}
}
</script></script>
Then these are three divs for demonstration. Add them in the body of your aspx page. I gave the dives different color so they could be easily judged.
<div id="DivOne" style="display: none; border: solid 1px #000000; height: 50px; width: 50px;<br mode=" hold=" /> background-color: Gray;">
</div>
<div id="DivTwo" style="display: none; border: solid 1px #000000; height: 50px; width: 50px;<br mode=" hold=" /> background-color: White;">
</div>
<div id="DivThree" style="display: none; border: solid 1px #000000; height: 50px;<br mode=" hold=" /> width: 50px; background-color: Navy;">
</div>
Now you have to call the javascript function in the .cs file of your master page. Note that the mathod should be public as we will access it in child page later in this solution. Write the method as follows:
public void changeDivDisplay(System.Web.UI.Control sender)
{
string script = string.Format("<script language="javascript" type="text/javascript">changeDisplay('{0}');</script>", sender.ID.ToString());
ScriptManager.RegisterStartupScript(sender, sender.GetType(), "changeDisplay", script, false);
}
Now add three buttons to the child page of the preceding master page:
<asp:button runat="server" id="One" text="One" onclick="DivOne_Click" xmlns:asp="#unknown" />
<asp:button runat="server" id="Two" text="Two" onclick="DivTwo_Click" xmlns:asp="#unknown" />
<asp:button runat="server" id="Three" text="Three" xmlns:asp="#unknown">
onclick="DivThree_Click" /></asp:button>
Following is the Very importent part of solution. Add the following line right after <%@Page %> Tag of the preceding child page.
<%@ MasterType VirtualPath="Site.master" %>
Now you are going to play the actual game. Actually you are going to call the "changeDivDisplay" method of master page in child page's button click events. Add the following code to the code behind file of your child page
protected void DivOne_Click(object sender, EventArgs e)
{
Master.changeDivDisplay(this.One);
}
protected void DivTwo_Click(object sender, EventArgs e)
{
Master.changeDivDisplay(this.Two);
}
protected void DivThree_Click(object sender, EventArgs e)
{
Master.changeDivDisplay(this.Three);
}