Search Results for

    Show / Hide Table of Contents

    Example of simplified buttons with new partial view

    In the previous example we showed how to replace a partial view in the template.

    Another option would have been to create a new view with the new functionality that we need.

    In this example we are going to show a second way to obtain the same results as the ones in example 2 - replace partial view: create a template that only allows to go to the next question independently of the survey configuration.

    Steps

    • As we show in the previous example, Screen.cshtml references the Buttons partial view directly.
        <div id="segment-end">
          @{ Html.RenderPartial("Buttons", Buttons(Model)); }
        </div>
    

    We create a copy of the file and we replace that code with:

        <div id="segment-end">
          @{ Html.RenderPartial("NextButton", Buttons(Model)); }
        </div>
    

    It will stop using _Buttons.cshtml and try to use a _NextButton.cshtml file.

    • As in the previous case, we copy the Buttons content:
    @model IEnumerable<NipoSoftware.Nfield.Interviewing.Contracts.Data.Button>
    <div id="navigation-container">
    @foreach (var button in Model)
    {
        <input type="submit" name="button-@button.Name.ToLowerInvariant()" value="@button.Text" class="button button-@button.Name.ToLowerInvariant()" />
    }
    </div>
    

    Now into a new NextButton file, and we add the same if change:

    @foreach (var button in Model)
    {
        if(button.Name.ToLowerInvariant() == "next"){
            <input ... />
        }
    }
    
    • As in the previous example, we generate a NextOnlyTemplate.zip file with the two views in the root (the modified Screen and the new NextButton) and we update the ODIN script with that template:
    *TEMPLATE "NextOnlyTemplate"
    
    *QUESTION 10 *CODES 61L1
    Do you own a smartphone?
    1:Yes
    2:No
    
    *END
    

    We can verify that it will generate the same output:

    Question with template

    In This Article
    Back to top Generated by DocFX