protected void Page_Load(object sender, EventArgs e)
        {
            Master.HideAllFilters = true;
            if (RequestVars.Get("a", 0) == 1)
            {
                Response.Clear();
                switch (RequestVars.Get("t", 0))
                {
                case 1:                         //Remove
                    int propSurvReaID = RequestVars.Post("p", -1);
                    int userID        = RequestVars.Post("u", -1);
                    int sendType      = RequestVars.Post("s", -1);
                    if (propSurvReaID != -1 && userID != -1 && sendType != -1)
                    {
                        SQLDatabase sql  = new SQLDatabase();    sql.CommandTimeout = 120;
                        int         rows = sql.NonQuery(
                            @"DELETE FROM [tblNotificationUsers] WHERE [PropertySurveyReasonID] = @PropertySurveyReasonID AND [UserID] = @UserID AND [SendType] = @SendType",
                            new SQLParamList().Add("@PropertySurveyReasonID", propSurvReaID)
                            .Add("@UserID", userID)
                            .Add("@SendType", sendType)
                            );
                        if (!sql.HasError)
                        {
                            if (rows != 0)
                            {
                                Response.Write(new JSONBuilder().AddInt("s", 0));
                            }
                            else
                            {
                                Response.Write(new JSONBuilder().AddInt("s", 4).AddString("msg", "No matching records found. Refresh the page to see the most up to date information."));
                            }
                        }
                        else
                        {
                            Response.Write(new JSONBuilder().AddInt("s", 3).AddString("msg", "There was a problem contacting the database. Please try again. (ENM105)"));
                        }
                    }
                    else
                    {
                        Response.Write(new JSONBuilder().AddInt("s", 2).AddString("msg", "Invalid values specified."));
                    }
                    break;

                case 2:                         //Get user list
                    propSurvReaID = RequestVars.Get("p", -1);
                    if (propSurvReaID != -1)
                    {
                        SQLDatabase sql = new SQLDatabase();    sql.CommandTimeout = 120;
                        DataTable   dt  = sql.QueryDataTable(@"
SELECT [UserID],[FirstName],[LastName]
FROM [tblCOM_Users]
WHERE [UserID] NOT IN (SELECT [UserID] FROM [tblNotificationUsers] WHERE [PropertySurveyReasonID] = @PSRID )
	AND [Active] = 1
ORDER BY [FirstName], [LastName]",
                                                             new SqlParameter("@PSRID", propSurvReaID));

                        if (!sql.HasError)
                        {
                            JSONBuilder jb = new JSONBuilder().AddInt("s", 0);
                            jb.AddArray("ubh");
                            foreach (DataRow dr in dt.Rows)
                            {
                                jb.AddObject()
                                .AddInt("i", (int)dr["UserID"])
                                .AddString("n", dr["FirstName"].ToString() + " " + dr["LastName"].ToString())
                                .CloseObject();
                            }
                            jb.CloseArray();
                            Response.Write(jb);
                        }
                        else
                        {
                            Response.Write(new JSONBuilder().AddInt("s", 3).AddString("msg", "There was a problem contacting the database. Please try again. (ENM106)"));
                        }
                    }
                    else
                    {
                        Response.Write(new JSONBuilder().AddInt("s", 2).AddString("msg", "Invalid values specified."));
                    }
                    break;

                default:
                    Response.Write(new JSONBuilder().AddInt("s", 1).AddString("msg", "Invalid type specified."));
                    break;
                }
                Response.End();
                return;
            }

            if (!IsPostBack)
            {
                //Hide reason by default. Can only be shown if Property and Survey are changed.
                ddlReason.Visible = false;
            }
            else
            {
                lblReasonError.Text = String.Empty;
            }
        }