Mono Support How to create a custom UserControl in monox ? 

Viewed 7991 time(s), 2 post(s), 5/7/2014 4:10:03 PM - by super
5/7/2014 4:10:03 PM
6018 Reputation 709 Total posts

I want to create a custom .ascx user control in monox.

I know how to do that in a standard asp.net application but I am getting error in monox as I need advise if I need to follow any guidelines ?

Here is that I have done so far.

1- Create a folder on root: "UserControl"

2- Added a new .ascx as "TestSqlUserControl.ascx"

3- Here is the .ascx code:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestSqlUserControl.ascx.cs" Inherits="MonoSoftware.MonoX.Pages.UserControl_TestSqlUserControl" %>
<%@ Import Namespace="MonoSoftware.MonoX.Resources" %>
<%@ Register Namespace="MonoSoftware.Web.Pager" Assembly="MonoSoftware.Web.Pager" TagPrefix="mono" %>
<h1>
    Test
 
</h1>

4- Here is code behind (TestSqlUserControl.ascx.CS)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MonoSoftware.MonoX.Utilities;
 
public partial class UserControl_TestSqlUserControl : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
}


5- On the homepage I added this:

<%@ Register TagPrefix="MonoX" TagName="TestSqlUserControl" Src="/UserControl/TestSqlUserControl.ascx" %>
<MonoX:TestSqlUserControl runat="server"></MonoX:TestSqlUserControl>


Where I am wrong ? please advise ?

1
5/8/2014 8:44:03 AM
345 Reputation 61 Total posts

Hello Super,
from what I can tell at first glance is that in your code behind class you are inheriting the BasePage class instead of one of the control classes (e.g. BasePagedPart).

Check http://www.mono-software.com/Blog/post/Mono/93/Building-a-custom-Web-part/ for a tutorial how to build custom web parts.

Regards,
Vedran

2
This is a demo site for MonoX. Please visit Mono Software for more info.