使用Switch和Case进行必要的字段验证 [英] Required Field Validation using Switch and Case

查看:119
本文介绍了使用Switch和Case进行必要的字段验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string selectedAction = ddlPatientStatus.SelectedValue;
         switch (ddlPatientStatus.SelectedValue)
         {
             case "4":
                 ddl_team_val.Enabled = true;
                 ddl_work_val.Enabled = true;
                 ddl_membership_val.Enabled = true;
                 ddl_status_val.Enabled = true;
                 ddl_documentstype_val.Enabled = true;
                 ddl_insurance_val.Enabled = true;
                 ddl_sex_val.Enabled = true;
                 ddl_income_val.Enabled = true;
                 ddl_location_val.Enabled = true;
                 goto case "8";
             case "9":
                 date_due_val.Enabled = true;
                 goto case "3";
             case "3":
                 ddl_Patient_val.Enabled = true;
                 goto case "2";
             case "2":
                 date_Procedure_val.Enabled = true;
                 goto case "8";
             case "1":
             case "5":
             case "6":
             case "7":
             case "8":
                 Comments_val.Enabled = true;
                 break;
             default:
                 break;
         }







我遇到问题4重复的问题本身适用于具有必需验证的所有其他DropDownList值。我需要找到一种方法来打破这个。




I am having issues with Case "4" repeating itself for all other DropDownList Values that have Required Validation. I need to figure out a way to break this.

推荐答案

而不是转到只需将所需的行放入您的案例

Instead of goto just put the required lines in your case :
case "2":
       date_Procedure_val.Enabled = true;
       Comments_val.Enabled = true;
       break;


这篇关于使用Switch和Case进行必要的字段验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆