Visual Studio - Master Pages

Post here for help with installing or upgrading mojoPortal pre-compiled release packages. When posting in this forum, please provide all relevant details. You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

Post here for help with installation of mojoPortal pre-compiled release packages

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.

You may also want to review the installation or upgrading documentation.

If you have questions about using the source code or working with mojoPortal in Visual Studio, please post in the Developer forum.

This thread is closed to new posts. You must sign in to post in the forums.
3/6/2005 6:06:45 PM
Gravatar
Total Posts 3

Visual Studio - Master Pages

Hi, first, thanks a lot for sharing a great work.

I am trying to add new pages (.aspx) in the project but could not add the Master Page.

Those pages with Master Pages also could not be loaded in VS Designer.

The message is "Error Creating Control - MPContainer".

It works fine when browsing though.

Meor
Malaysia
3/7/2005 1:54:32 AM
Gravatar
Total Posts 18439

Re: Visual Studio - Master Pages

When I create a new page I just create a normal WebForm then copy the needed bit from an exisiting page.  I have noticed that master pages doesn't play well with the designer but I don't really use the designer and drag/drop stuff myself. I prefer to work in the Html view. I'm thinking eventually when the official Master Pages comes out in ASP.NET 2.0, I will convert to that and it probably will work better in the designer. The current implementation of Master Pages that is used in mojoPortal was done by Paul Wilson and actually I think it did have some designer support but I commented it out for some reason I can't remember at the moment. If you look in the MasterPage.cs file under the Components folder in the Web project, you'll see where I commented it out. You may want to experiment with un-commenting it and see if it works better for you. I'm thinking for the designer you would have to compile MasterPages into its own dll and add it to the toolbox but I'm really not sure. It just has never bothered me at all because I don't use the designer.
3/7/2005 12:49:39 PM
Gravatar
Total Posts 3

Re: Visual Studio - Master Pages

Thanks for the reply.

I have tried to figure it out myself, but since I found out you had built and compiled the Master Page inside your library (mojoPortal.Web) I thought there were some details that I had left.

I will try to comment out those that you had advised. If, however, I would to separate the Master Page as another project, would it be as simple as including Paul Wilson's dll/project and remove your MasterPage code?

I did use the original ASP.NET Portal by Susan Warren with notepad and command line before, but I just love the designer now :)

Thanks a lot for your time
7/12/2005 7:36:02 AM
Gravatar
Total Posts 73

Re: Visual Studio - Master Pages

I wonder if you managed to do it. I want to develop in VS 2003 with designer and find it cumbersome to do without it.

Jan

7/12/2005 1:14:51 PM
Gravatar
Total Posts 73

Re: Visual Studio - Master Pages

I tried it myself. First I moved the Components subdir to a new project. I compiled the project and changed all the references in the rest of the code. The problem remained. Then I replaced the 'public MasterPage()' code with the 'public MasterPage()' code from Wilson. I also activeted the commented code Joe mentions. The designer did not give any problem. Apparently the code within 'public MasterPage()' is causing the problem. I'm going to sleep now, try to continue tomorrow.

Jan

7/12/2005 1:23:43 PM
Gravatar
Total Posts 18439

Re: Visual Studio - Master Pages

If you find it is something I can change to support the desinger without breaking anything else let me know and I'll be glad to do it.  I have a vague recollection that there was an older version of MasterPages that may have worked in the designer but it had performance problems and when he made the changes to fix it it no longer worked in the designer. I could be totally wrong on that but seems like I read something about it way back.

Anyway, another option if you want to use the desinger to add your own features, is to do your features as regular UserControls then just position them within the page. That way you would have designer support while working in the user control and just put minimal code in the page to load your control.

Hope it helps,

Joe
7/13/2005 4:15:17 AM
Gravatar
Total Posts 73

Re: Visual Studio - Master Pages

The problem appears to be in the fact that Context only exists within a HTTPContext. Because Visual Studio is a plain Windows application, there is no HTTPContext and the container cannot be created.

Adding code like

if (Context != null)

{ ...

}

arround the code within public MasterPage(), prevents the HTTPContext stuff being evaluated when used within designer. The code needs to be in a real assembly (i.e. compiled) and therefor has to be separated from the rest of the mojoPortal.Web code.

Using this, there seems to be no negative effect on the speed of the application. it looks faster, but I have only tested upto default.aspx. Still have to change the references in the other aspx modules.

Jan

7/13/2005 2:10:08 PM
Gravatar
Total Posts 18439

Re: Visual Studio - Master Pages

I don't quite understand. Its compiled into a real assembly, mojoPortal.Web.dll, how is that not real?

7/13/2005 2:20:02 PM
Gravatar
Total Posts 18439

Re: Visual Studio - Master Pages

OK, I figured out what you were saying, it was getting an error as you said due to the use of HttpContext since there is no HttpContext at design time.

I put the code as you said if(HttpContext.Curent != null) and it works!

It doesn't need to be in a separate assembly, its still in mojoPortal.Web.dll.  I've committed it to svn. 

Thanks for your help!

Joe
8/28/2005 3:57:44 PM
Gravatar
Total Posts 3

Re: Visual Studio - Master Pages

Thanks man, it works, finally :)
You must sign in to post in the forums. This thread is closed to new posts.