Creating a User widget

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
10/3/2012 10:48:46 AM
Gravatar
Total Posts 40

[SOLVED] Creating a User widget

Hello,

I am trying to create a user widget to replace the top mojoPortal bar where the WelcomeMessage...RegisterLink appear.

I want to create a widget to be called somewhere in my layout.Master like <user:Widget runat="server"... /> and then i will place inside some of the current items like <portal:UserProfileLink.../><portal:LoginLink.../> etc...

1) I have added the following to the Web.config:

<addtagPrefix="user"   tagName="Widget" src="~/Controls/User/Widget.ascx"/>

2) Created a Web User Control named Widget.ascx inside folder Controls/User/

---- Widget.ascx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Xpto.Web.UI.Controls.User
{
   public partial class Widget : System.Web.UI.UserControl
   {
      protected void Page_Load(object sender, EventArgs e)
      {}
   }
}

----- Widget.ascx

<%@ ControlLanguage="C#" AutoEventWireup="true" CodeBehind="Widget.ascx.cs" Inherits="Xpto.Web.UI.Controls.User.Widget" %>

<div><h1>Hello world!</h1></div>

3) I build and refresh mojo and get the following error:

System.Web.HttpParseException (0x80004005): Unknown server tag 'user:Widget'. ---> System.Web.HttpParseException (0x80004005): Unknown server tag 'user:Widget'. ---> System.Web.HttpException (0x80004005): Unknown server tag 'user:Widget'. 

 

What am i missing here?

Thank you in advance!
Best regards,
João

10/3/2012 11:22:27 AM
Gravatar
Total Posts 40

Re: Creating a User widget

Solved!

Turns out i was adding the tagName declaration in my projects' Web.config. On the post-build events only the files are copied to mojo's controls and dll's so mojo's Web.config did not get the declaration for my user tag.

Typed it again there and it worked!

Any ideas on how to automate the changes on mojo's Web.config?

Best regards,
João

10/3/2012 11:25:09 AM
Gravatar
Total Posts 1196
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Creating a User widget

If you look at the top of the tagPrefix declarations in web.config, you'll see that the namespace and assembly for "portal" are declared separately like this:

<add tagPrefix="portal" namespace="mojoPortal.Web.UI" assembly="mojoPortal.Web"/>

So you'll need a corresponding second declaration for your own namespace/assembly for "user".

Jamie

10/3/2012 11:40:16 AM
Gravatar
Total Posts 18439

Re: Creating a User widget

If I were you I would declare it directly in the top of your layout.master file so you don't have to maintain that change in Web.config during upgrades.

<%@ Register TagPrefix="user" TagName="Widget" Src="~/Controls/User/Widget.ascx" %>

namespace and assembly are used for declaring server controls, user controls are declared as above when in the page or like this in Web.config:

<add tagPrefix="portal" tagName="SkinList" src="~/Controls/SkinSetting.ascx"/>

Hope that helps,

Joe

10/4/2012 3:42:26 AM
Gravatar
Total Posts 40

Re: Creating a User widget

Thank you Joe, i declared it on top of the layout.master and it works!
Thanks for the hint Jamie but i want to avoid mantaining web.config.

Best regards,
João

You must sign in to post in the forums. This thread is closed to new posts.