I know the easy solution would be to make the label a textbox with multiline but this does not solve the problem since I want to render anchor tags inside the text value. For example:
<asp:Label ID='myLabel' runat="server" Text=" This is my label etc... go
here <a href='Destn.aspx'>Here</a> to update" />
This can't be done by using a textbox since a textbox will not display the anchor tag as a link instead it will display as plain text
Property Value True if the label control is multiline; otherwise, False. A multi-line label control renders the label's text on more than one line. If the WordWrap property is set to True, long lines will be wrapped to the following line.
We can also use a Panel control to create a multiline label in C#. We can place the desired label inside a panel and then handle the ClientSizeChanged event for the panel. The ClientSizeChanged event is invoked whenever the size of a control inside the panel changes. We can resize the label with the Label.
Set Property "WordWrap = True" for Label control, it will wrap to the nextline for the new word . It will not cut the word in between, unless the word length is bigger than the physical length of the Label..
<asp:Label
ID='myLabel'
runat="server"
style="word-wrap:break-word;"
Width="140px"
Text=" This is my label etc... go here <a href='Destn.aspx'>Here</a> to update" />
Add width property and provide any appropriate value whatever you want and add one css style which will wrap the word
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With