[英]ASP .NET - RequiredFieldValidator creates space after textbox
I have a DetailsView with a number of textboxes setup with RequiredFieldValidators. 我有一个DetailsView,其中包含许多使用RequiredFieldValidators设置的文本框。
The code for both is: 两者的代码是:
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("date_time") %>'></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator11"
runat="server"
ControlToValidate="TextBox1"
ErrorMessage="Please update date_time."
ValidationGroup="InsertDetailsView1">*</asp:RequiredFieldValidator>
</InsertItemTemplate>
The problem is that the validation control is now creating a space (ie 问题是验证控件现在正在创建一个空间(即
) between the textbox and the one below it. )文本框和它下面的文本框之间。 How do I get rid of the space?
我如何摆脱空间? Is it a CSS thing?
它是CSS的东西吗?
设置此属性: Display="Dynamic"
。
您可以设置Display =“Dynamic”,只有在发生错误时才会显示消息。
You could set Display="Dynamic", but you will still end up wrapping once the validation error is triggered if you don't leave a space big enough for the error message next to the control. 您可以设置Display =“Dynamic”,但如果没有为控件旁边的错误消息留出足够大的空间,则在触发验证错误后仍然会结束。
I usually put a red asterisk in for the error text, and then I put the actual error text in the ErrorMessage and ToolTip attributes, then display the long error message using a validation summary control. 我通常在错误文本中放入一个红色星号,然后我将实际的错误文本放在ErrorMessage和ToolTip属性中,然后使用验证摘要控件显示长错误消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.