zoukankan      html  css  js  c++  java
  • C#中后台申明全局变量来判断某一特定值的代码

    i f (CheckData())
            {
                return;
            }
     Boolean flag = false;
            if (rep_item_list.Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(Page, GetType(), "popUp", "alert('产品明细不能为空!');", true);//判断产品明细是否为空
                flag = true;
                return flag;
            }
            else
            {
                for (int i = 0; i < rep_item_list.Rows.Count; i++)
                {
                    if ((((DropDownList)rep_item_list.Rows[i].FindControl("drpImdeGoodsID")).SelectedItem.Value) == "-1")//判断产品名称是否为空
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), "popUp", "alert('请输入第" + (i + 1) + "行产品名称!');", true);
                        ((DropDownList)rep_item_list.Rows[i].FindControl("drpImdeGoodsID")).Focus();
                        flag = true;
                        return flag;
                    }
                    if (((TextBox)rep_item_list.Rows[i].FindControl("txtImdeQuantity")).Text.Trim().Equals(String.Empty))//判断数量是否为空
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), "popUp", "alert('请输入第" + (i + 1) + "行数量!');", true);
                        ((TextBox)rep_item_list.Rows[i].FindControl("txtImdeQuantity")).Focus();
                        flag = true;
                        return flag;
                    }
                    Regex r = new Regex("^[0-9]{1,}$");        //判断是否数字
                    if (!r.IsMatch(((TextBox)rep_item_list.Rows[i].FindControl("txtImdeQuantity")).Text))      //txtImdeQuantity.Text 这个是要判断的值
                    {
                        ScriptManager.RegisterStartupScript(Page, GetType(), "popUp", "alert('数量必须为数字!');", true);
                        ((TextBox)rep_item_list.Rows[i].FindControl("txtImdeQuantity")).Focus();
                        ((TextBox)rep_item_list.Rows[i].FindControl("txtImdeQuantity")).Text = "";
                        flag = true;
                        return flag;
                    }
                }
                return flag;
            }
  • 相关阅读:
    this.$route和this.$router的区别
    HTTP请求方式中get和post的区别
    如何使用NPM?CNPM又是什么?
    javascript通过navigator.userAgent识别各种浏览器
    用JS添加和删除class类名
    前端布局神器display:flex
    强大的display:grid
    自动化测试的那些事儿
    selenium家族发展史
    第八章、函数进阶之字典生成式与匿名函数
  • 原文地址:https://www.cnblogs.com/QiuJL/p/4524295.html
Copyright © 2011-2022 走看看