How to pass parameters with customized 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.
5/3/2013 2:27:02 PM
Gravatar
Total Posts 27

How to pass parameters with customized module

I am creating a customized module using the HelloWorld example as template. The customized module will display SSRS report viewer control. I got the ReportViewer control working and displaying report correctly. Now I want to set up two parameters - ReportServerUrl and ReportPath so that I can fill in those two parameters for each report page when I add a content using the customized module. Could someone show me how to do that in the code? See below for the modified Hello World sample with a report control added.

 


<%@ Control Language="C#" ClassName="HelloMojoModule.ascx" Inherits="mojoPortal.Web.SiteModuleControl"   %>

<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>


<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="mojoPortal.Business" %>
<%@ Import Namespace="mojoPortal.Business.WebHelpers" %>
<%@ Import Namespace="mojoPortal.Web.Framework" %>
<%@ Import Namespace="mojoPortal.Web" %>
<%@ Import Namespace="mojoPortal.Web.Controls" %>
<%@ Import Namespace="mojoPortal.Web.UI" %>
<%@ Import Namespace="mojoPortal.Web.Editor" %>
<%@ Import Namespace="mojoPortal.Net" %>

<script runat="server">
  
   private string ReportServerUrl = string.Empty;
   private string ReportPath = string.Empty;
 
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
      
    }

    protected void Page_Load(object sender, EventArgs e)
    {
     
        LoadSettings();
        PopulateLabels();
        if(!Page.IsPostBack)
        {
         PopulateControls();
        }
       
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "Hello Web I'm a SiteModule and my ModuleID is " + this.ModuleId.ToString(CultureInfo.InvariantCulture);

            ssrsRpt.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
            ssrsRpt.ServerReport.ReportServerUrl = new Uri("http://server1/ReportServer_DEV1");
            ssrsRpt.ServerReport.ReportPath = "/AdventureWorks Sample Reports/Company Sales SQL2008R2";
            //ssrsRpt.ServerReport.Refresh();
    }
 

    private void PopulateControls()
    {
  TextBox1.Text = "Click the button";

    }


    private void PopulateLabels()
    {

    }

    private void LoadSettings()
    {

  // TODO: if your feature has an edit page link to it here
  //Title1.EditUrl = SiteRoot + "/MyClassEdit.aspx";
         //Title1.EditText =
       
        Title1.Visible = !this.RenderInWebPartMode;
        if (this.ModuleConfiguration != null)
        {
            this.Title = this.ModuleConfiguration.ModuleTitle;
            this.Description = this.ModuleConfiguration.FeatureName;
        }

    }

</script>

<portal:OuterWrapperPanel ID="pnlOuterWrap" runat="server">
<mp:CornerRounderTop id="ctop1" runat="server" />
<portal:InnerWrapperPanel ID="pnlInnerWrap" runat="server" CssClass="panelwrapper mymodule">
<asp:UpdatePanel ID="upGallery" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<portal:ModuleTitleControl id="Title1" runat="server" />
<portal:OuterBodyPanel ID="pnlOuterBody" runat="server">
<portal:InnerBodyPanel ID="pnlInnerBody" runat="server" CssClass="modulecontent">

Your custom form goes here.
<asp:TextBox ID="TextBox1" runat="server" CssClass="widetextbox"></asp:TextBox>

    <rsweb:ReportViewer ID="ssrsRpt" runat="server" AsyncRendering="False"
        ExportContentDisposition="AlwaysAttachment" Height="600" Width="800" Font-Bold="False" Font-Names="Verdana" Font-Size="8pt">
    </rsweb:ReportViewer>

<portal:mojoButton ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />

</portal:InnerBodyPanel>
</portal:OuterBodyPanel>
</ContentTemplate>
</asp:UpdatePanel>
<portal:EmptyPanel id="divCleared" runat="server" CssClass="cleared" SkinID="cleared"></portal:EmptyPanel>
</portal:InnerWrapperPanel>
<mp:CornerRounderBottom id="cbottom1" runat="server" />
</portal:OuterWrapperPanel>

5/3/2013 2:41:34 PM
Gravatar
Total Posts 18439

Re: How to pass parameters with customized module

The ModuleControl is only supposed to be the entry point of a feature, if you need to show different things based on parameters you should implement a supporting page in your feature not try to pass extra params to the CMS page that hosts your modulecontrol. The modulecontrol does not own the url for the cms page. What if every feature on a given page wanted to pass extra parameters to the cms page url, it would be a big mess. The ModuleControl needs to be able to play nice on the page that may contain any number of feature instances that it doesn't know about.

The typical scenario is to have a list of items within your module control with links for each item in the list that link to a supporting page for the details passing in the pageid, moduleid (mid)  ,and any extra feature specific params you need in the url for the supporting page. This is how all included features work including the forums, the blog, webstore, etc. Don't try to do everything for a complex feature inside the modulecontrol.

See also videos 22 through 26 of our developer tutorial series.

Keep in mind that the CMS page url is already using url mapping to map the friendly CMS page url to /Default.aspx?pageid=x so it really should not then have more parameters tacked onto the friendly url, also it has one and only one canonical url for seo purposes and that canonical url has no extra parameters. See also How mojoPortal Works.

Hope that helps,

Joe

5/6/2013 2:11:40 PM
Gravatar
Total Posts 27

Re: How to pass parameters with customized module

Thanks for the link. From the following article, I can add the setting for a customized module from the GUI - Admin Menu > Feature Definitions > Feature Definition Settings. I was able to do that from there. I verified that the new settings were added to the [mp_ModuleDefinitionSettings] table. I also was able to configure the value for each content. But I could not retrieve the value in the code. I am still a little bit confused about the resource file. Will the "Add New Setting" wizard automatically generate resource file and the resource entry? In my case,

"ReportServerUrl = Settings["SSRSReportServerURL"].ToString();" did not retrieve the setting values stored in the database. Did I miss anything?

https://www.mojoportal.com/modulesettings-adeveloperconvenience.aspx

 

5/6/2013 2:34:24 PM
Gravatar
Total Posts 18439

Re: How to pass parameters with customized module

mp_ModuleDefinitionSettings is the default value used when a new instance of the feature is created. The one used in the instance comes from mp_ModuleSettings. If the instance already existed before you added a new setting definition then you need to populate it by going to the Settings for the instance (ModuleSettings.aspx). Your default value should appear there but you need to click save to propagate it to mp_ModuleSettings.

Once you do that then Settings[YourKey] should return a value.

Nothing creates resource files for you, you would have to do that yourself and indicate the file in the feature definition settings. If no resource file is found it just uses the resourcekey as the label for the setting. But best not to use any spaces in the resourcekey though.

Hope that helps,

Joe

 

 

5/6/2013 2:55:56 PM
Gravatar
Total Posts 27

Re: How to pass parameters with customized module

Thanks for your prompt response. I finally got the SSRS report viewer working. Now I have to figure why the report rendered differently in the middle column (multiple boxes) from the one in the right column.

 

5/6/2013 4:02:52 PM
Gravatar
Total Posts 27

Re: How to pass parameters with customized module

By the way, how do post a screenshot? I did not see any link that allow me to upload a picture. I tried to copy and paste, it did not seem to work. Thanks again.

5/6/2013 4:19:18 PM
Gravatar
Total Posts 18439

Re: How to pass parameters with customized module

Sorry but I'm a bit of a zealot about security and don't want to allow strangers to upload files on my server, only privileged users can do that currently.

You can link to files or images that you post elsewhere though.

Best,

Joe

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