应用CSS到.NET的ImageButton [英] Applying CSS to .NET ImageButton
问题描述
我有以下的CSS,我可以申请到一个HTML输入标签。
I have the following CSS that I can apply to an HTML input tag.
#headerSearch
{
width: 265px;
}
#headerSearch .text
{
width: 215px;
}
#headerSearch #searchButton
{
background: url(../images/searchButton.png) no-repeat 0 0;
width: 36px;
border: 1px solid #ccc;
margin: 0;
}
#headerSearch #searchButton:hover
{
background: url(../images/searchButton.png) no-repeat 0 -28px;
}
和HTML,而我应用它...
And the HTML to which I apply it...
<div id="headerSearch" class="float">
<input id="txtSearch" class="text left" type="text" />
<input id="searchButton" class="submit right" type="submit" value="" />
</div>
这奇妙的作品。
It works wonderfully.
不过,我想是因为我想要的网页提交的ImageButton的行为(上升等,当你点击它,然后单击事件发生)来使用ImageButton控件,而不是输入标签的,但我不知道如何去用的ImageButton混合CSS。我试着像
However, I want to use an ImageButton control instead of the input tag because I want the page submit behavior of the ImageButton (which occurs when you click on it and click event is raised, etc.), but I am not sure how to go about mixing CSS with the ImageButton. I tried something simple like
<asp:ImageButton ID="ibtnSrch" runat="server" CssClass="searchBtn" onclick="ibtnSrch_Click" AlternateText="Search" />
但所发生的是图像显示器具有在白盒(默认图像丢失图标)红色X超过它的上面。
but what occurs is the image displays with a red X in a white box (the default image is missing icon) over top of it.
所以,更简洁,我该如何与.NET的ImageButton混合优雅CSS?
推荐答案
总之我不会用asp的图像按钮。
In short I would not use the asp image button.
我会用你目前的HTML控件,然后添加一些JavaScript点击一个隐藏的asp:Button控件,当你提交的输入点击
I would use your current html controls and then add some javascript to click a hidden asp:Button control when your submit input is clicked.
<div id="headerSearch" class="float">
<input id="txtSearch" class="text left" type="text" />
<input id="searchButton" class="submit right" type="submit" value="" onclick="<% hiddenSearch.ClientID %>.click();" />
<asp:Button ID="hiddenSearch" runat="server" style="display:none;" />
</div>
我不太记得,如果这是正确的语法来获取客户端ID ...
I don't quite recall if that is the correct syntax to get the client id...
这篇关于应用CSS到.NET的ImageButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!