Check for http:// in front of URL

If you are looping through records and you want to see if the Link field starts with http://

@*------- begin code---------------------------
@{
    string thelink="";
    string ls="";
    string le="</a>";
    
    if(!item.IsDBNull("Link")){
        thelink = item.GetString("Link");
        if(!thelink.StartsWith("http://") && !thelink.StartsWith("https://")){
            thelink = "http://" + thelink;
        }
        ls = "<a href=\"" + thelink + "\" target=\"_blank\">";    
    }
    else{
        ls = "<a href=\"/post/" + item.Href + "\">";
    }
}
@if (item.GetFiles("PrimaryImage").Count>0) {
    <div class="mb-1">
        @BRT.Raw(ls)
        <img src="@item.GetFiles("PrimaryImage")[0].Url?width=316&height=110&mode=crop" />
        @BRT.Raw(le)
    </div>
} 
<div>
    @BRT.Raw(ls)
    <b>@item.GetString("Title")</b>
    @BRT.Raw(le)
</div>
end code--------------------------*@