Copied to clipboard

Flag this post as spam?

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


  • Carlos Gómez 25 posts 55 karma points
    Feb 28, 2015 @ 06:54
    Carlos Gómez
    0

    Macro parameter in a RTE macro

    Hello...

    I created a partial view macro for a contact form that requires a parameter to choose what e-mail address will be the recipient of the info.  If the parameter says "A" will go to [email protected], if the parameter says "B", it will go to [email protected]

    I made a Model for this with its Surface Controller.  The partial view's first line is :

    @model IIDH.Models.ContactFormViewModel 

    And the parameter is "CountriID" which is a textstring that is completed with the "A" or "B" once it is used in the RTE.

    The problem I have is that I am not able to read the parameter in the cshtml Partial, since it is not inheriting from Umbraco.Web.Macros.PartialViewMacroPage

    How could I read that parameter?  I will use a HTML.Hidden to send it to the Surface Controller, but first I need to assign the hidden field with the Parameter value entered in the RTE.

    Thanks for your help.  

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 28, 2015 @ 07:10
    Jan Skovgaard
    0

    Hi Carlos

    How have you tried reading the parameter? What code did you use?

    /Jan

  • Carlos Gómez 25 posts 55 karma points
    Feb 28, 2015 @ 17:53
    Carlos Gómez
    0

    Hello Jan....

    It just doesn't allow me to compile when I use @Model.MacroParameters["CountryID"]...  @Parameter.CountryID... 

    In another form that I am using for a Photo Gallery, doesn't need a Model, so it is inhereted from Umbraco.Web.Macros.PartialViewMacroPage, and there I do have access to the Model.MacroParameters collection, but I can not inherit from Umbraco.Web.Macros.PartialViewMacroPage at the same time as using a Model because it shows this error: "The 'inherits' keyword is not allowed when a 'model' keyword is used."

    Getting back to what I did:

    This is how it appears in the code of the RTE:

    <div class="umb-macro-holder mceNonEditable"><!-- <?UMBRACO_MACRO macroAlias="ContactForm" CountryID="CR" /> --> <ins>Macro alias: <strong>ContactForm</strong></ins></div>

    And the Partial:

    @model IIDH.Models.ContactFormViewModel 

    <div class="cform" id="contact-form">

    @if(TempData["success"]==null)

    {

    using(Html.BeginUmbracoForm<IIDH.Controllers.ContactFormSurfaceController>("HandleFormSubmit")){

            @Html.Hidden("CountryID","CR")       <=== This is what I want to do with the input parameter value entered in backoffice in the RTE

     

        <div class="form-group">

        <label for="name">Nombre completo o nombre de la organización:</label>

        @Html.TextBoxFor(m => m.Name, new { @class = "form-control", placeholder = "Nombre completo o de la organización" })

        @Html.ValidationMessageFor(m => m.Name)

        <br />

        </div>

    etc. etc. etc.

     

     

  • Carlos Gómez 25 posts 55 karma points
    Mar 01, 2015 @ 19:34
    Carlos Gómez
    0

    Friends...  Any idea what I am doing wrong or how to get that parameter value?

Please Sign in or register to post replies

Write your reply to:

Draft