为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

C#
忽然笑 2021-06-11 15:43:03
我对文本框字符串 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"
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 116 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信