开发者

Set the number of rows dynamically for multiline text box

I am entering some random text with space and in a text box during insert mode. Now in view mode I want to see those text as it was entered. For that I am using multiline text box and setting its border=none as he text should look like as it is label. I dont want to see any scroll bars. So I set column property=50 开发者_运维问答and assigning rows dynamically but still its not working. Here is the comments that I have inserted "Testing commentsghgjhgvhgvhgvkhbvfjsghksjnlksnvs;vmns;lkfgnskljgklk lkj;lkjlkjlk lkj'lkj

sdfgsg

dfg"

The code is as below

txtComments.Rows = (int)Math.Ceiling((double)dtSky.Rows[0]["Comments"].ToString().Length / 50);

txtComments.Text = dtSky.Rows[0]["Comments"].ToString();

How can I do this? I can use lable as per requirements....


You say I want to see the text as it was entered.. as a label. For this you shouldn't use a textbox with no border but a html element more suited to displaying text. Either a div or a span or just a plain p.

To render a div in asp.net you could use an asp:literal with some html wrapping it

<div>
    <asp:Literal ID="commentsLiteral" runat="Server"></asp:Literal> 
<div>

in your code behind

commentsLiteral.Text = dtSky.Rows[0]["Comments"].ToString();

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜