ASP.Net 验证器样式

标签 asp.net .net css validation

我在一个文本框上有多个验证器(见下面的结构)。当 RequiredFieldValidator 通过但 CustomValidator 失败时,文本框和 CustomValidator 之间存在间隙,因为 RequiredFieldValidator 具有隐藏的 CSS 属性。

[FieldLabel] [TextBox] [RequiredFieldValidator] [CustomValidator]

验证器的 HTML 输出如下所示。

<input name="...Age" value="65" id="...Age" type="text">
<span id="...RequiredFieldValidator" style="color: rgb(195, 1, 185); visibility: hidden;">required</span>
<span id="...CustomValidator" style="color: rgb(195, 1, 185); visibility: visible;">must be between 55 and 74</span>

如何确保文本框和 CustomValidator 之间没有空格?

最佳答案

设置验证器的Display="Dynamic"属性

MSDN: ASP.NET Validation in Depth

关于ASP.Net 验证器样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3660665/

相关文章:

html - CSS - 背景停止

jquery - 单击图像时如何更改缩放图标?

css - 如何设置flex box item的高度100%

c# - 可折叠的主细节 GridView 结构

c# - 如何在.cs中的特定时间执行javascript?

c# - 总是添加一个空的事件处理程序可以吗?

c# - 如何在 C# 中向图标添加文本?

.net - 如何将 StringFormat 添加到 DataTemplate 内的 Textblock?

c# - 缓存键导致错误 "Negating the minimum value of a twos complement number is invalid."

asp.net - tinymce 在回发时获取 HTML 代码