Strategy ONE

Creating a New Page Section or a Page Template File

You can create a new file and use it as a new page template or a page section. This section discusses the steps to create a new file (jsp/ascx), and the Adding, Removing or Modifying Page Sections topic discusses how you can add it to MicroStrategy Web.

The steps to create a new file differ based on the environment (J2EE or .NET) in which you are working.

J2EE environment

To create a new file, you can make a copy of an existing JSP file and edit it accordingly, or create the new file from scratch. Once this custom file is ready with all the necessary include files and so on, use the Web Customization Editor to include the custom file in the MicroStrategy Web product. This is discussed in the Adding, Removing or Modifying Page Sections topic.

.NET environment

The approach for creating a new file in this environment is dictated by the Microsoft .NET Framework 2.0. Refer to the MicroStrategy Web readme to see the latest version of the certified .NET Framework.  You can create a new file using either the single-file page model or the code-behind page model as governed by the .NET Framework. Refer to the ASP.NET Web Page Code Model topic in MSDN for a detailed discussion on the two page models and which model is better for your development purpose.

  • Using the Single-File Page Model

    In this model, the page's presentation logic and business logic (programming code) are in the same ASP .NET file (denoted by an ascx or aspx extension). The programming code is in a script block that contains the attribute runat="server" to mark it as code that ASP.NET should execute. Consider the following example of a custom file called MyReport_Content.ascx. The subroutine in the file indicates the error page Error_Content.ascx to be used for displaying the error.

    <%@ Page Language="VB" %>

    <%@ Register TagPrefix="web" Namespace="MicroStrategy.Tags"%>

    <script runat="server">

       Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

         Dim ex As System.Exception

         Try

             Me.errorPageName = "Error_Content.ascx"

         Catch ex

           Me.setError(Me, ex)

         End Try

       End Sub

    </script>

    <html>

         ...

    </html>

    Refer to Development in a .NET environment for best practices and guidelines to be followed when writing custom code in a .NET environment.

  • Using the Code-Behind Page Model

    In this model, every ASP .NET file (denoted by an ascx or aspx extension) has a corresponding Visual Basic code-behind file (denoted by an ascx.vb or aspx.vb extension) that contains the code or logic for the ASCX or ASPX file. Thus, mstrWeb.aspx uses mstrWeb.aspx.vb and Report_Content.ascx uses Report_Content.ascx.vb.

    When you want to create a new file, you must also create its corresponding vb file. The most important parameters that need to exist in these files are listed below:

    • Namespace and Class information in the vb code-behind file with the ascx.vb or aspx.vb extension. 

    • CodeFile and Inherits in the ASP .NET file with the ascx or aspx extension.

    When you create the vb file, it must have information about the class. This is the first line of code, as indicated below in the example of a custom file called MyReport_Content.ascx.vb. The subroutine in the file indicates the error page Error_Content.ascx to be used for displaying the error.

    NamespaceMyCompany

     Partial ClassMyReport_Content

       Inherits MicroStrategy.MSTRControls.MSTRUserControl

       

       Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

         Dim ex As System.Exception

         Try

             Me.errorPageName = "Error_Content.ascx"

         Catch ex

           Me.setError(Me, ex)

         End Try

       End Sub

     End Class

    End Namespace

    The Namespace used by all MicroStrategy Web pages is MicroStrategy. It is recommended that you use a different Namespace for your custom files for better organization and manageability.  Also provide the class with a meaningful name.

    The ASP .NET file must have information about its corresponding vb file. This is retrieved from the first line of code as indicated in the following example of MyReport_Content.ascx.

    <%@ Control Language="vb" AutoEventWireUp="false"CodeFile="MyReport_Content.ascx.vb"Inherits="MyCompany.MyReport_Content"%>

    <%@ Register TagPrefix="web" Namespace="MicroStrategy.Tags"%>

    The Codebehind value for your custom file is the name of the vb file you create. The Inherits value indicates the class that must be inherited and has the following syntax: Namespace.Class Name.

    Refer to Development in a .NET environment for best practices and guidelines to be followed when writing custom code in a .NET environment.

See also