Search by Zip

@functions {

    protected int radius;
    
    public override void InitializePage() {
        base.InitializePage();     
        
        if (String.IsNullOrEmpty(Request.QueryString["radius"]) || !int.TryParse(Request.QueryString["radius"], out radius)) {
            radius = 1;
        }
        
    }
}

<div>
    <form method="get" action="thispage">
        <p><input type="text" name="zip" value="@Request.QueryString["zip"]" placeholder="and/or enter zip code" /></p>
        <p>
            <select name="radius" class="form-control">
                @foreach(int i in new int[] {1,5,10,25,50,100}) {
                    <option value="@i" selected="@(i == radius ? "selected" : "")">@i miles</option>
                }
            </select>
        </p>
        <p>
            <button class="btn btn-default" type="submit">Search</button>
        </p>
    </form>
</div>

@if(!String.IsNullOrEmpty(Request.QueryString["search"]) || !String.IsNullOrEmpty(Request.QueryString["zip"])){
@BRT.Index(tableId:"Contacts",viewId:"PUTINYOURVIEWID",pageSize:50,fields: new[] {"Name","PhysCity"}, 
condition: (String.IsNullOrEmpty(Request.QueryString["zip"]) ? null : ConditionMeta.Parse("<Distance FieldId=\"PhysZip\" Zip=\"" + Request.QueryString["zip"] + "\" Radius=\"" + radius.ToString() + "\"/>")),
itemTemplate:
@<div>
    <h4><a href="/whateverdetail/@item.Href"><b>@item["Name"].ToString() - @item["PhysCity"]</b></a></h4>
    <hr/>
</div>)

}