Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • René 327 posts 852 karma points
    May 09, 2012 @ 10:45
    René
    0

    Error loading MacroEngine script (file: NewsletterSubscribe.cshtml)

    Hi (Tanks for this nice project)

    • Umbraco version: umbraco v 4.7.2
    • Db: MsSql 2008

    I have this small issue, any ideas..

    Just used the razor template for the frontend subscription.

    I get this error when trying to submit to newsletter.

    Error loading MacroEngine script (file: NewsletterSubscribe.cshtml)
    
    Error Loading Razor Script (file: Newsletter Subscribe) Dit not provide a valid name    at NewsletterStudio.Api.Subscribe(String email, String name, Int32 subscriptionId)
      at NewsletterStudio.Api.Subscribe(String email, Int32 subscriptionId)
      at ASP._Page_macroScripts_NewsletterSubscribe_cshtml.Execute() in d:\web\localuser\son-smykket.dk\public_html\macroScripts\NewsletterSubscribe.cshtml:line 19
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
      at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
      at System.Web.WebPages.WebPage.ExecutePageHierarchy()
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
      at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
      at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @{
        bool showThankYou false;
        string Error "";
        
        if (Request.Form["action"!= null &Request.Form["action"].ToString(== "subscribe" &Request.Form["txtEmail"].ToString(!= "")
        {
            String txtEmail Request.Form["txtEmail"].ToString();
            
            if (NewsletterStudio.Api.IsValidEmail(txtEmail))
            {
                // Trying to get the subscriptionId from Macro-parameter.
                Int32 subscriptionId (Parameter.SubscriptionId != nullConvert.ToInt32(Parameter.SubscriptionId0;

                // Adding subsbriber
                var success (subscriptionId != 0NewsletterStudio.Api.Subscribe(txtEmailsubscriptionIdNewsletterStudio.Api.Subscribe(txtEmail);
                    
                showThankYou true;
            }
            else
            
                Error "* Det er ikke en korrekt e-mail";
            }
        }
    }

    <div class="newsletter">

    @if (!showThankYou)
    {       
         <div class="newsletter-form">
            <form method="post" action="@Request.Url">
                <input type="hidden" name="action" value="subscribe" />
                <label for="txtEmail">E-mail<span style="color:Red">@Error</span></label>
                <input type="text" name="txtEmail" id="txtEmail" class="txt" size="12" />
                <input type="submit" id="btnSubmit" value="Tilmeld" class="btn" />
            </form>
        </div>
    }
    else

         <div id="newsletter-thankyou">
            <p>Tak for tilmelding</p>
        </div>
    }
    </div>
  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    May 09, 2012 @ 17:13
    Markus Johansson
    0

    Hi!

    Seams like you found a bug here!

    I'll put this in the backlog for the next version (comming soon)! Basicly I would change this row:
    var success = (subscriptionId != 0) ? NewsletterStudio.Api.Subscribe(txtEmail, subscriptionId) : NewsletterStudio.Api.Subscribe(txtEmail);

    TO:

    var success = (subscriptionId != 0) ? NewsletterStudio.Api.Subscribe(txtEmail, Common.UppercaseFirst(email.Substring(0, email.IndexOf("@")).Replace(".", " ")), subscriptionId) : NewsletterStudio.Api.Subscribe(txtEmail);

    This is to use another method in the api that creates the new subscriber. Does this work?

    Of topic: Did you install Newsletter Studio in v4.7.2 without any problems? How was the experiance?

  • René 327 posts 852 karma points
    May 09, 2012 @ 18:39
    René
    0

    HI

    Sorry, it did not work, i get this error. 

    Error occured

    d:\web\localuser\son-smykket.dk\public_html\macroScripts\634721852133382143_NewsletterSubscribe.cshtml(20): error CS0103: The name 'Common' does not exist in the current context

     

    Of topic: i did install in v 4.7.2 without any problems, and the expirence was fine. 

    Later today im going to test it, (If i get to work) :-)

    Tanks 

    René

  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    May 09, 2012 @ 23:42
    Markus Johansson
    0

    Hi!

    You may need to add a using statement to include the common-class, it in the "NewsletterStudio"-namespace. Just add something like:

    @using NewsletterStudio

    At the top of you macro.

  • René 327 posts 852 karma points
    May 10, 2012 @ 07:22
    René
    0

    HI

    Solved, tanks

    I had to add: @using NewsletterStudio at the top

    And change this:  "email.Substring(0, email.IndexOf" to this   "txtEmail.Substring(0txtEmail.IndexOf"

    Here is the string as i used, this is working

    var success (subscriptionId != 0NewsletterStudio.Api.Subscribe(txtEmailCommon.UppercaseFirst
    (txtEmail.Substring(0txtEmail.IndexOf("@")).Replace("."" "))subscriptionId
    NewsletterStudio.Api.Subscribe(txtEmail);

    Have a nice day

  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    May 10, 2012 @ 08:02
    Markus Johansson
    0

    Hi!

    Thank you very much for sharing your solution!

Please Sign in or register to post replies

Write your reply to:

Draft