How to load a master page on submit button click [Resolved]

Posted by Sheesh under Regular Expressions on 5/29/2011 | Points: 10 | Views : 14288 | Status : [Member] | Replies : 3
The firsts page of project while executing is login form & after authorizing, i want it should redirect to mastermain page, after clicking submit button, but it shows error "This type of page is not served". The login page is not the child page of master page. The code i have written as
protected void Loin(object sender, EventArgs e)
{
Response.Redirect("~/MasterPage.master");
}

Now to load this master page, any help..??

Thanks
Regards



Responses

Posted by: Lokesh76 on: 5/29/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi Sheesh,

Yes that's right by default web server unable to served .master extension. Let you explain where exactly you wrong as we have master pages for define layout of our application so we use master page in the context of content pages menas .aspx pages.

So you can not do
Response.Redirect("~/MasterPage.master"); 

instead of above you need to redirect to relative .aspx page and inside the .aspx use the appropriate master page which one you want to
Response.Redirect("~/default.aspx"); 


for dynamically loading of master page you can use following line inside Page_PreInit event
 protected void Page_PreInit(object sender, EventArgs e)

{
Page.MasterPageFile = "Site1.master";
}


Hope it will help you out

Thanks
Lokesh Kumar

Sheesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sheesh on: 5/29/2011 [Member] Starter | Points: 25

Up
0
Down

Resolved
Hi
Thanks for your response.. It is working.!!

Thanks
Regards

Sheesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lokesh76 on: 5/30/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Sheesh,
You are welcome. please mark this as answer so that its comes in resolved category.


Thanks
Lokesh Kumar

Sheesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response