Many ways of Wrapping a Long texts into Multiple lines in Asp.Net

vishalneeraj-24503
Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 3614
There are so many ways of wrapping a long texts into multiple lines to looks good and fit in all Browsers.

As it's required sometimes,to break long sentence into multiple lines to fit in a Gridview or Division tag or Span tag or any control like Label or Textbox.

Today We will see,how to wrap a long texts in many ways:-

1st way:-
Using Wrap property of Textbox control - It has a boolean value as True and False.If it's true then Texts will Break into new lines.

We can directly use Wrap property in a Textbox as shown below

For Example:
<asp:TextBox ID="txt_description" runat="Server" Wrap="true" TextMode="MultiLine" Witdth = "200px"></asp:TextBox>

<asp:Label Width="350px" runat ="server" Style="wrap:true;" />

2nd way:-
Using word-wrap style property :-
Here,we have to give word-wrap:break-word in style property

For Example:
<asp:Label Text="abcdef ghijk lmnopqrst uvwxyzabcdef ghijk lmnopqrst uvwxyzabcdef ghijk lmnopqrst uvwxyz" Width="350px" runat ="server" Style="word-wrap:break-word;" />


3rd way:-
Using word-break style property:-
Here,we have to give word-break:break-all in style property

For Example:
<asp:Label Text="abcdef ghijk lmnopqrst uvwxyzabcdef ghijk lmnopqrst uvwxyzabcdef ghijk lmnopqrst uvwxyz"
Width="350px" runat ="server" Style="word-break:break-all;" />

<asp:TextBox ID = "txt_description" runat = "Server" Style="word-break:break-all;" TextMode="MultiLine" Witdth = "200px"></asp:TextBox>

Comments or Responses

Login to post response