普通防爆pression验证 - 显示块,而不是行内动态时 [英] Regular Expression Validator - display block rather than inline when dynamic
问题描述
有没有什么办法让一个RegularEx pressionValidator使用的显示渲染本身:块,而不是显示:内联在它的样式属性,设置显示属性时,以显示=动态
Is there any way to make a RegularExpressionValidator render itself using display:block, instead of display:inline in its style attribute, when setting the Display property to "Display='Dynamic'"?
我曾尝试在样式表的设置,但是当它在网页上呈现这个被覆盖。
I have tried setting it in the stylesheet but this gets overwritten when it is rendered on the page.
感谢
推荐答案
以上使用了CSS的想法!重要的是如此接近,我可以品尝它。使用这种想法和CSS属性选择,我做到了。我不得不使用包含选择器来获得它在FF工作,但现在我已经在IE10,FF和Chrome测试它,到目前为止,这是工作。这是非常简单的。这里是一个样本验证器在我的aspx页面
The idea above on using a css with !Important was so close I could taste it. Using that idea and CSS attribute selectors I did it. I had to use the "contains" selector to get it working in FF, but now I have tested it in IE10, FF and Chrome and so far it is working. It is really simple. Here is a sample validator in my aspx page
<asp:RequiredFieldValidator runat="server" ID="rfvRequired" ErrorMessage="This is required.<br/>This is line 2" ControlToValidate="tbRequired" ValidationGroup="CommonAttributesValidationGroup" SetFocusOnError="True" CssClass="valerror" Display="Dynamic"></asp:RequiredFieldValidator>
接下来,我有一个valerror风格。
Next I have a style for valerror.
span.valerror[style*="inline"]
{
display:block !Important;
background-color: Yellow;
border: 1px solid #cccccc;
font-size:.9em;
}
这是它。它的工作原理:当跨度改变从样式显示:无到显示:内联在跨度踢和力量属性选择它是一个块。你只需要做出像上面一一的CSS项,并确保你的每个验证该类。
That is it. how it works: when the span changes the style from "display:none" to "display:inline" the attribute selector on the span kicks in and forces it to be a block. You just need to make ONE css entry like the one above and make sure you make each validator that class.
这篇关于普通防爆pression验证 - 显示块,而不是行内动态时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!