MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Documentation on writting your own plugin ?  (Mono Support )

Viewed 73354 time(s), 21 post(s) 12/30/2010 6:11:32 PMby shawndg
shawndg

shawndg

1/11/2011 12:37:26 AM
It compiles...

But I cant find my webpart anywhere inside monox..

Im not sure how to make it show up in monox..

?
This content has not been rated yet. 
1871 Reputation 252 Total posts
shawndg

shawndg

2/15/2011 12:56:24 PM
ok..

I been hacking at this now for .. non stop.. 48 hours just about and.. im having a hard time trying to build a Monox compiled webpart..

.. I started over... I started from a blank portal, I compiled it ok.. no-problems.. blank portal.. changed name space and assemble name too .. "Scene.Web"

I then added a folder to the portal and named it CusScene..

I then right clicked on my new folder and added a new user control to it.. I named my new control "WebPart"

Below is my code...

WebPart.ascx..

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebPart.ascx.cs" Inherits="Scene.Web.CusScene.WebPart" %>
<p>
    Name? 
    <asp:TextBox ID="TxtName" runat="server"></asp:TextBox>
    <asp:Button ID="CmdGO" runat="server" onclick="CmdGO_Click" Text="GO" />
</p>
<p>
    HELLO
    <asp:Label ID="lblName" runat="server" Text="Label"></asp:Label>
</p>
<p>
     </p>



WebPart.ascx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 MonoSoftware.MonoX;
 
namespace Scene.Web.CusScene
{
    public partial class WebPart : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void CmdGO_Click(object sender, EventArgs e)
        {
            lblName.Text = TxtName.Text;
        }
    }
}


AutoGenerated Code - WebPart.ascx.designer.cs
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
 
namespace Scene.Web.CusScene {
     
     
    public partial class WebPart {
         
        /// <summary>
        /// TxtName control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.TextBox TxtName;
         
        /// <summary>
        /// CmdGO control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button CmdGO;
         
        /// <summary>
        /// lblName control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Label lblName;
    }
}



-I compiled the portal solution.. it created.. the following dll in the bin dir of monox..
Scene.Web.dll

Now.. im not sure.. why im not seeing my webpart inside monox.. or am i missing something ?
This content has not been rated yet. 
1871 Reputation 252 Total posts
denis

denis

2/15/2011 12:57:11 PM
You may now use your new part in two ways. However, it is VERY important that your custom parts inherit from MonoSoftware.MonoX.BasePart, or from MonoSoftware.MonoX.BaseAutoRegisterPart if they are to be used in ModuleGallery (see below).

1. programatically: declare the control in the header of your page (note that I used names and paths according to your specifications, it is posible that something has to be changed):
<%@ Register Src="/CusScene/WebPart.ascx" TagPrefix="CusScene" TagName="TestPart" %>

and than put the part on the desired position in the page:

<CusScene:TestPart ID="ctlTestPart" runat="server"></CusScene:TestPart>


2. interactively using the module gallery: you may see all built-in parts in the part gallery (open the administrative toolbar on any MonoX page, click on the part gallery icon and you will see all parts in the main part catalog). If you want to add custom parts to the gallery, you have to tell MonoX where to look for them. There is a web.config setting ModuleGalleryPath that holds a comma-separated list of paths that are scanned in search for custom parts (that must inherit from BaseAutoRegisterPart to be recognized). Just add your folder to this setting and your custom parts should show in the catalog. Note that Web parts may be interactively added only to Web part zones - more on this topics can be found in any of the articles or books displayed on [url=http://monox.mono-software.com/MonoX/Pages/AdditionalResources.aspx]our resoures page[/url].

Please do contact our support if you need additional help on this. We don't want you to spend too much time on such relatively simple techniques.
This content has not been rated yet. 
7207 Reputation 956 Total posts
shawndg

shawndg

2/15/2011 12:57:33 PM
Ok..

I created a new file... and called it Webpart.aspx and placed the following code in it..

<%@ Page
Language="C#"
MasterPageFile="/MonoX/MasterPages/Default.master"
AutoEventWireup="true"
Inherits="MonoSoftware.MonoX.BasePage"
Theme="Default"
Title=""
%>
<%@ MasterType TypeName="MonoSoftware.MonoX.BaseMasterPage" %>
<%@ Register Src="/CusScene/WebPart.ascx" TagPrefix="CusScene" TagName="TestPart" %>
 
<CusScene:TestPart ID="ctlTestPart" runat="server"></CusScene:TestPart>


Ok.. now how to I get it to show up inside Monox ? Do I need to move the new file to a directory ? the bin control is automaticly already being placed in root/bin the same location as the other monox dlls..

But im not sure about this file.. or if I even did this right... I think you mean to create a whole new file.. and according to the monox pdf it looks about right..

But now im thinking... maybe im missing a step...
This content has not been rated yet. 
1871 Reputation 252 Total posts
denis

denis

1/11/2011 9:54:23 PM
Just put this page inside the MonoX folder hierarchy - basically wherewer you want except the special folders like App_Themes or bin. You can register it via Page administration - right click on a page list - Register portal page. An alternative would be to just access your new page via the browser, if everything is OK and the page runs without errors, it will auto-register with MonoX.

New page can also be created interactively, by clicking on a New page in the Page administration context menu. However, the technique you have choosen allows for greater control.
This content has not been rated yet. 
7207 Reputation 956 Total posts
shawndg

shawndg

2/15/2011 12:57:58 PM
Ok.. I created the file.. Webpart.aspx.. and put it in the root\MonoX\ModuleGallery\CusScene
dir.. I even moved it into the root\MonoX\ModuleGallery\ but when I go to the design portion of a webpage.. inside monox... parts gallery.. I still do not see my part anywhere..

Now this prompt me to start digging at the files inside the ModuleGallery directory... and I noticed they actually look a little different then my file..

They are using assembly references and since my control is also a assembly.. its compiled and it can be found in root/monox/bin/Scene.Web.dll which is what im trying to do..

I am trying to compile my control into a dll webpart then somehow make it show up inside monox.. The src part of my example.. makes me think maybe that part is wrong..

I want to be able to drag and drop my webpart inside monox..

The code i found inside the other webparts looks like this..
<%@ Register Assembly="MonoX" Namespace="MonoSoftware.MonoX.Controls" TagPrefix="mono" %>


I just wish the example included a simple compiled control so that I could see how its setup.. my biggest problem currently is that everything i find in the documentation as well as the samples are all script level controls.. and not a compiled dll webpart controls...
This content has not been rated yet. 
1871 Reputation 252 Total posts
denis

denis

1/12/2011 5:15:37 PM
There are a few confusing facts in your previous post... why do you want to put the page in the module (part) gallery?

Webpart.ASPX is a PAGE. It does not go to the module gallery. It may be placed anywhere. It is available as is, just enter ITS ADDRESS in the browser and it should show up and auto-register with MonoX.

Webpart.ASCX is a PART. It should go to the module gallery if you want to drag and drop it on the page. However, if you put it on the page as you did in your code samples (statically), you don't need to do anything else - it is already present on the page. If you want to use it accross pages and drag and drop it from part catalog to the page it does NOT have to be declared this way. Instead, just put an empty Web part zone on the page and register the part in the Web part gallery:

"You may see all built-in parts in the part gallery (open the administrative toolbar on any MonoX page, click on the part gallery icon and you will see all parts in the main part catalog). If you want to add custom parts to the gallery, you have to tell MonoX where to look for them. There is a web.config setting ModuleGalleryPath that holds a comma-separated list of paths that are scanned in search for custom parts (that must inherit from BaseAutoRegisterPart to be recognized). Just add your folder to this setting and your custom parts should show in the catalog. Note that Web parts may be interactively added only to Web part zones - more on this topics can be found in any of the articles or books displayed on our resoures page."

Do not worry about assembly references.
I think that you should contact us via MSN or Skype to go over this.
This content has not been rated yet. 
7207 Reputation 956 Total posts
denis

denis

1/12/2011 6:23:25 PM
I have another idea: could you please study the sample in the [url=http://www.mono-software.com/Download/MonoX.pdf]manual[/url], section 14.3.1, page 140: "Hello world Web part", it was updated today.
It contains code for a page and Web control, showing how you can have both static and dynamic parts on the page and how to include your part to the catalog.
This content has not been rated yet. 
7207 Reputation 956 Total posts
shawndg

shawndg

2/15/2011 12:59:09 PM
I am happy to report.. i got it to work!!1
Thx for all the guidance a long the way..
For all of you who may be running into the same issues as me..

Here is what you need to do to get a custom web part to compile dynamical inside monox..

First.. just get the basic code up and running using the portal project that comes with monox.. make sure you move the solution files to the root of your monox and make sure your running visual studio as a administrator or else you may have some off upgrade issues and visual studio may report problems detecting the version of the portal solution..

I set the solution properties to something more my liking..
Assemble Name = Scene.Web
Namespace = Scene.Web

Once.. you pass this problem.. now its time to create a simple folder to hold your webpart..
just right click on the portal solution and create a folder.. call it something.. in my example I called my folder CusScene..

Now right click on the folder and add a new item - custom web user control.. I named my control WebPart.. Ok.. now you can code some stuff your self or just copy and past the following code into the controls.

WebPart.Ascx - Main Design - Source HTML
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebPart.ascx.cs" Inherits="Scene.Web.CusScene.WebPart" %>
<p>
    Name? 
    <asp:TextBox ID="TxtName" runat="server"></asp:TextBox>
    <asp:Button ID="CmdGO" runat="server" onclick="CmdGO_Click" Text="GO" />
</p>
<p>
    HELLO
    <asp:Label ID="lblName" runat="server" Text="Label"></asp:Label>
</p>
<p>
     </p>


WebPart.ascx.cs

Note the most important part here.. is to make sure you inherit.. from monox..

MonoSoftware.MonoX.BaseAutoRegisterPart or something below this.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 MonoSoftware.MonoX;
 
namespace Scene.Web.CusScene
{
    public partial class WebPart : MonoSoftware.MonoX.BaseAutoRegisterPart
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void CmdGO_Click(object sender, EventArgs e)
        {
            lblName.Text = TxtName.Text;
        }
    }
}


WebPart.ascx.designer.cs - should be auto generated for you wehn you build the project.. but here the code anyways..

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
 
namespace Scene.Web.CusScene {
     
     
    public partial class WebPart {
         
        /// <summary>
        /// TxtName control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.TextBox TxtName;
         
        /// <summary>
        /// CmdGO control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button CmdGO;
         
        /// <summary>
        /// lblName control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Label lblName;
    }
}



Once you compile the code.. you can not just move the control into the C:\Monox\MonoX\ModuleGallery - WebPart.ascx .. its good idea to change this some.. or use your own dir so you cant conflict with anything that monox has in its default gallery.. I plan to just put all my controls in their own folder... but for a quick test.. this worked just fine..

Once i have the part inside their.. i went into monox - logged into admin.. then put any page into design move.. and i could simply place my control anywhere inside monox..

presto!! this is exactly what I was trying to do.. now i can go wild and designing and building any custom control I need and simple allow my website users to drag and drop it into monox! woohoo..
This content has not been rated yet. 
1871 Reputation 252 Total posts
denis

denis

1/12/2011 9:42:00 PM
I am happy to hear that you have everything running. BTW, using your own folders for pages/parts/themes/whatever is always recommended, as all MonoX upgrades replace the content of "system" folders: App_Themes/Default (+Common, DefaultAdmin), App_Templates/Default (+Common, +DefaultAdmin), bin, and MonoX.
This content has not been rated yet. 
7207 Reputation 956 Total posts
1 2 3