protected void Property_Click(object sender, EventArgs e)
        {
            PropertyTableAzure prop = new PropertyTableAzure();
            prop.StreetNumber = txtStreetnumber.Text;
            prop.StreetName = txtStreetname.Text;
            prop.Municipality = txtUnitName.Text;
            prop.Suburb = txtSuburb.Text;
            prop.City = txtCity.Text;
            prop.Province = ddlProvince.SelectedValue;
            prop.Country = txtCountry.Text;
            prop.Added = DateTime.Now;
            prop.UserName = FederationForms;
            prop.WebReference = hdfWebrefence.Value;
            prop.Longitude = "";
            prop.Latitude = "";
            prop.PropertyType = "";

            prop.UnitNumber = txtUnitNumber.Text;

            //prop.UniqueNumberUser = Guid.NewGuid();
            if (ddlPropertyType.SelectedValue != "Select")
            {
                prop.PropertyType = ddlPropertyType.SelectedValue;
            }
            string UserId;
            if (!string.IsNullOrEmpty(hdfUserID.Value))
            {
                Session["UserID"] = hdfUserID.Value;
                prop.UserID = Convert.ToString(hdfUserID.Value);
            }
            else if (Session["UserID"] != null)
            {
                UserId = (string)Session["UserID"];
                prop.UserID = UserId;
            }

            else
            {
                //Keys keys = Search.GetID(FederationForms);
                //prop.UserID = keys.UserID;
                //Session["UserID"] = keys.UserID;
            }
            Guid propID = Search.AddProperty(prop, hdfPropertyID.Value);
            Session["propID"] = Convert.ToString(propID);
            //Check if the currently login guy is an agent

            PropertyIDFromDataBase.Value = Convert.ToString(propID);
            try
            {
                if (string.IsNullOrEmpty(hdfLatitude.Value) && string.IsNullOrEmpty(hdfLongitude.Value))
                {
                    address = txtStreetnumber.Text + "+" + txtStreetname.Text + "+" + txtSuburb.Text + "+" + ddlProvince.SelectedValue + "+" + txtCity.Text + "+" + "za";
                    WebRequest request = WebRequest.Create("http://maps.googleapis.com/maps/api/geocode/json?address=" + address + " &sensor=false");
                    WebResponse response = request.GetResponse();
                    Stream stream = response.GetResponseStream();
                    DataContractJsonSerializer seriler = new DataContractJsonSerializer(typeof(AddressResponse));
                    AddressResponse resp = (AddressResponse)seriler.ReadObject(stream);

                    if (resp.Results.Count() > 0)
                    {
                        prop.Latitude = resp.Results[0].Geometry.Location.Lat;
                        prop.Longitude = resp.Results[0].Geometry.Location.Lng;

                        hdfLatitude.Value = prop.Latitude;
                        hdfLongitude.Value = prop.Longitude;
                        map.Visible = true;
                        divPropertyDetailsFields.Visible = false;
                    }
                }
                else
                {
                    divPropertyDetailsFields.Visible = false;
                    map.Visible = true;
                    //imap.Attributes.Add("src", "/Members/maps/uploadMap.aspx?propertyid=" + propID + "&lat=" + hdfLatitude.Value + "&lng=" + hdfLongitude.Value);
                }
            }
            catch
            {

            }

            //this.Page.RegisterStartupScript("OnMap", "<script>getMap()</script>");
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Map", "<script type='text/javascript'>getMap()</script>", false);

            LoadSelectedState(3);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                HtmlMeta htmlmeta = new HtmlMeta();
                htmlmeta.Name = "Keywords";
                htmlmeta.Content = "Property in South africa,property South africa,real estate in kanya,South african real estate,real estate agent in South africa,proprty listing site in South africa,plots for sale,most popular property site in South africa";
                Page.Header.Controls.Add(htmlmeta);

                HtmlMeta htmlmeta2 = new HtmlMeta();
                htmlmeta2.Name = "keywords2";

                if (Request.QueryString["PropertyID"] != null)
                {

                    string propertyid = Convert.ToString(Request.QueryString["PropertyID"]);

                    property = Search.GetPropertyTableFromCache(Guid.Parse(propertyid));

                    int? views = Search.UpdateViewNum(Guid.Parse(propertyid));
                    lblNumberOfTimes.Text = Convert.ToString(views);
                    lblWebReference.Text = property.WebReference;
                    if (property.ImageUrlAzures.Count > 0)
                    {
                        RadRotator1.DataSource = property.ImageUrlAzures;
                        RadRotator1.DataBind();
                        listviewDetails.DataSource = property.ImageUrlAzures;
                        listviewDetails.DataBind();
                        //ImageUrlAzure imgthumb = list[0];
                        imgPropThumb.ImageUrl = property.ImageUrlAzures[0].thumbnailblob;
                        imgPropThumb.Visible = true;
                    }
                    else
                    {
                        RadRotator1.Visible = false;
                        imgNoImage.Visible = true;
                        imgNoImage.ImageUrl = "~/Images/images_propertysearch.jpg";
                        imgPropThumb.ImageUrl = "~/Images/images_propertysearch.jpg";
                    }

                    //estate details
                    if (property.EstateAgentAzure != null)
                    {
                        EstateAg.Visible = true;

                        if (!string.IsNullOrWhiteSpace(property.EstateAgentAzure.ProfilePhotoUrl))
                        {
                            hypImage.ImageUrl = property.EstateAgentAzure.ProfilePhotoUrl;
                            imgAgentThumb.ImageUrl = property.EstateAgentAzure.ProfilePhotoUrl;
                        }
                        else
                        {
                            hypImage.ImageUrl = "~/Images/images_propertysearch.jpg";
                            imgAgentThumb.ImageUrl = "~/Images/images_propertysearch.jpg";
                        }
                        lblBusinessName.Text = property.EstateAgentAzure.BusinessName;
                        lblAddress.Text = property.EstateAgentAzure.AgentAddress;
                        lblCityEstate.Text = property.EstateAgentAzure.City;
                        lblestatePhone.Text = property.UsersTableAzure.WorkPhone;

                        lblAgentCity.Text = property.EstateAgentAzure.City;
                        lblAgentPhoneNumber.Text = property.UsersTableAzure.WorkPhone;
                        lblAgentPostalCode.Text = property.EstateAgentAzure.PostalCode;
                        lblAgentBusiness.Text = property.EstateAgentAzure.BusinessName;
                        lblAgentRoad.Text = property.EstateAgentAzure.Road;
                        lblAgentState.Text = property.EstateAgentAzure.State_Prov;
                    }
                    else
                    {
                        EstateAg.Visible = false;
                        imgAgentThumb.Visible = false;
                    }

                    //Property details
                    if (property.AttributeTableAzure != null)
                    {
                        GetFeatures(property.AttributeTableAzure);
                    }
                    if (property.PriceTableAzure != null)
                    {
                        lblPrice.Text = "R " + Convert.ToString(property.PriceTableAzure.MonthlyRental);
                        lblPrice2.Text = "R " + Convert.ToString(property.PriceTableAzure.MonthlyRental);
                        lblDescription.Text = Convert.ToString(property.PriceTableAzure.Description);
                        lblPriceDialog.Text = Convert.ToString(property.PriceTableAzure.MonthlyRental);
                    }
                    //lblCity.Text = property.City;
                    // lblUnitNumber.Text = property.UnitNumber;
                    //lblRoad.Text = property.StreetName;
                    lblSuburb.Text = CheckContainHomeType(property.PriceTableAzure.Attributes) + " " + property.PropertyType + "<br/>" + property.UnitNumber + " " + property.Municipality + " <br/>" + property.StreetNumber + " " + property.StreetName + ",<b/>" + property.Suburb + " " + property.City;
                    sellmetaTag = lblSuburb.Text;
                    lblDetails.Text = CheckContainHomeType(property.PriceTableAzure.Attributes) + " " + property.PropertyType + "<br/>" + property.UnitNumber + " " + property.Municipality + " " + property.StreetNumber + " " + property.StreetName + ",<b/>" + property.Suburb + " " + property.City + " " + property.Province;
                    lblPropertyType1.Text = CheckContainHomeType(property.PriceTableAzure.Attributes) + " " + property.PropertyType;
                    lblAddress2.Text = property.StreetName + " " + property.Suburb + " " + property.City;
                    lblCityDialog.Text = property.City;

                    lblRoadDialog.Text = property.StreetName;
                    lblSurburbDialog.Text = property.Suburb;
                    // lblPropertyType.Text = property.PropertyType;
                    UnitNumberDialog.Text = property.UnitNumber;
                    lblStateDialog.Text = property.Province;

                    hyperFriend.Attributes.Add("OnClick", "SubmitClientDetails('" + divFriend.ClientID + "')");
                    hyperView.Attributes.Add("OnClick", "SubmitClientDetails('" + divContact.ClientID + "')");
                    HyperArrangeView2.Attributes.Add("OnClick", "SubmitClientDetails('" + divContact.ClientID + "')");
                    btnContactAgent.Attributes.Add("OnClick", "SubmitClientDetails('" + divContact.ClientID + "')");
                    Hidecontent.Attributes.Add("onClick", "Hide('" + divContact.ClientID + "')");
                    //set up the client ids for the friends form
                    string clientfriendids = txtYourName.ClientID + ";" + txtyouremailaddress.ClientID + ";" + txtfirstfriendsname.ClientID + ";" + txtfirstfriendsemail.ClientID + ";" + txtsecondfriendname.ClientID + ";" + txtsecondfriendemail.ClientID + ";" + txtComment.ClientID + ";" + propertyid;
                    hypSendMailFriend.Attributes.Add("OnClick", "SubmitEmailsFriends('" + clientfriendids + "')");
                    hidedivFriend.Attributes.Add("OnClick", "Hide('" + divFriend.ClientID + "')");
                    //set up the ids for the contact us form
                    string clientid = divContact.ClientID + ";" + txtName.ClientID + ";" + txtPhone.ClientID + ";" + txtEmail.ClientID + ";" + txtMessage.ClientID + ";" + propertyid + ";" + property.UserID;

                    hyperSendEmail.Attributes.Add("OnClick", "SubmitClientPersonalDetails('" + clientid + "')");

                    //imap.Attributes.Add("src", "/Public/maps/uploadMap.aspx?lat=" + property.Latitude + "&lng=" + property.Longtitude);
                    imap.Attributes.Add("src", "/Public/Map/Map.aspx?lat=" + property.Latitude + "&lng=" + property.Longitude);
                    LoadNearPlace();
                    Page.Title = lblPropertyBed.Text + "  in  " + lblSuburb.Text + " ," + property.City;
                    htmlmeta2.Content = sellmetaTag;
                    Page.Header.Controls.Add(htmlmeta2);
                }
            }
        }