I want to master page run time

Discussion in 'C#' started by amkeabhi123, Sep 21, 2012.

  1. #1
    Hey friends
    I want to change master page
    in run time through C# code dynamically, but could not found good answer so please help replace master page in dynamically.
     
    amkeabhi123, Sep 21, 2012 IP
  2. Kousha

    Kousha Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Why you want to do this? it's not rational. i believe you have a mistake in your way
     
    Kousha, Sep 21, 2012 IP
  3. bibinsmk

    bibinsmk Active Member

    Messages:
    205
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    It is very simple to transfer the master page dynamically. For this you have to set the name of Masterpage in PreInit Method of every page

    protected void Page_PreInit(object sender, EventArgs e)
    {
    try
    {
    this.MasterPageFile = Session["master"].ToString();// In this session you have to save the name of Master page file eg: SampleMasterpage.master
    }
    catch
    {
    Response.Redirect("Login.aspx");
    }
    }


    For More Details visit : http://dotnetinterviewquestions.malayalees.in
     
    bibinsmk, Sep 29, 2012 IP
  4. amkeabhi123

    amkeabhi123 Member

    Messages:
    219
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #4
    thanks to response and answer .
    I have solve through using pagInIt method.
     
    amkeabhi123, Nov 20, 2012 IP