Copied to clipboard

Flag this post as spam?

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


  • AsheM 9 posts 89 karma points
    1 week ago
    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 1024 posts 6755 karma points MVP 4x c-trib
    1 week ago
    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 9 posts 89 karma points
    1 week ago
    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