Code Blocks not working in module

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.
8/22/2010 4:43:23 PM
Gravatar
Total Posts 26

Code Blocks not working in module

Hiya, Im new to developing on MojoPortal, looks good by the way, but I ran into trouble the first time I tried developing a module for the system. I had a simple hyperlink on the module I started from your codesmith templates, but where I ran into trouble was putting in code blocks for any of the properties, particularly for NavigateUrl of which my example was exactly the same as the other Features.UI examples adding pageid and moduleid. The parameter would just disappear in the outputted html and the logs spoke of nothing in terms of bugs

I got around it in the end by changing it programatically in the code behind, but it baffled me, does it look like Im doing anything wrong?

Thanks

Hurricane

Finished files below with my workaround

<%@ Control Language="C#" AutoEventWireup="false" CodeBehind="members.ascx.cs" Inherits="Iwi.UI.membersModule" %>
<portal:mojoPanel ID="mp1" runat="server" ArtisteerCssClass="art-Post" RenderArtisteerBlockContentDivs="true">
<mp:CornerRounderTop ID="ctop1" runat="server" />
<asp:Panel ID="pnlWrapper" runat="server" CssClass="art-Post-inner panelwrapper members">
<portal:ModuleTitleControl runat="server" ID="TitleControl" />
<portal:mojoPanel ID="MojoPanel1" runat="server" ArtisteerCssClass="art-PostContent">
<asp:Panel ID="pnlmembers" runat="server" CssClass="modulecontent">
<div class="settingrow">
<asp:HyperLink ID="hl_edit_details" runat="server">Edit My Details</asp:HyperLink>
</div>
</asp:Panel>
</portal:mojoPanel>
<div class="cleared">
</div>
</asp:Panel>
<mp:CornerRounderBottom ID="cbottom1" runat="server" />
</portal:mojoPanel>


// Author: Hurricane Hunia
// Created: 2010-8-22
// Last Modified: 2010-8-22
//
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by
// the terms of this license.
//
// You must not remove this notice, or any other, from this software.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Globalization;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using mojoPortal.Web;
using mojoPortal.Web.Framework;
using mojoPortal.Web.UI;
//using log4net;
using Iwi.BusinessObjects;
using Resources;

namespace Iwi.UI
{

public partial class membersModule : SiteModuleControl
{
// FeatureGuid bf93880d-ed59-42d4-95f2-60c925db5637

#region OnInit

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.Load += new EventHandler(Page_Load);

}

#endregion

protected void Page_Load(object sender, EventArgs e)
{

LoadSettings();
PopulateLabels();
PopulateControls();

}

private void PopulateControls()
{

TitleControl.Visible = !this.RenderInWebPartMode;
if (this.ModuleConfiguration != null)
{
this.Title = this.ModuleConfiguration.ModuleTitle;
this.Description = this.ModuleConfiguration.FeatureName;
}

hl_edit_details.NavigateUrl = this.SiteRoot + "/Iwi/members/my_details.aspx?PageId=" + this.PageId.ToString() + "&ModuleId=" + this.ModuleId.ToString();


}


private void PopulateLabels()
{
TitleControl.EditText = "Edit";
}

private void LoadSettings()
{


}


}
}

8/23/2010 7:28:30 AM
Gravatar
Total Posts 18439

Re: Code Blocks not working in module

Hi Hurricane Hunia,

You posted the code that does work but you ask about code that does not work.

How can I know what was wrong until I see the code that doesn't work?

Also the parameters in your url should be pageid and mid not PageId and ModuleId if you want to be consistent with other mojoPortal code.

Hope it helps,

Joe

8/24/2010 3:46:55 AM
Gravatar
Total Posts 26

Re: Code Blocks not working in module

My bad Joe example below, the navigateurl just gets left out in outputted html.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="registration_admin.ascx.cs"
Inherits="Iwi.UI.registration_adminModule" %>
<portal:mojoPanel ID="mp1" runat="server" ArtisteerCssClass="art-Post" RenderArtisteerBlockContentDivs="true">
<mp:CornerRounderTop ID="ctop1" runat="server" />
<asp:Panel ID="pnlWrapper" runat="server" CssClass="art-Post-inner panelwrapper registration_admin">
<portal:ModuleTitleControl EditText="Edit" EditUrl="~/registration_admin/registration_adminEdit.aspx"
runat="server" ID="TitleControl" />
<portal:mojoPanel ID="MojoPanel1" runat="server" ArtisteerCssClass="art-PostContent">
<asp:Panel ID="pnlregistration_admin" runat="server" CssClass="modulecontent">
<div class="settingrow">
<ul class="linkitem">
<li class="linkitem">
<asp:HyperLink ID="hl_search" runat="server" EnableViewState="false" Text="Search Member" ToolTip="Search all members to view member record" NavigateUrl='<%# this.SiteRoot + "/Iwi/registration_admin/registration_admin.aspx?mid=" + ModuleId + "&amp;pageid=" + PageId %>'></asp:HyperLink>
</li>
</ul>
</div>
</asp:Panel>
</portal:mojoPanel>
<div class="cleared">
</div>
</asp:Panel>
<mp:CornerRounderBottom ID="cbottom1" runat="server" />
</portal:mojoPanel>
 

using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Globalization;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using mojoPortal.Web;
using mojoPortal.Web.Framework;
using mojoPortal.Web.UI;
//using log4net;
using Iwi.BusinessObjects;
using Resources;

namespace Iwi.UI
{

public partial class registration_adminModule : SiteModuleControl
{
// FeatureGuid d90b5804-86ab-4de3-a56b-23e50d6a5449

#region OnInit

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.Load += new EventHandler(Page_Load);

}

#endregion

protected void Page_Load(object sender, EventArgs e)
{

LoadSettings();
PopulateLabels();
PopulateControls();

}

private void PopulateControls()
{

TitleControl.Visible = !this.RenderInWebPartMode;
if (this.ModuleConfiguration != null)
{
this.Title = this.ModuleConfiguration.ModuleTitle;
this.Description = this.ModuleConfiguration.FeatureName;
}


}


private void PopulateLabels()
{

}

private void LoadSettings()
{


}


}
}
 

8/24/2010 7:32:25 AM
Gravatar
Total Posts 18439

Re: Code Blocks not working in module

Hi Hurricane Hunia,

Syntax like this <%# is for databinding:

NavigateUrl='<%# this.SiteRoot + "/Iwi/registration_admin/registration_admin.aspx?mid=" + ModuleId + "&amp;pageid=" + PageId %>'

to use that syntax I think you would then need to call

hl_search.DataBind();

or this.DataBind()

from your code behind. In the end it is probably just as convenient to set the navigate url from code.

I "think" you could also do it like this with the <%= (which is shorthand for Response.Write):

NavigateUrl='<%= this.SiteRoot + "/Iwi/registration_admin/registration_admin.aspx?mid=" + ModuleId + "&pageid=" + PageId %>'

Note also that you probably don't need to pre-encode the parameters like &amp;pageid in this case because the NavigateUrl property will automatically url encode &pageid to &amp;pageid

But really I think it is probably cleaner in the end to set the url from code like you did already.

Hope it helps,

Joe

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