How can I set button text on multiple lines in C # from aspx.cs page?
I have a button in my project, the text of which I set via the aspx.cs page. Here is the button code
<asp:Button ID="btnEmailRequestSummary" runat="server" OnClick="btnEmailRequestSummary_OnClick" />
Here is the code from the aspx.cs page
if (//condition)
{
btnEmailRequestSummary.Text = "Generate & Email - Request Summary";
}
else
{
btnEmailRequestSummary.Text = "Generate Request Summary";
}
I need the word "Summary", which will appear on the next line. I tried to use <br />
, \n
as well as the ASCII value for <br />
and \n
, but no luck.
source to share
EDIT: as pointed out in the comment, this solution may not work in some browsers, please use CSS to achieve this as suggested here
declare this CSS class:
<style type="text/css">
.wrap { white-space: normal; width: 100px; }
</style>
Then in code:
btnEmailRequestSummary.Attributes.Add("class", "wrap ")
This may work in some browsers,
btnEmailRequestSummary.Text = "Generate Request 
 Summary";
[ampersandHash010;] a character entity usually gives a newline in the button text. Please refer to this link for more symbol references:
Hope it helps.
source to share