I have seen the other way around, where coders need to change the master page for a particular content. But in this case, I am more worried about what is in the content, and I wish to change it.
protected void btn_search_Click(object sender, ImageClickEventArgs e)
{
string pageName = this.ContentPlaceHolder1.Page.GetType().FullName;
if (pageName != "ASP.ChinaShipManagerHome_aspx")
{
// then change it here?!
}
}
As you can surmise in my case, I have a button "Search" on my master page. However, they may have strayed away from the content, that the 'search' needs to interact with. So when they click 'search' it needs to switch back to the right 'Content' in 'ContentPlaceHolder1'.
This is the only way I believe. I don't think you can actually change the literal contentplaceholder from the masterpage.
protected void btn_search_Click(object sender, ImageClickEventArgs e)
{
string pageName = this.ContentPlaceHolder1.Page.GetType().FullName;
if (pageName != "ASP.chinashipmanagerhome_aspx")
{
string t = Base64Encode(tb_search.Text);
Response.Redirect("ChinaShipManagerHome.aspx?search2=" + t); //Redirect with query
}
Then in the 'Page_Load' I added, after checking that the person has not lost session. EDIT: It actually does not matter if its postback, in fact it has to be both.
else
{
if (Request.QueryString["search2"] != null && tb_search.Text == "")
{
tb_search.Text = Base64Decode(Request.QueryString["search2"].ToString());
btn_search_Click(this, new ImageClickEventArgs(1, 1));
}
}
Here it recalls 'btn_search_click' but now its on the right page. EDIT: Must also check tb_search.Text is empty, or you will get a circular reference when searching again.