MasterPage

Hi guys,

I have a base page that basically contructs and loads all the html for every single page I have, i.e it builds the head, body, html and form tags etc

I am trying to achieve the following, depending on what role the user is (taken from db) then display the masterpage that matches that role

protected override void OnPreInit(EventArgs e)
{
// code to check which role
if (role==Admin)
{
base.MasterPageFile = "/masterpageforadmin
}

.
.
. etc etc

in my web.config file i have :

<pages pageBaseType="PageSetup"/>

My problem is this - because i am building head,form... tags in a base class, removing them from my master page prevents the tree view from working which is in the masterpage - the error I get is that in order for the tree view component to work it needs to be wrapped inside a form tag with runat="server".

So, how do i dynamically load head,body,form tags etc into my master page




Answer this question

MasterPage

  • Steve.W19324

    Hi,

    Please post this question in the newsgroup below.

    ASP.NET and Visual Web Developer Forums
    http://forums.asp.net/

    We recommend posting appropriately so you will get the most qualified pool of respondents, and so other partners who regularly read the newsgroups can either share their knowledge or learn from your interaction with us.

    BTW: C# syntax did not allow Multiple inheritance. That is to say, as the error states, one class can have two or more than two based classes. But it can have one base class and multiple interface.
    e.g. the pseudocode below is OK.

    interface A
    {
    }
    interface B
    {
    }

    class BaseClassA
    {
    }

    class ClassB : BaseClassA,A,B
    {
    }


    If you still have any concern, please feel free to post here.

    Best regards,
    Peter Huang



  • Thomas Waldron

    ok my bad on this one, I had forgot to create a code behind file when creating the new master page file.

    ok, so I now have a cs file, but I need to do this

    namespace CapitalIncentives.Web

    {

    public partial class _Default : System.Web.UI.MasterPage : PageSetup

    {

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    }

    }

    but this is throwing up an error stating I can not have multiple base class's

    this is properly something simply, but I've been looking at this far too long


  • MasterPage