Friday, 24 August 2012

Beginning .Net : Text wrapping into the multi line textbox in asp.net

There are situation in multi line textbox where you want to wrapping text in textbox and sometimes you not want to wrap text , that text type as it is.
We can achieve this using "Wrap" property. By Default it is true.

In textbox Wrapping means if you entered text more than width of the textbox it will automatically set cursor into next line. In unwrapping if you entered text more than width of the textbox there is one horizontal scrollbar appear below the textbox and your line is continued.

Here is example for this.
In this example you can see that we take two text boxes one is "Product Description" and Second is "Product Meta Description". And both this text boxes are multiline textbox.
In "Product Description" textbox we allow warp text in this textbox.
And in "Product Meta Description" textbox we do not allow wraping in text.

You can see in output that in "Product Description" textbox new line created without pressing enter or return key. In "Product Meta Description" textbox scrollbar is appear when entered more data.

ASPX Code :
        <table>
            <tr>
                <td>
                    Product Description :
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtProductDescription" TextMode="MultiLine" Wrap="true"
                        Height="120px" Width="250px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Product Meta Description :
                </td>
                <td>
                    <asp:TextBox runat="server" ID="txtProductMetaDescription" TextMode="MultiLine" Wrap="false"
                        Height="120px" Width="250px"></asp:TextBox>
                </td>
            </tr>
        </table>

Output : 
(To view original image , click on image)

Here is example for set Maximum characters length of multi line textbox. Click Here...
 
For Beginning .Net articles. Click Here...
 
Here is very useful .Net Tips.


Note : Give Us your valuable feedback in comments. Give your suggestions in this article so we can update our articles accordingly that.


No comments:

Post a Comment