User Control in VB.Net

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.
9/25/2010 10:20:14 AM
Gravatar
Total Posts 7

Re: User Control in VB.Net

Thanks Joe for the quick response.

I have everything being copied, i.e. all my dlls etc. through post build events and they are all the web folder

xcopy /s /y "$(ProjectDir)bin\CoachAlert.UI.dll" "$(SolutionDir)Web\bin\"
xcopy /s /y "$(ProjectDir)bin\CoachAlert.Business.dll" "$(SolutionDir)Web\bin\"
xcopy /s /y "$(ProjectDir)bin\CoachAlert.Data.dll" "$(SolutionDir)Web\bin\"
xcopy /s /y "$(ProjectDir)AddAthlete\*.ashx" "$(SolutionDir)Web\AddAthlete\"
xcopy /s /y "$(ProjectDir)AddAthlete\*.ascx" "$(SolutionDir)Web\AddAthlete\"
xcopy /s /y "$(ProjectDir)AddAthlete\*.aspx" "$(SolutionDir)Web\AddAthlete\"
xcopy /s /y "$(ProjectDir)App_GlobalResources\*.resx" "$(SolutionDir)Web\App_GlobalResources\"
xcopy /s /y "$(ProjectDir)Setup\*" "$(SolutionDir)Web\Setup"

I even tried the code inline example and that didn't work either.

not sure what to try now.  maybe my setup on my web admin side in mojo portal is wrong, added it in admin and the created a new page where i added my 'feature'

My control source is:  AddAthlete/AddAthlete.ascx

I have a folder in the web folder called addathlete and have the ascx there.  

9/25/2010 10:37:25 AM
Gravatar
Total Posts 18439

Re: User Control in VB.Net

And you've verified the files have landed there?

are you seeing any errors in the log?

If there is any error in your usercontrol it will fail to load and can produce a page not found error

When using codebehind you don't specify the class so you need to remove ClassName="AddAthlete.ascx"

and your Inherits not correct, it should only list the class that is the codebehind, so this:

Inherits="CoachAlert.UI.AddAthlete,mojoPortal.Web.SiteModuleControl"

should be

Inherits="CoachAlert.UI.AddAthlete"

and in your codebehind you need to change this:

Inherits System.Web.UI.UserControl

to this:

Inherits mojoPortal.Web.SiteModuleControl

Hope it helps,

Joe

9/25/2010 11:00:54 AM
Gravatar
Total Posts 7

Re: User Control in VB.Net

Joe,

When i get this working its definitely worth  buy a beer!

i changed to Inherits mojoPortal.Web.SiteModuleControl

but it said not defined so i changed to global.Inherits mojoPortal.Web.SiteModuleControl

 

but i think that may be telling me im missing something.  I changed to global but still a blank page.

once I fix the inherit, hopefully it will work, but wondering if something is wrong with the projects web.config or master page?  the web.ocnfig has the pages in it.  master page was from the store.ui.

9/25/2010 11:03:46 AM
Gravatar
Total Posts 18439

Re: User Control in VB.Net

You need to add a reference from your custom project to the mojoPortal.Web project. Right click the references node in your project and then look on the Projects tab to set a reference to mojoPortal.Web.

Hope it helps,

Joe

9/25/2010 11:12:24 AM
Gravatar
Total Posts 7

Re: User Control in VB.Net

Joe,

I had that reference already set.

Type mojoportal.web.sitemodulecontrol not defined.

Thanks for your help on this.  Once I get it going ill be able to start on my project and be able to create more modules.

9/25/2010 11:19:07 AM
Gravatar
Total Posts 18439

Re: User Control in VB.Net

Get rid of this stuff if you have it in the .ascx file, this was only for using inline code not codebehind

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

in your codebehind make sure you have

Imports mojoPortal.Web

also it looks like you commented out your namespace CoachAlert.UI , you should uncomment that

Hope it helps,

Joe

9/25/2010 11:26:15 AM
Gravatar
Total Posts 7

Re: User Control in VB.Net

Just as I saw your post I was compiling without the inline <%@ items :)

If I put the name space back in, I notice my reference to any labels or text boxes has this error: button 1 is not declared it may be inaccessible due to its protection level

I have imports mojoportal.web in my imports.

9/25/2010 11:29:44 AM
Gravatar
Total Posts 18439

Re: User Control in VB.Net

Your .designer file may have been confused by some of the changes like changing the base class. Sometimes switching to design view may fix it or look in the .designer file and fix things manually if the controls are not declared correctly.

9/25/2010 11:39:30 AM
Gravatar
Total Posts 7

Re: User Control in VB.Net

i blew everything out and recrecerted, still have to use global.mojoportal for the inherit and can't see the controls on the ascx page.  I think we are up to 2 beers by now.!

ascx

<%@ Control Language="VB" AutoEventWireup="false" CodeBehind="AddAthlete.ascx.vb" Inherits="CoachAlert.UI.AddAthlete" %>

 

<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 linksmodule">
<portal:ModuleTitleControl id="Title1" runat="server" />
<portal:mojoPanel ID="MojoPanel1" runat="server" ArtisteerCssClass="art-PostContent">
<asp:Panel ID="pnlCoachAlert" runat="server" EnableViewState="false" CssClass="modulecontent">

Your custom form goes here.
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />

</asp:Panel>
<div class="modulefooter"></div>
</portal:mojoPanel>
<div class="cleared"></div>
</asp:Panel>
<mp:CornerRounderBottom id="cbottom1" runat="server" />
</portal:mojoPanel>
 

 

codebehind

Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.Configuration
Imports System.Globalization
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports mojoPortal.Web
Imports mojoPortal.Web.Framework
Imports mojoPortal.Web.UI
'Imports log4net
Imports Resources
Imports CoachAlert.UI


Namespace CoachAlert.UI


    Partial Public Class AddAthlete
        Inherits Global.mojoPortal.Web.SiteModuleControl
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
            Dim button1 As New Button
            button1 = Me.FindControl("button1")
            button1.Text = "Howdy"
        End Sub

    End Class
End Namespace

designer file

 

'------------------------------------------------------------------------------
' <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>
'------------------------------------------------------------------------------

Option Strict On
Option Explicit On


Partial Public Class AddAthlete

'''<summary>
'''mp1 control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents mp1 As Global.mojoPortal.Web.UI.mojoPanel

'''<summary>
'''ctop1 control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents ctop1 As Global.mojoPortal.Web.Controls.CornerRounderTop

'''<summary>
'''pnlWrapper control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents pnlWrapper As Global.System.Web.UI.WebControls.Panel

'''<summary>
'''Title1 control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents Title1 As Global.mojoPortal.Web.UI.ModuleTitleControl

'''<summary>
'''MojoPanel1 control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents MojoPanel1 As Global.mojoPortal.Web.UI.mojoPanel

'''<summary>
'''pnlCoachAlert control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents pnlCoachAlert As Global.System.Web.UI.WebControls.Panel

'''<summary>
'''TextBox1 control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents TextBox1 As Global.System.Web.UI.WebControls.TextBox

'''<summary>
'''Button1 control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents Button1 As Global.System.Web.UI.WebControls.Button

'''<summary>
'''cbottom1 control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents cbottom1 As Global.mojoPortal.Web.Controls.CornerRounderBottom
End Class
 

9/25/2010 11:51:44 AM
Gravatar
Total Posts 18439

Re: User Control in VB.Net

Make sure you also add a project reference to mojoPortal.Web.Controls project

and in code behind

Imports mojoPortal.Web.Controls

also it is best if your custom project does not have a global.asax in it

Hope it helps,

Joe

9/25/2010 12:07:22 PM
Gravatar
Total Posts 7

Re: User Control in VB.Net

still a blank page.

 

See email I sent you.  Not sure where to go now.

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