如何在按钮中制作2行文本 [英] how to make 2 lines text in button

查看:61
本文介绍了如何在按钮中制作2行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好吧

i有固定大小的按钮,每个按钮都是动态设置的

我的问题:当文字很长时,按钮会切断它,

i希望在2行中创建长文本并重新调整大小以适应按钮

我的按钮代码

Hi all
i have buttons with fixed size and the text of each is dynamically set
my problem: when the text is long , the button cuts it,
i want to make the long text in 2 lines and re-size it to fit the button automatically
my button code

<asp:Button ID="btnSubCat1" runat="server" Text="Button" onclick="subCatClick"
                           Visible="False" Width="100px" Height="50px"/>



代码背后:


code behind:

btnSubCat1.Text = dr["NAME"].ToString();
               btnSubCat1.Visible = true;

推荐答案

作为SA解决方案的补充...

您可以在值内使用HTML实体输入标记的属性以打破行...

AS addition to SA's solution…
You can use HTML entities inside the value property of the input tag to break line...
<input type="button" value="Some&#13;&#10;Text"/>


HTML中至少有按钮的形式。在一种形式中,您可以使用break元素显示多行:

There are at least to forms of button in HTML. In one form, you can use the break element to show more than one line:
<button>First Line<br/>Second Line</button>



如果我不是很多错误,ASP.NET使用不同的形式(请检查):


If I'm not much mistaken, ASP.NET uses a different form of it (please check it up):

<input type="button" value="Some Text"/>



即使ASP.NET使用基于输入元素的第二种形式,您也可以使用第一种形式,以获得一些多行按钮文本,并直接处理点击通过Javascript。或者基于此HTML创建自己的ASP.NET控件。



作为奖励,您将了解ASP.NET和ASP.NET控件的实际工作方式。 :-)







解决方案3也可以使用,但不是很干净一,即使在实践中它可能(原文如此!)应该适用于所有平台。在我的评论中,我试图解释原因。
请参阅: http://en.wikipedia .org / wiki / End_of_line [ ^ ]。



-SA


Even if ASP.NET uses the second form based on input element, you can use the first form, in order to have some multiline button text, and handle the click directly via Javascript. Or create your own ASP.NET control based on this HTML.

As a bonus, you will get understanding of how ASP.NET and ASP.NET controls really work. :-)



Solution 3 will also work, but it is not quite clean one, even though in practice it probably (sic!) should work in all platforms. In my comment to it, I tried to explain why.
Please see: http://en.wikipedia.org/wiki/End_of_line[^].

—SA


解决方案

http://stackoverflow.com/questions/5268354/wrap-text-within-a-aspbutton [< a href =http://stackoverflow.com/questions/5268354/wrap-text-within-a-aspbuttontarget =_ blanktitle =New Window> ^ ]



感谢BELGIUMsky
the solution
http://stackoverflow.com/questions/5268354/wrap-text-within-a-aspbutton[^]

thanks for BELGIUMsky


这篇关于如何在按钮中制作2行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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