- HTML code
<asp:Label ID="lb_show" runat="server" style="position:absolute; top: 196px; left: 88px; height: 16px; word-break:break-all"/></asp:Label>
- C# code
protected void btn_submit_Click(object sender, EventArgs e) { string message = string.Empty; try { int min = Convert.ToInt32(txt_start.Text); int max = Convert.ToInt32(txt_end.Text); for (int i = min; i <= max; i++) { for (int j = min; j <= i; j++) { message += string.Format("{0}*{1}={2} ", j, i, i * j); } message += "\r\n"; } } catch { message = "请输入正确数字"; } lb_show.Text = message; }
真纠结呀。。用一个lable不能换行了吗;
虽然可以用多个标签解决
------解决方案--------------------------------------------------------
<div style="width:500px;height:500px;word-break:break-all">
<asp:Literal ID="lbl_show" ... />
</div>
------解决方案--------------------------------------------------------
<asp:Label ID="lb_show" runat="server"
style="position:absolute; top: 196px; left: 88px; height: 16px; width:xxpx; display:inline-block; word-wrap:break-word; word-break:break-all; overflow:hidden;"/></asp:Label>
这里1.设置宽度
2.设置display
上面两个是必须的;
try above, good luck