Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

' is not accessible in this context because it is 'Friend'

Posted on 2011-02-10
2
Medium Priority
?
5,767 Views
Last Modified: 2012-05-11
Hi Experts,

Hoping someone can help me on this one.
I am customising a module on DNN, and I have these errors in Visual Studio on the ascx page
- Error      65      'ZLDNN.Modules.myQandA.Settings' is not accessible in this context because it is 'Friend'
- Error      66      'Context' is not a member of 'ASP.settings_ascx'.

Also I am sure due to the ascx page having the above errors on the line <%@ Control Language="vb" AutoEventWireup="true" Inherits="ZLDNN.Modules.myQandA.Settings" Codebehind="Settings.ascx.vb" %> it is not recognising the controls on the page in the codebehind file, which is causing more errors.

Can anyone help me with the above errors which I think will solve all my issues.

Code attached.

Thanks
C
ascx file
 
<%@ Control Language="vb" AutoEventWireup="true" Inherits="ZLDNN.Modules.myQandA.Settings" Codebehind="Settings.ascx.vb" %>
<%@ Import Namespace="DotNetNuke.Services.Exceptions" %>
<%@ Import Namespace="DotNetNuke" %>
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>

<table cellspacing="0" cellpadding="2" border="0" summary="myQandA Settings Design Table">
    <tr>
        <td class="SubHead"  nowrap><dnn:label id="lblQuestionTemplateInList" runat="server"  suffix=":"></dnn:label></td>
        <td valign="bottom" >
            <asp:textbox id="txtQuestionTemplateInList" cssclass="NormalTextBox" width="390" columns="30" textmode="MultiLine" rows="10" maxlength="2000" runat="server" />
        </td>
    </tr>
    
    <tr>
        <td class="SubHead" nowrap><dnn:label id="lblQuestionTemplateInDetailView" runat="server" suffix=":"></dnn:label></td>
        <td valign="bottom" >
            <asp:textbox id="txtQuestionTemplateInDetailView" cssclass="NormalTextBox" width="390" columns="30" textmode="MultiLine" rows="10" maxlength="2000" runat="server" />
        </td>
    </tr>
    
      <tr>
        <td class="SubHead" nowrap><dnn:label id="lblAnswerTemplate" runat="server" suffix=":"></dnn:label></td>
        <td valign="bottom" >
            <asp:textbox id="txtAnswerTemplate" cssclass="NormalTextBox" width="390" columns="30" textmode="MultiLine" rows="10" maxlength="2000" runat="server" />
        </td>
    </tr>
    <tr>
        <td class="SubHead" nowrap><dnn:label id="lblBestAnswerTemplate" runat="server" suffix=":"></dnn:label></td>
        <td valign="bottom" >
            <asp:textbox id="txtBestAnswerTemplate" cssclass="NormalTextBox" width="390" columns="30" textmode="MultiLine" rows="10" maxlength="2000" runat="server" />
        </td>
    </tr>
     <tr>
        <td class="SubHead" nowrap><dnn:label id="lblNewQuestionEmailSubject" runat="server" suffix=":"></dnn:label></td>
        <td valign="bottom" >
            <asp:textbox id="txtNewQuestionEmailSubject" cssclass="NormalTextBox" width="390" columns="30"   runat="server" />
        </td>
    </tr>
      <tr>
        <td class="SubHead" nowrap><dnn:label id="lblNewQuestionEmailNotificationTemplate" runat="server" suffix=":"></dnn:label></td>
        <td valign="bottom" >
            <asp:textbox id="txtNewQuestionEmailNotificationTemplate" cssclass="NormalTextBox" width="390" columns="30" textmode="MultiLine" rows="10" maxlength="2000" runat="server" />
        </td>
    </tr>
     <tr>
        <td class="SubHead" nowrap><dnn:label id="lblAnswerEmailSubject" runat="server" suffix=":"></dnn:label></td>
        <td valign="bottom" >
            <asp:textbox id="txtAnswerEmailSubject" cssclass="NormalTextBox" width="390" columns="30"   runat="server" />
        </td>
    </tr>
      <tr>
        <td class="SubHead" nowrap><dnn:label id="lblAnswerEmailNotificationTemplate" runat="server" suffix=":"></dnn:label></td>
        <td valign="bottom" >
            <asp:textbox id="txtAnswerEmailNotificationTemplate" cssclass="NormalTextBox" width="390" columns="30" textmode="MultiLine" rows="10" maxlength="2000" runat="server" />
        </td>
    </tr>
    <tr>
        <td class="SubHead" ><dnn:label id="lbQuestionEditPage" runat="server"  suffix=":"></dnn:label></td>
        <td valign="bottom" >
             <asp:DropDownList ID="cboQuestionEditPage" runat="server">
        </asp:DropDownList>
        </td>
      
    </tr>
      <tr>
        <td class="SubHead" ><dnn:label id="lbQuestionViewPage" runat="server" suffix=":"></dnn:label></td>
        <td valign="bottom" >
             <asp:DropDownList ID="cboQuestionViewPage" runat="server">
        </asp:DropDownList>
        </td>
      </tr>
    <tr>
        <td class="SubHead" colspan="2">
            <dnn:Label ID="lbAskRoles" runat="server" CssClass="SubHead"></dnn:Label>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <asp:CheckBoxList ID="chkAskRoles" CssClass="Normal" RepeatColumns="5" runat="server">
            </asp:CheckBoxList>
        </td>
    </tr>
     <tr>
        <td class="SubHead" colspan="2">
            <dnn:Label ID="lbAnswerRoles" runat="server" CssClass="SubHead"></dnn:Label>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <asp:CheckBoxList ID="chkAnswerRoles" CssClass="Normal" RepeatColumns="5" runat="server">
            </asp:CheckBoxList>
        </td>
    </tr>
    <tr>
        <td class="SubHead" nowrap>
            <dnn:Label ID="lbPageSize" runat="server" CssClass="SubHead"></dnn:Label>
        </td>
        <td>
            <asp:TextBox ID="txtPageSize" runat="server" Width="126px"></asp:TextBox>
            <asp:RangeValidator ID="RANGEVALIDATOR1" runat="server" ErrorMessage="(1-1000)" MaximumValue="1000"
                MinimumValue="1" Type="Integer" ControlToValidate="txtPageSize"></asp:RangeValidator></td>
    </tr>
    
     <tr>
        <td class="SubHead" nowrap>
            <dnn:Label ID="lbAnswerPageSize" runat="server" CssClass="SubHead"></dnn:Label>
        </td>
        <td>
            <asp:TextBox ID="txtAnswerPageSize" runat="server" Width="126px"></asp:TextBox>
            <asp:RangeValidator ID="RANGEVALIDATOR5" runat="server" ErrorMessage="(1-1000)" MaximumValue="1000"
                MinimumValue="1" Type="Integer" ControlToValidate="txtAnswerPageSize"></asp:RangeValidator></td>
    </tr>
    
      <tr>
        <td class="SubHead" nowrap>
            <dnn:Label ID="lbMaxCategories" runat="server" CssClass="SubHead"></dnn:Label>
        </td>
        <td>
            <asp:TextBox ID="txtMaxCategories" runat="server" Width="126px"></asp:TextBox>
            <asp:RangeValidator ID="RANGEVALIDATOR2" runat="server" ErrorMessage="(1-1000)" MaximumValue="1000"
                MinimumValue="1" Type="Integer" ControlToValidate="txtPageSize"></asp:RangeValidator></td>
    </tr>
    
     <tr>
        <td class="SubHead" nowrap>
            <dnn:Label ID="lbMaxCharacters" runat="server" CssClass="SubHead"></dnn:Label>
        </td>
        <td>
            <asp:TextBox ID="txtMaxCharacters" runat="server" Width="126px"></asp:TextBox>
            <asp:RangeValidator ID="RANGEVALIDATOR3" runat="server" ErrorMessage="(90-500)" MaximumValue="500"
                MinimumValue="90" Type="Integer" ControlToValidate="txtMaxCharacters"></asp:RangeValidator></td>
    </tr>
    
     <tr>
        <td class="SubHead" nowrap>
            <dnn:Label ID="lbMinCharacters" runat="server" CssClass="SubHead"></dnn:Label>
        </td>
        <td>
            <asp:TextBox ID="txtMinCharacters" runat="server" Width="126px"></asp:TextBox>
            <asp:RangeValidator ID="RANGEVALIDATOR4" runat="server" ErrorMessage="(10-90)" MaximumValue="90"
                MinimumValue="10" Type="Integer" ControlToValidate="txtMinCharacters"></asp:RangeValidator></td>
    </tr>
      <tr>
        <td class="SubHead" ><dnn:label id="lbAllowUserSubmitMoreThanOneAnswers" runat="server" suffix=":"></dnn:label></td>
        <td valign="bottom" >
            <asp:CheckBox ID="chkAllowMultiAnswers" runat="server" />
        </td>
      </tr>
      
       <tr  >
        <td class="SubHead" >
            <dnn:Label ID="lbEmailAddress" Suffix=":"  runat="server">
            </dnn:Label>
        </td>
        <td width="365">
           <asp:TextBox ID="txtEmailAddress" runat="server" 
                CssClass="NormalTextBox"></asp:TextBox><asp:RegularExpressionValidator ID="RegularExpressionValidator1"
                    runat="server" ErrorMessage="username@domain" ControlToValidate="txtEmailAddress" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
         </td>
    </tr>
</table>

Open in new window


.vb file
 
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
'

Imports System.Web.UI

Imports DotNetNuke
Imports DotNetNuke.Services.Exceptions

Namespace ZLDNN.Modules.myQandA

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' The Settings class manages Module Settings
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Partial Class Settings
        Inherits Entities.Modules.ModuleSettingsBase

#Region "Base Method Implementations"

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' LoadSettings loads the settings from the Database and displays them
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Overrides Sub LoadSettings()


            Try
                If (Page.IsPostBack = False) Then
                    If CType(ModuleSettings(MySettings.QuestionTemplateInList), String) <> "" Then
                        Me.txtQuestionTemplateInList.Text = CType(ModuleSettings(MySettings.QuestionTemplateInList), String)
                    Else
                        Me.txtQuestionTemplateInList.Text = Localization.GetString("defaultQuestionTemplateInList.Text", pubMod.GetSharedResourceFile)
                    End If

                    If CType(ModuleSettings(MySettings.QuestionTemplateInDetailView), String) <> "" Then
                        Me.txtQuestionTemplateInDetailView.Text = CType(ModuleSettings(MySettings.QuestionTemplateInDetailView), String)
                    Else
                        Me.txtQuestionTemplateInDetailView.Text = Localization.GetString("defaultQuestionTemplateInDetailView.Text", pubMod.GetSharedResourceFile)
                    End If

                    If CType(ModuleSettings(MySettings.AnswerTemplate), String) <> "" Then
                        Me.txtAnswerTemplate.Text = CType(ModuleSettings(MySettings.AnswerTemplate), String)
                    Else
                        Me.txtAnswerTemplate.Text = Localization.GetString("defaultAnswerTemplate.Text", pubMod.GetSharedResourceFile)
                    End If

                    If Me.txtAnswerTemplate.Text.IndexOf("[DELETE]") < 0 And Me.txtAnswerTemplate.Text.IndexOf("[MAKEBEST]") < 0 Then
                        Me.txtAnswerTemplate.Text = Me.txtAnswerTemplate.Text & " [DELETE] [MAKEBEST]"
                    End If

                    If CType(ModuleSettings(MySettings.BestAnswerTemplate), String) <> "" Then
                        Me.txtBestAnswerTemplate.Text = CType(ModuleSettings(MySettings.BestAnswerTemplate), String)
                    Else
                        Me.txtBestAnswerTemplate.Text = Localization.GetString("defaultBestAnswerTemplate.Text", pubMod.GetSharedResourceFile)
                    End If

                    If Me.txtBestAnswerTemplate.Text.IndexOf("[DELETE]") < 0 And Me.txtBestAnswerTemplate.Text.IndexOf("[MAKEBEST]") < 0 Then
                        Me.txtBestAnswerTemplate.Text = Me.txtBestAnswerTemplate.Text & " [DELETE] [MAKEBEST]"
                    End If


                    If CType(ModuleSettings(MySettings.NewQuestionEmailNotificationTemplate), String) <> "" Then
                        Me.txtNewQuestionEmailNotificationTemplate.Text = CType(ModuleSettings(MySettings.NewQuestionEmailNotificationTemplate), String)
                    Else
                        Me.txtNewQuestionEmailNotificationTemplate.Text = Localization.GetString("defaultNewQuestionEmailNotificationTemplate.Text", pubMod.GetSharedResourceFile)
                    End If

                    If CType(ModuleSettings(MySettings.AnswerEmailNotificationTemplate), String) <> "" Then
                        Me.txtAnswerEmailNotificationTemplate.Text = CType(ModuleSettings(MySettings.AnswerEmailNotificationTemplate), String)
                    Else
                        Me.txtAnswerEmailNotificationTemplate.Text = Localization.GetString("defaultAnswerEmailNotificationTemplate.Text", pubMod.GetSharedResourceFile)
                    End If

                    If CType(ModuleSettings(MySettings.NewQuestionEmailNotificationSubject), String) <> "" Then
                        Me.txtNewQuestionEmailSubject.Text = CType(ModuleSettings(MySettings.NewQuestionEmailNotificationSubject), String)
                    Else
                        Me.txtNewQuestionEmailSubject.Text = Localization.GetString("defaultNewQuestionEmailNotificationSubject.Text", pubMod.GetSharedResourceFile)
                    End If

                    If CType(ModuleSettings(MySettings.AnswerEmailNotificationSubject), String) <> "" Then
                        Me.txtAnswerEmailSubject.Text = CType(ModuleSettings(MySettings.AnswerEmailNotificationSubject), String)
                    Else
                        Me.txtAnswerEmailSubject.Text = Localization.GetString("defaultAnswerEmailNotificationSubject.Text", pubMod.GetSharedResourceFile)
                    End If

                    pubMod.BindViewTabs(PortalId, Me.cboQuestionEditPage)
                    SetSelection(Settings, MySettings.AskQuestionTab, Me.cboQuestionEditPage)
                    pubMod.BindViewTabs(PortalId, Me.cboQuestionViewPage, "Desktopmodules/myQandA/ViewQuestion.ascx")
                    SetSelection(Settings, MySettings.ViewQuestionTab, Me.cboQuestionViewPage)
                    txtPageSize.Text = CType(Settings(MySettings.PageSize), String)
                    InitRole(CType(Settings(MySettings.AskRoles), String), Me.chkAskRoles, PortalId, False)
                    InitRole(CType(Settings(MySettings.AnswerRoles), String), Me.chkAnswerRoles, PortalId, False)
                    If CType(ModuleSettings(MySettings.MaxCategories), String) <> "" Then
                        Me.txtMaxCategories.Text = CType(ModuleSettings(MySettings.MaxCategories), String)
                    Else
                        Me.txtMaxCategories.Text = "4"
                    End If

                    If CType(ModuleSettings(MySettings.MaxCharacters), String) <> "" Then
                        Me.txtMaxCharacters.Text = CType(ModuleSettings(MySettings.MaxCharacters), String)
                    Else
                        Me.txtMaxCharacters.Text = "120"
                    End If

                    If CType(ModuleSettings(MySettings.MinCharacters), String) <> "" Then
                        Me.txtMinCharacters.Text = CType(ModuleSettings(MySettings.MinCharacters), String)
                    Else
                        Me.txtMinCharacters.Text = "10"
                    End If
                    txtAnswerPageSize.Text = CType(Settings(MySettings.AnswersPageSize), String)

                    SetCheckBox(Settings, MySettings.AllowMultiAnswer, Me.chkAllowMultiAnswers, False)
                    Me.txtEmailAddress.Text = CType(Settings(MySettings.EmailSender), String)
                End If
            Catch exc As Exception           'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' UpdateSettings saves the modified settings to the Database
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public Overrides Sub UpdateSettings()
            Try
                Dim objModules As New Entities.Modules.ModuleController

                objModules.UpdateModuleSetting(ModuleId, MySettings.QuestionTemplateInList, Me.txtQuestionTemplateInList.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.QuestionTemplateInDetailView, Me.txtQuestionTemplateInDetailView.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.BestAnswerTemplate, Me.txtBestAnswerTemplate.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.AnswerTemplate, Me.txtAnswerTemplate.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.AskQuestionTab, Me.cboQuestionEditPage.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.ViewQuestionTab, Me.cboQuestionViewPage.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.AskRoles, pubMod.GetRoleFromControl(Me.chkAskRoles, PortalSettings.AdministratorRoleName.ToString))
                objModules.UpdateModuleSetting(ModuleId, MySettings.PageSize, Me.txtPageSize.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.AnswerRoles, pubMod.GetRoleFromControl(Me.chkAnswerRoles, PortalSettings.AdministratorRoleName.ToString))
                objModules.UpdateModuleSetting(ModuleId, MySettings.MaxCategories, Me.txtMaxCategories.Text)

                objModules.UpdateModuleSetting(ModuleId, MySettings.MaxCharacters, Me.txtMaxCharacters.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.MinCharacters, Me.txtMinCharacters.Text)

                objModules.UpdateModuleSetting(ModuleId, MySettings.AnswersPageSize, Me.txtAnswerPageSize.Text)

                objModules.UpdateModuleSetting(ModuleId, MySettings.AllowMultiAnswer, Me.chkAllowMultiAnswers.Checked.ToString)

                objModules.UpdateModuleSetting(ModuleId, MySettings.AnswerEmailNotificationSubject, Me.txtAnswerEmailSubject.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.AnswerEmailNotificationTemplate, Me.txtAnswerEmailNotificationTemplate.Text)

                objModules.UpdateModuleSetting(ModuleId, MySettings.NewQuestionEmailNotificationSubject, Me.txtNewQuestionEmailSubject.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.NewQuestionEmailNotificationTemplate, Me.txtNewQuestionEmailNotificationTemplate.Text)
                objModules.UpdateModuleSetting(ModuleId, MySettings.EmailSender, Me.txtEmailAddress.Text)
            Catch exc As Exception           'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

#End Region

    End Class

End Namespace

Open in new window

0
Comment
Question by:Craig Lambie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1000 total points
ID: 34868520
When you don't put an access modifier on a class, it defaults to "Friend", which is visible only within the same assembly. Try adding the "Public" modifier to your class declaration:
Partial Public Class Settings

Open in new window

0
 
LVL 1

Author Comment

by:Craig Lambie
ID: 34881208
Thanks Kaufmed,
That definitely fixed the issue in the ascx error.

However in a code behind file I still can't access the controls in the ascx file?
Any ideas on why that would be?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question