Theme Requirements?

Topics: Controls, Themes
Oct 14, 2010 at 3:04 AM

I am using blogengine.net as a blog section of my website, but I am attempting to keep a consistent feel so that it isn't obvious to the user going from blog section and the rest of the site. I have created a theme that matches the rest of my site for the blog engine. the blog is located at siteroot/blog, where as most the site is located in the siteroot.

I had hoped to handle the site navigation with a usercontrol, this works fine in the normal site, but if I use it in my theme it doesn't work, the theme doesn't crash, but the pages always display completely blank/white. I know that it is the usercontol that causes this, the theme works fine otherwise.

The user control is just a div with a rel link to css and js files and a few styled list items for the nav.

What am I doing wrong? is it because they are technically separate applications in the same site? I'm not all that experienced with asp.net I'm normally a winforms guy.

Coordinator
Oct 14, 2010 at 7:46 AM

Usually a user control works.  When you have a completely white page, if you do a "View Source" in your browser, is there any content there?

I would maybe try removing everything from the user control (so it is as empty as possible) and see if if works.  It it does work, then try adding items back a little at a time to see when it stops working.  But if it's not working when everything has been removed, then it's hard to say what's causing it without seeing more.

Oct 14, 2010 at 10:37 PM

thanks, I will try that and post back.

Oct 27, 2010 at 8:26 AM

Ok, I tried with just a user control that has a single link in it. It still showed up completely blank. No error redirect. Just a blank page. when I checked the source it was blank. literally nothing there. I have no idea why I can't use any user controls. But i reproduce the error very easily.

any ideas?

Coordinator
Oct 29, 2010 at 7:20 AM

I would ask you to post your User Control code here to take a look at.  But if all it has in it is a single link, there's probably not much to look at! :)

But it still probably has the <%@ Control %> directive at the very top, right?  Is there a codebehind file for it (i.e. .ASCX.CS) ?

Where and how are you inserting this user control into your theme -- this might be more relevant.  For example, are you using <%@ Register %> at the top of the theme page?  Which theme page/file are you inserting it into?  The placement of the user control in the theme file can also be important.

If there's any code you can post here, that would probably help.   Code meaning the user control code, and the theme file you are inserting the user control into.

Oct 31, 2010 at 3:33 AM

yes it does have the control directive

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="DDNav.ascx.cs" Inherits="DDNav" %>

It also does have a code behind file. simply

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class DDNav : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

}

Then I am using the register directive at the top of the site.master page

<%@ Register Src="~/DDControls/DDNav.ascx" TagName="Nav" TagPrefix="DDNav1" %>  

and then i am just using

<DDnav1:Nav ID="NavMenu" runat="server" />  

in the site.master file for my theme and its located in a div in a very basic 2 column css set up like

<div container> <div nav /> <div widget /> <div main /> </div container>

So what am I doing wrong?

 

Coordinator
Oct 31, 2010 at 9:59 PM

I don't think you're doing anything wrong.  I created files with your content and was able to put the user control in the site.master file without any problems (the user control appeared, as expected).  So what you have looks correct.

If you're using a custom theme, you might want to try putting the user control in the Standard theme to see if it makes a difference.

You could also try putting the user control into a standalone ASPX page, just to see if it works there.  Here's the contents for a standalone page you can name anything (e.g. test.aspx).

<%@ Page Language="C#" %>
<%@ Register Src="~/DDControls/DDNav.ascx" TagName="Nav" TagPrefix="DDNav1" %>

test page
<DDnav1:Nav ID="NavMenu" runat="server" />

Nov 1, 2010 at 1:54 AM

I know that the control itself works fine, because I use it in my site. I am using blogengine.net just for the blog section of my site, I created matching master pages. one for my basic site, one for the theme. It works fine not in the blogengine.net theme

Just adding the register directive to the masterfile breaks the theme. I can't seem to find any reason why.

There is no code errors displayed, the page is just completely empty, and the source reflects that.

I will try putting my control in the standard theme and see how it goes and post back.

Thanks for all your help.

Nov 1, 2010 at 7:49 PM

would it be asking too much to ask you to email the code example you tested to RickeyWard(at)DiamondDrake(dot)com ?

That way I could test against you code to find resolve.

Coordinator
Nov 1, 2010 at 9:29 PM

I emailed you a ZIP of a new BE 1.6 instance with the user control in it.

If your blog is in a subfolder and there's a main website, one possibility is that the ~/DDControls is not resolving to the correct directory.  As an example, if your blog is in a subdirectory /blog, and DDControls is in /blog/DDControls, then ~/DDControls might be pointing to the wrong location.  The DDControls folder should maybe be moved to the website root.  Just guessing here.  This might not be how things are setup, and I would expect you would receive an error message if this was the case.  Hopefully the email will help.

Nov 2, 2010 at 1:54 AM

thanks, I got your email and I am working now on trying to find out why yours works an mine doesn't. I am going to try posting your example on my web server and checking to see if it works there.

I have some generic questions that might help me find the solution.

I have the blog in a sub-directory called /blog/ and I use godaddy.com hosting. (asp.net 2.0) I have set the /blog/ directory as an application root, so all the ~/ paths work just fine. But what if I want to use a user control off the siteroot not the application root? can I ../../ my way back to the real site root? Will a full URL path work in that situation? like http://www.site.com/controls/control.aspx ?

I have been trying to just add the user control to the blog/DDControls/ directory for simplicity, but optimistically I would like the theme @ root/blog/themes/diamonddrake/ pull the usercontrol from root/controls/ But for now i have just been trying to get it to work at all.

I will post back with my findings. Thanks again for all your help.

Coordinator
Nov 2, 2010 at 2:29 AM

I'm 99.999999% sure it's not possible to reference a user control that's outside of the blog application.  If you tried setting the "Src" to something like /../DDControls/control.ascx, etc. or an absolute URL, you'll get an ASP.NET error indicating that the control must be within the same application.

So you would need to have the same control in two locations -- the main site, and within the blog.  If you are updating the user control a lot and don't want to deal with always remembering to keep them in sync, you could create something that compares the timestamps of the ASCX file in both applications (main website app and the blog app).  It could then copy the physical file from the main website to the blog app if it differs.  This is allowed to do -- i.e. from the blog app, you can access files on the file system that are part of the main website (outside of the blog).

Nov 2, 2010 at 2:31 AM

I noticed that the example you sent me was with blogengine 1.6.0.0 and I am using 1.6.1.0

Do you think that makes a difference with this error I am receiving?

Coordinator
Nov 2, 2010 at 3:57 AM

No, I don't think it matters.  I originally put your User Control code into BE 1.6.2.x and it worked okay there too.

Nov 4, 2010 at 7:19 PM

I hate to say this. But I just can't get it to work. I don't admit defeat easily, but I'm willing to argue that there is a unknown factor at work here that I don't have the sanity to track down.

I really appreciate all your help. Maybe I'll try again when the next version comes out. For now I'll just deal with a usercontrol in main site, and copy and paste that content directly into the masterpage for my blog. I really wanted to understand what I was doing wrong. But from what I can tell there is no reason it shouldn't work.

Thanks again Ben, I owe you one.

btw my blog is located at http://www.diamonddrake.com/blog/

Nov 7, 2010 at 5:40 PM

I got it working. thanks for all your help Ben.