Reputation: 353
I am having a button in my project whose text I am setting through aspx.cs page. Here is code of button
<asp:Button ID="btnEmailRequestSummary" runat="server" OnClick="btnEmailRequestSummary_OnClick" />
Here is code from aspx.cs page
if (//condition)
{
btnEmailRequestSummary.Text = "Generate & Email - Request Summary";
}
else
{
btnEmailRequestSummary.Text = "Generate Request Summary";
}
I need a 'Summary' word to be appear on next line. I tried using <br />
, \n
, and also ASCII values for <br />
and \n
but no luck.
Upvotes: 3
Views: 4276
Reputation: 625
You may try this CSS:
white-space: pre;
width: 60px;
word-wrap: break-word;
With the exact text for the button being:
string.Format("Generate & Email - Request {0} Summary", Environment.NewLine);
NOTE: the spaces before and after the Environment.NewLine
Upvotes: 0
Reputation: 6153
EDIT : As pointed in comment this solution might not work on 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 the code-behind:
btnEmailRequestSummary.Attributes.Add("class", "wrap ")
This might work on some browsers,
btnEmailRequestSummary.Text = "Generate Request 
 Summary";
[ampersandHash010;] character entity normally gives the new line in Button Text. Refer this link for more Character Entity References:
Hope this helps.
Upvotes: 2