添加无论是在asp.net按钮的图像和文字 [英] Adding an image and text both in asp.net button

查看:169
本文介绍了添加无论是在asp.net按钮的图像和文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一个解决方案,我可以添加图像和文本无论是在asp.net按钮。

I am looking for a solution where I will be able to add an image and text both in asp.net button.

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

我只能够指定文字的按钮,但我怎么可以添加一个形象,以及它?

I am only able to specify text to the button, but how can I add an image as well to it?

推荐答案

在默认情况下,ASP .NET不有一个按钮,可以在同一时间呈现图像和文字。但是,您可以通过两种方式实现。

By default, ASP .Net doesn't have a button which can render both image and text at the same time. However, you can achieve in two ways.

我preFER CSS,因为它重量轻,你可以风格它任何你想要的。

I prefer CSS because it is light weight, and you can style it whatever you want.

<style type="text/css">
    .submit {
        border: 1px solid #563d7c;
        border-radius: 5px;
        color: white;
        padding: 5px 10px 5px 25px;
        background-image: url(https://cdn.sstatic.net/stackoverflow/img/sprites.png?v=6);
        background-position-y: 465px;
        background-position-x: 5px;
        background-color: #563d7c;
    }
</style>

<asp:Button runat="server" ID="Button1" Text="Submit" CssClass="submit"/>

第三方控制

它的工作原理正确的开箱即用。但是,你不能轻易改变自己的风格。

Third Party Control

It works right out of the box. However, you cannot change their style easily.

使用如的Telerik RadButton 第三方控制。

最后但并非最不重要的,如果你愿意,你可以实现自己的自定义服务器控件。

这篇关于添加无论是在asp.net按钮的图像和文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆