Copied to clipboard

Flag this post as spam?

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


  • Tony Painter 2 posts 72 karma points
    Sep 23, 2016 @ 15:16
    Tony Painter
    0

    How can I make text hyperlink in cshtml script

    Hi there

    i have the following script;

    @using VC.usercontrols;
    
    @{
      string locations = @Locations.GetJSON();
      string divClass = (@Model.Id == 3437) ? "map" : "funding";
    }
    
    
    
    <div class="@divClass">
      <h4>Apply for funding</h4>
      <p>To find out if you are eligible for funding please enter your postcode into the search.  If applying for funding in Scotland select **here** </p> <br> <br> <br>
      <div class="search">
        <p>Postcode search</p>
        <input type="text" value="Enter postcode" class="searchField location" title="Apply for funding search">
        <input type="text" value="boosh" style="display:none">
        <input value="search" src="/images/button_find.png" class="searchButton locationSearch" type="image" title="Apply for funding search">
    
      </div>
        </div>
    

    Where here is the hyperlink text to a url. Can someone please help?

  • Marc Goodson 2157 posts 14434 karma points MVP 9x c-trib
    Sep 24, 2016 @ 09:53
    Marc Goodson
    0

    Hi Tony

    At this point do you know the Url of the page you plan to link to ?

    eg

    <p>To find out if you are eligible for funding please enter your postcode into the search.  If applying for funding in Scotland select <a href="http://www.fundingscotland.com/eligible">here</a> </p> <br> <br> <br>
    

    or is that url a page somewhere in your Umbraco site and you are wondering how to find it and refer to it in the razor file ?

    Depending on your approach to the structure of the site you could use the Umbraco Helpers here to find the page:

    https://our.umbraco.org/documentation/reference/querying/umbracohelper/

    eg if your funding page had a specific document type alias...

    @{
      string locations = @Locations.GetJSON();
      string divClass = (@Model.Id == 3437) ? "map" : "funding";
    
    var fundingPage = Umbraco.TypedContentSingleAtXPath("//fundingPageAlias");
    var fundingPageUrl = fundingPage.Url;
    
    }
    
    <p>To find out if you are eligible for funding please enter your postcode into the search.  If applying for funding in Scotland select <a href="@fundingPageUrl">here</a> </p> <br> <br> <br>
    

    or if your funding page didn't have a specific document type alias, you could create a property on the homepage of the site called 'funding page' and make this a content picker, and pick the particular page here. Then in your razor file, you could get a reference to the homepage of the site, read the picker property, and get the url of the picked item.

  • Tony Painter 2 posts 72 karma points
    Sep 26, 2016 @ 08:26
    Tony Painter
    0

    Hi Marc Many thanks for this solution. I just used a href="url of page" with the relevant coding as you suggested.

    This has worked well and takes you to a hidden page that would be only accessible if a qualifying postcode was entered in the postcode search.

    tony

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies