如何在我的 for 循环中为文本框添加 css 类

我对文本框字符串 null 的验证有问题,我确实做了一个 for 循环来计算空文本框,但我的问题是如果我使用 for 循环,我将如何在空文本框上添加带有红色背景的 css 样式. 我已经有了 css 样式示例:(txtNumberOfDaysCovered.cssClass="form-control border-danger")


我的 for 循环:


 string[] countTextbox = new string[8];

 countTextbox[0] = txtEndDate.Text;

 countTextbox[1] = txtLessLeaveTaken.Text;

 countTextbox[2] = txtnumberOfDaysCovered.Text;

 countTextbox[3] = txtoperation.Text;

 countTextbox[4] = txtposition.Text;

 countTextbox[5] = txtStartDate.Text;

 countTextbox[6] = txtThissApp.Text;

 countTextbox[7] = txApprover.Text;


 for (int i = 0; i < countTextbox.Length; i++)

 {

     if (string.IsNullOrWhiteSpace(countTextbox[i]))

     {


         ValidationMessage.Text = "Please fill up all the required fields";

         ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", "<script>$('#modal_form_inline').modal('show');$('#modal_form_inline_Confimation').modal('hide');</script>", false);

                return;

     }


}

我只是不能简单地做这些 ff 代码: countTextbox[i].cssClass = "form-control border-danger"


忽然笑
浏览 117回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP