Copied to clipboard

Flag this post as spam?

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


  • AsheM 19 posts 120 karma points
    Dec 02, 2019 @ 20:56
    AsheM
    0

    Trying to make a document download link

    So I'm trying to make a template that will allow my editors to upload something like a registration form that users can download. I am using the media picker to specify which file should be associated with the download link but I'm having trouble getting the url. I have this code in the Template:

    var typedMediaPickerSingle = Model.Value<IPublishedContent>("registrationForm");
    if (typedMediaPickerSingle != null)
    {
    <p>@typedMediaPickerSingle.Url</p>
        <a href="@typedMediaPickerSingle.Url" >Registration Form</a>
    }
    

    but it errors out: "CS0103: The name 'typedMediaPickerSingle' does not exist in the current context"

    What am I doing wrong here?

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Dec 03, 2019 @ 06:54
    Marc Goodson
    100

    Hi AsheM

    It's just a guess but is your declaration of the variable outside of a code block?

    @{
    var typedMediaPickerSingle = Model.Value<IPublishedContent>("registrationForm");
    }
    @if (typedMediaPickerSingle != null)
    {
    <p>@typedMediaPickerSingle.Url</p>
        <a href="@typedMediaPickerSingle.Url" >Registration Form</a>
    }
    

    does the above make a difference?

    regards

    Marc

  • AsheM 19 posts 120 karma points
    Dec 03, 2019 @ 13:46
    AsheM
    0

    It worked! Thank you I'm new to this and you totally fixed it!

Please Sign in or register to post replies

Write your reply to:

Draft