<asp:IE8+ 中的按钮文字乱七八糟

<asp:Button text jerks in IE8+

按钮内的文本突然跳动或向下移动几个像素。

<div>
<asp:Button runat="server" ID="Button1" CssClass="ButtonClass" Text="" runat="server" />
</div>

ascx.cs:

Button1.Text = LocalizationResourceManager.GetLocalizedValue("Button_Text");

CSS:

.ButtonClass{
 background: url('/Button.png') no-repeat scroll 0 0 transparent;
 cursor: pointer;
 font-weight: bold;
 font-size: 14px;
 height: 33px;
 padding-bottom: 7px;
 padding-right: 19px;
 width: 180px;
 border: solid 0px;
 color: #fff!important;
 background-position: 0px -31px;
}

但是,如果有 <span>,我可以使用:

{position:relative;top;0;left:0;}

因为 span 不能在 asp:button 内部使用,我想修复这个按钮本身。

我试过了:

<asp:LinkButton ID="Button1" runat="server" CssClass="ButtonClass">
    <span runat="server" id="ButtonText"></span>
</asp:LinkButton>

ascx.cs:

 ButtonText.text = LocalizationResourceManager.GetLocalizedValue("Button_Text");

我有错误: Error 9 'System.Web.UI.HtmlControls.HtmlGenericControl' does not contain a definition for 'text' and no extension method 'text' accepting a first argument of type 'System.Web.UI.HtmlControls.HtmlGenericControl' could be found (are you missing a using directive or an assembly reference?)

我在这里错过了什么?

不确定你 CSS 是否真的应用于按钮,但如果你想在按钮内使用 span 为什么不将你的控件更改为链接按钮,如下所示:

<asp:LinkButton ID="Button1" runat="server" CssClass="Button1">
<span>Register 2</span>
</asp:LinkButton>

编辑:

<asp:LinkButton ID="Button1" runat="server" CssClass="Button1">
<span>
<asp:Label ID="ButtonText" runat="server" ></asp:Label>
</span>
</asp:LinkButton>

我认为这对你有用。