You must Sign In to post a response.
  • Category: ASP.NET

    How to line break to asp button text

    Dear All,


    how to line break to asp button text
  • #750637
    Hi,

    I never tried this use below snippet for the same

    Btn.text="hi"+<br/>+"hello";

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #750644
    you can do that by setting width and css property. see below code:


    <style type="text/css">
    .wrap { white-space: normal; width: 100px; }
    </style>
    <asp:Button ID="button1" runat="server" Text="some text to wrap" CssClass="wrap" />


    hope this helps you.

    If it helps you then Rate this.

    Best Regards,
    Manoranjan Sahoo
    http://www.dotnetsquare.com
    Blog: http://blog.msahoo.net

  • #750650
    Check out the below code it works in both Google Chrome and Mozilla firefox browser but it does not work in Internet Explorer.

    <asp:Button runat="server" id="btn" Text="hello

    hi
    hi" />


    Here it displays the hi text twice in separate lines with a line break.

    Miss. Jain
    Microsoft Certified Technology Specialist in .Net

  • #750661
    hi
    venkat
    Try this code

    <asp:Button ID="btnDateTime1" runat="server" Text="Display Date Time" />
    <br/>
    <asp:Button ID="Button2" runat="server" Text="Display Date Time" />
    <br/>
    <asp:Button ID="Button3" runat="server" Text="Display Date Time" />

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #750673
    Hi,

    You can use buttonid.text property and can use <br/> for this like below-

    <asp:Button ID="Button1" runat="server" />
    Button1.text=//your text

    Thanks,
    Ashutosh Jha
    http://tricksroad.com

  • #750676
    Hello venkat,

    Use word-wrap property with break-word in class
    I have posted snippet for you ,try it

    <asp:Button ID="btnSubmit" runat="server" Text="SOME TEXT TO SUBMIT BUTTON" CssClass="btnClass"/>

    CSS code

    <style>
    .btnClass {
    word-wrap: break-word;
    width: 90px;
    }
    </style>

    If you have still an issue than i'll getback to you.

    Regards,
    Nirav Prabtani (Senior Web Developer)
    Email : niravjprabtani@gmail.com
    blog : niravprabtani.blogspot.in

  • #750681
    Have you tried HTML button \n does the task for you
    see below snippet

    <input type='submit' value='my \n button'>
    OR
    <input type="submit" value='top &#10; bottom'>

    You can use carriage return characters to break the line: but it support HTML 5 supporting browser only
    see below
    <input type="button" value="Really Tall Button">

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #765212
    If you are using ASP Button then add style to button as style="white-space:normal; padding:1px 2px 1px 2px;" and in code adjust space by html entity ( );

    e.g.
    btn1.text = Server.HtmlDecode("       Hello      This is my world");
    btn1.WIdth = 105;
    btn1.Height = 35;

    Hope this will work

  • #765213
    Please use HTML non breaking space code at the place of space in code. as much spaces that much add non breaking space.


  • Sign In to post your comments