Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have two folder in my ASP.net web project, each one has some pages inside and has its own master page.

I want to change master page programmatically

one folder called: Members and have MemberComments.aspx page which has MemberMaster.master
I write that code to change its master page inside it:

C#
protected void Page_PreInit(object sender, EventArgs e)
    {
        if (Request.Url.LocalPath.Contains("EditTopics"))
        {
            this.MasterPageFile = "~/Admins/AdminMaster.master";
        }
    }


another folder called Admins and have EditTopics.aspx page
I write that code to go to MemberComments.aspx page:

Server.Transfer("~/Members/MemberComments.aspx);


but it give me error that:

Error executing child request
Posted
Updated 26-Jan-11 7:35am
v2
Comments
GenJerDan 26-Jan-11 14:18pm    
Do you get the same error if you don't try to change the MasterPage?
MrLonely_2 26-Jan-11 14:48pm    
No..... there are no errors if i don't try to change the MasterPage
GenJerDan 26-Jan-11 15:17pm    
That narrows down the problem, then. Put breakpoints in the code used to change the masterpage and see what the actual error is.

1 solution

Check your AdminMaster.master page. if you use response.write on adminmater.page.cs you get error like this.
 
Share this answer
 
Comments
MrLonely_2 26-Jan-11 14:49pm    
I need to use Server.Transfer because i have parameters...........

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900