Basic Resource Question - Could not load type 'NopSolutions.NopCommerce.Web.Modules.RequestTrialCont

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 年 前
I am adding a form to a fairly standard 1.6 install and am getting a parser error, shown below.

Begin Error:
  Parser Error
  Description: An error occurred during the parsing of a resource required to service this request. Please review the   following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'NopSolutions.NopCommerce.Web.Modules.RequestTrialControl'.

Source Error:


Line 1:  <%@ Control Language="C#" AutoEventWireup="true" Inherits="NopSolutions.NopCommerce.Web.Modules.RequestTrialControl"
Line 2:      CodeBehind="RequestTrial.ascx.cs" %>
Line 3:  <%@ Register TagPrefix="nopCommerce" TagName="SimpleTextBox" Src="~/Modules/SimpleTextBox.ascx" %>


Source File: /Modules/RequestTrial.ascx    Line: 1

End Error


The code from the C# file is listed below.

namespace NopSolutions.NopCommerce.Web.Modules
{
    public partial class RequestTrialControl : BaseNopUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                BindData();
        }

        protected void BindData()
        {
            if (NopContext.Current.User != null && !NopContext.Current.User.IsGuest)
            {
                txtFullName.Text = NopContext.Current.User.FullName;
                txtEmail.Text = NopContext.Current.User.Email;
            }
        }

        protected void btnRequestTrial_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    if (String.IsNullOrEmpty(txtEnquiry.Text))
                        return;
                    string email = txtEmail.Text.Trim();
                    string fullName = txtFullName.Text.Trim();
                    string subject = string.Format("{0}. {1}", SettingManager.StoreName, "Contact us");
                    string body = MessageManager.FormatContactUsFormText(txtEnquiry.Text);

                    var from = new MailAddress(email, fullName);

                    //required for some SMTP servers
                    if (SettingManager.GetSettingValueBoolean("Email.UseSystemEmailForRequestTrialForm"))
                    {
                        from = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);
                        body = string.Format("<b>From</b>: {0} - {1}<br /><br />{2}", Server.HtmlEncode(fullName), Server.HtmlEncode(email), body);
                    }
                    var to = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);
                    MessageManager.InsertQueuedEmail(5, from, to, string.Empty, string.Empty, subject, body, DateTime.Now, 0, null);

                    pnlResult.Visible = true;
                    pnlRequestTrial.Visible = false;
                }
                catch (Exception exc)
                {
                    LogManager.InsertLog(LogTypeEnum.MailError, string.Format("Error sending \"Contact us\" email."), exc);
                }
            }
        }
    }
}
13 年 前
Have you recompiled the solution after adding the control? If so, try to clean the solution and then build it. Are there any errors that prevent the compile from completing?

.
13 年 前
Got, it - thanks.

I neglected to move one of the recompiled libs to the server.

One additional question - The page loads but does not use the theme the rest of the site is using,   Where is this controlled at the page level?

Jack
13 年 前
on the .aspx page for this form, have you linked to a masterpage ?
13 年 前
It does link to the standard master page: ~/MasterPages/TwoColumns.master

It is the same as the rest of my pages - that is what is so confusing.

I must be missing something here....

Jack
13 年 前
jackb86 wrote:
Got, it - thanks.

I neglected to move one of the recompiled libs to the server.

One additional question - The page loads but does not use the theme the rest of the site is using,   Where is this controlled at the page level?

Jack


The aspx page that displays the control needs to inherit from BaseNopPage instead of Page as this parent class is where the selected theme is set (BaseNopPage extends Page).

For example, if your aspx page is named RequestTrial.aspx, then in RequestTrial.aspx.cs, declare the class as follows:

public partial class RequestTrial : BaseNopPage


.
13 年 前
That is what I have, see below.

namespace NopSolutions.NopCommerce.Web
{
    public partial class RequestTrialPage : BaseNopPage
    {
       protected void Page_Load(object sender, EventArgs e)
          {
              string title = GetLocaleResourceString("PageTitle.RequestTrial");
              SEOHelper.RenderTitle(this, title, true);
          }
    }
}
13 年 前
jackb86 wrote:
That is what I have, see below.

namespace NopSolutions.NopCommerce.Web
{
    public partial class RequestTrialPage : BaseNopPage
    {
       protected void Page_Load(object sender, EventArgs e)
          {
              string title = GetLocaleResourceString("PageTitle.RequestTrial");
              SEOHelper.RenderTitle(this, title, true);
          }
    }
}


The site theme (selected in Administration) is set in the BaseNopPage class OnPreInit event (file Controls\BaseNopPage.cs at line 131). Have you posted the full source (except for using directives) for the aspx.cs page or are you implementing the OnPreInit event without calling the base class event? If you are overriding the event, add base.OnPreInit(e); to the event so that the theme can be set for the page. If this event is not called then the theme defined in web.config (DarkOrange) will be used for the page.

Since you said your theme works for every other page on your site, have you tried running the site in the debugger to see what is being set for the theme for this page (Page.Theme variable). Are you trying to set the theme for the page via a Page attribute in the aspx file?

Can you post the full source code for the aspx page and codebehind or send via PM if you don't want to post it here?

.
13 年 前
What I did is take a copy of the contactUs page and update it to refelect the new name, no real new code.   See below.


RequestTrail.aspx.cs
//------------------------------------------------------------------------------
// The contents of this file are subject to the nopCommerce Public License Version 1.0 ("License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at  https://www.nopcommerce.com/License.aspx.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
// See the License for the specific language governing rights and limitations under the License.
//
// The Original Code is nopCommerce.
// The Initial Developer of the Original Code is NopSolutions.
// All Rights Reserved.
//
// Contributor(s): _______.
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Caching;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.Localization;
using NopSolutions.NopCommerce.BusinessLogic.Payment;
using NopSolutions.NopCommerce.BusinessLogic.SEO;
using NopSolutions.NopCommerce.Common.Utils;
namespace NopSolutions.NopCommerce.Web
{
    public partial class RequestTrialPage : BaseNopPage
    {
       protected void Page_Load(object sender, EventArgs e)
          {
              string title = GetLocaleResourceString("PageTitle.RequestTrial");
              SEOHelper.RenderTitle(this, title, true);
          }
    }
}



RequestTrail.aspx
<%@ Page Language="C#" MasterPageFile="~/MasterPages/TwoColumn.master" AutoEventWireup="true"
    Inherits="NopSolutions.NopCommerce.Web.RequestTrialPage" Codebehind="RequestTrial.aspx.cs"   ValidateRequest="false" %>
    
<%@ Register TagPrefix="nopCommerce" TagName="RequestTrial" Src="~/Modules/RequestTrial.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="Server">
    <nopCommerce:RequestTrial ID="ctrlRequestTrial" runat="server" />
</asp:Content>


Thanks for you help,

Jack
13 年 前
I tried the code and the control you posted and it uses the theme that is the same as the rest of the site (not using the default theme). Are there any errors? Have you run the site in the debugger?

.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.