Here is a sample uc setup to get you started ( this one is for asp.net1)
In a standard user control i start off with a lable and a panel for the error ( thsi will be used to show the correct error to the correct poeple ( admin/ non admin ) . In the panel I have a piece of text defining each of the common misstakes that have to do with my siteadmins filling in the wrong data for the public properties
test.ascx
asp:Label id="Label1" runat="server">Label</asp:Label
asp:Label id="lblError" runat="server" ForeColor="Red"></asp:Label
asp:Panel id="PnlError" runat="server" Wrap="False" Visible="False">Explanation about error for admins</asp:Panel
codebehind
Imports DotNetNuke
Imports DotNetNuke.Entities.Portals
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Public Class test
Inherits System.Web.UI.UserControl
Public testproperty As String
Protected WithEvents lblError As System.Web.UI.WebControls.Label
Protected WithEvents PnlError As System.Web.UI.WebControls.Panel
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'
Try
'Dim modid As String = CType(Me.Parent, DotNetNuke.Entities.Modules.PortalModuleBase).ID.ToString
'DotNetNuke.Entities.Modules.VisibilityState.None()
Label1.Text = CType(testproperty, Integer) & "-" & Me.Parent.UniqueID & "-" & DotNetNuke.Common.Globals.NavigateURL
Catch oEx As Exception
Dim checkerror As ArrayList = Helper.DisplayError(oEx.Message)
lblError.Text = checkerror(0)
PnlError.Visible = checkerror(1)
Exit Try
End Try
End Sub
Private Sub CheckVisible()
Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)
Dim mUser As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo
If mUser.UserID < 1 Then
'User Not Logged In
CType(Me.Parent.Parent, DotNetNuke.Entities.Modules.PortalModuleBase).ContainerControl.Visible = False
Else
If mUser.IsSuperUser Or mUser.UserID = _portalSettings.AdministratorId.ToString Then
'doe niks
Else
CType(Me.Parent.Parent, DotNetNuke.Entities.Modules.PortalModuleBase).ContainerControl.Visible = False
End If
End If
End Sub
End Class
helper.vb module
Imports DotNetNuke
Imports DotNetNuke.Entities.Portals
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Module Helper
Public Function DisplayError(ByVal Message As String) As ArrayList
Dim strerror As String = ""
Dim blnAdmin As Boolean = False
Dim ArlError As New ArrayList
Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)
Dim mUser As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo
If mUser.UserID < 1 Then
'User Not Logged In
strerror = "error for non logged in user
Else
If mUser.IsSuperUser Or mUser.UserID = _portalSettings.AdministratorId.ToString Then
'admin or host so general error and explanation
strerror = Message
blnAdmin = True
Else
'normal user so a general error
strerror = "error for normal user"
End If
End If
ArlError.Add(strerror)
ArlError.Add(blnAdmin)
Return ArlError
End Function
End Module
thats it the basic setuop I use for everythig. One tab has about 15 modules on it and based if there is data or not only the ones that have actual content are shown. So you need to check in your code if there is data returned and if not you call
checkvisible()
Another point to take into notice if that ( at least for the version of the xepient mdoule now ) is that sometimes it blows on cast errors generated by the public properties.
to overcome this make all your public properties strings and then cast them to the type you need. Thsi way if its filled in incorrectly your try/catch will catch the error so it wont blowup your portal
ctype(myproperty, integer)
This should get you started using this module have fun