コード例 #1
0
    protected void fv_pxy_vld_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        JsAdapter       ja = new JsAdapter();
        ProxyValidation pv = new ProxyValidation();

        if (Session["currentPV"] != null)
        {
            pv = (ProxyValidation)Session["currentPV"];
        }
        if (string.IsNullOrEmpty(pv.ValidationName))
        {
            e.Cancel = true;
            ja.ajaxAlert("缺少有效的代理配置", this);
        }
    }
コード例 #2
0
    protected void btn_test_Click(object sender, EventArgs e)
    {
        JsAdapter ja = new JsAdapter();

        try
        {
            string name    = ((TextBox)fv_pxy_vld.FindControl("vld_name")).Text;
            string url     = ((TextBox)fv_pxy_vld.FindControl("vld_url")).Text;
            string method  = ((TextBox)fv_pxy_vld.FindControl("vld_request_method")).Text;
            string regex   = ((TextBox)fv_pxy_vld.FindControl("vld_pass_regex")).Text;
            int    timeout = int.Parse(((TextBox)fv_pxy_vld.FindControl("vld_timeout")).Text);
            int    attemps = int.Parse(((TextBox)fv_pxy_vld.FindControl("vld_attemps")).Text);
            int    status  = int.Parse(((TextBox)fv_pxy_vld.FindControl("vld_status")).Text);

            pVld = new ProxyValidation(name, url, method, regex, timeout, attemps, status, DateTime.Now);

            if (pVld.validateProxyServer())
            {
                ((Button)fv_pxy_vld.FindControl("btn_save")).Enabled = true;
                ja.ajaxAlert("测试成功", this);
            }
            else
            {
                ((Button)fv_pxy_vld.FindControl("btn_save")).Enabled = false;
                ja.ajaxAlert("测试失败,请检查配置", this);
            }
        }
        catch (Exception ex)
        {
            ja.ajaxAlert(ex.Message, this);
        }
        finally {
            if (fv_pxy_vld.CurrentMode == FormViewMode.Edit)
            {
                nav_1.Attributes.Add("class", "active");
                nav_2.Attributes.Remove("class");
            }
            if (fv_pxy_vld.CurrentMode == FormViewMode.Insert)
            {
                nav_2.Attributes.Add("class", "active");
                nav_1.Attributes.Remove("class");
            }
        }
    }