有时我的文本框渲染时没有样式
我有这个非常奇怪的问题。我有一些文本框的设置,其定义如下:
<table style="width: 100%; position: relative; top: -10px;">
<tr>
<td style="font-size: 9pt; text-align: left;">
<asp:TextBox ID="multiHandle2_1_BoundControl" BackColor="Transparent" BorderStyle="None"
Font-Size="9pt" runat="server" Width="30" Text="25" /><span style="position: relative;
left: -11px;">DKK</span>
</td>
<td style="font-size: 9pt; text-align: right; float: right;">
<asp:TextBox ID="multiHandle2_2_BoundControl" runat="server" Width="30" BackColor="Transparent"
BorderStyle="None" Font-Size="9pt" /><span style="position: relative; left: -5px;">DKK</span>
</td>
</tr>
</table>
现在,这几乎在任何时候都有效。但是,我使用输出缓存,并且多次遇到我看到我的网站时 HTML 呈现错误的情况。让我们看看渲染的 HTML。
当它呈现错误时(大约 95% 的情况下会发生),它只是删除我的文本框中的以下内容:
BackColor="Transparent" BorderStyle="None"
Font-Size="9pt" Width="30" Text="25"
这真的很奇怪,因为我可以看到这在大多数情况下都得到了完美的应用。
当它工作时,它会像这样呈现:
<table style="width: 100%; position: relative; top: -10px;">
<tr>
<td style="font-size: 9pt; text-align: left;">
<input name="ctl00$ctl00$ContentPlaceHolder1$LeftSidebar$Filters1$multiHandle2_1_BoundControl" type="text" value="149" id="ContentPlaceHolder1_LeftSidebar_Filters1_multiHandle2_1_BoundControl" style="background-color:Transparent;border-style:None;font-size:9pt;width:30px;" /><span style="position: relative;
left: -11px;">DKK</span>
</td>
<td style="font-size: 9pt; text-align: right; float: right;">
<input name="ctl00$ctl00$ContentPlaceHolder1$LeftSidebar$Filters1$multiHandle2_2_BoundControl" type="text" value="249" id="ContentPlaceHolder1_LeftSidebar_Filters1_multiHandle2_2_BoundControl" style="background-color:Transparent;border-style:None;font-size:9pt;width:30px;" /><span style="position: relative; left: -5px;">DKK</span>
</td>
</tr>
</table>
当它不工作时,它会像这样呈现(经常发生,但并不总是)。不同之处在于我输入的样式消失了。:
<table style="width: 100%; position: relative; top: -10px;">
<tr>
<td style="font-size: 9pt; text-align: left;">
<input name="ctl00$ctl00$ContentPlaceHolder1$LeftSidebar$Filters1$multiHandle2_1_BoundControl" type="text" value="13" id="ContentPlaceHolder1_LeftSidebar_Filters1_multiHandle2_1_BoundControl" /><span style="position: relative;
left: -11px;">DKK</span>
</td>
<td style="font-size: 9pt; text-align: right; float: right;">
<input name="ctl00$ctl00$ContentPlaceHolder1$LeftSidebar$Filters1$multiHandle2_2_BoundControl" type="text" value="249" id="ContentPlaceHolder1_LeftSidebar_Filters1_multiHandle2_2_BoundControl" /><span style="position: relative; left: -5px;">DKK</span>
</td>
</tr>
</table>
SO... ASP.NET - 这是怎么回事?这非常烦人;-)
I have this very strange problem. I have a setup with some Textboxes, which is defined as follows:
<table style="width: 100%; position: relative; top: -10px;">
<tr>
<td style="font-size: 9pt; text-align: left;">
<asp:TextBox ID="multiHandle2_1_BoundControl" BackColor="Transparent" BorderStyle="None"
Font-Size="9pt" runat="server" Width="30" Text="25" /><span style="position: relative;
left: -11px;">DKK</span>
</td>
<td style="font-size: 9pt; text-align: right; float: right;">
<asp:TextBox ID="multiHandle2_2_BoundControl" runat="server" Width="30" BackColor="Transparent"
BorderStyle="None" Font-Size="9pt" /><span style="position: relative; left: -5px;">DKK</span>
</td>
</tr>
</table>
Now, this works nearly at all times. However, I use output caching and I've experienced several times I see my site, and the HTML is rendered wrong. Let's look at the rendered HTML.
When it is rendered wrong (happens ~95% of the times), it is simply removing the following on my textbox:
BackColor="Transparent" BorderStyle="None"
Font-Size="9pt" Width="30" Text="25"
This is really strange, as I can see this is applied perfectly most of the times.
When it works, it is rendered like this:
<table style="width: 100%; position: relative; top: -10px;">
<tr>
<td style="font-size: 9pt; text-align: left;">
<input name="ctl00$ctl00$ContentPlaceHolder1$LeftSidebar$Filters1$multiHandle2_1_BoundControl" type="text" value="149" id="ContentPlaceHolder1_LeftSidebar_Filters1_multiHandle2_1_BoundControl" style="background-color:Transparent;border-style:None;font-size:9pt;width:30px;" /><span style="position: relative;
left: -11px;">DKK</span>
</td>
<td style="font-size: 9pt; text-align: right; float: right;">
<input name="ctl00$ctl00$ContentPlaceHolder1$LeftSidebar$Filters1$multiHandle2_2_BoundControl" type="text" value="249" id="ContentPlaceHolder1_LeftSidebar_Filters1_multiHandle2_2_BoundControl" style="background-color:Transparent;border-style:None;font-size:9pt;width:30px;" /><span style="position: relative; left: -5px;">DKK</span>
</td>
</tr>
</table>
When it doesn't work, it is rendered like this (happends quite often, however, not always). Difference is the styles on my input is GONE.:
<table style="width: 100%; position: relative; top: -10px;">
<tr>
<td style="font-size: 9pt; text-align: left;">
<input name="ctl00$ctl00$ContentPlaceHolder1$LeftSidebar$Filters1$multiHandle2_1_BoundControl" type="text" value="13" id="ContentPlaceHolder1_LeftSidebar_Filters1_multiHandle2_1_BoundControl" /><span style="position: relative;
left: -11px;">DKK</span>
</td>
<td style="font-size: 9pt; text-align: right; float: right;">
<input name="ctl00$ctl00$ContentPlaceHolder1$LeftSidebar$Filters1$multiHandle2_2_BoundControl" type="text" value="249" id="ContentPlaceHolder1_LeftSidebar_Filters1_multiHandle2_2_BoundControl" /><span style="position: relative; left: -5px;">DKK</span>
</td>
</tr>
</table>
SO... ASP.NET - what the is going on? This is extremely annoying ;-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如你所写的,这很奇怪,我确信“非常烦人”......我不知道为什么会发生这种情况,但你可以通过正确使用
css
来解决它。无需在元素上编写样式,只需给它一个
class
并将该类的样式定义放入您的css
文件中。As you wrote it's strange and I'm sure "extremely annoying"... I don't know why it's happening but you can solve it with proper use of
css
.Instead of writing the style on the element just give it a
class
and the style definition for that class put in your'scss
file.