Line Break, Hard return Help?????

Last post 07-03-2008 1:47 AM by myreferencecode. 10 replies.

Sort Posts:

  • Hmm [^o)] Line Break, Hard return Help?????

    04-22-2005, 12:17 PM
    • Member
      110 point Member
    • HCPLconfused
    • Member since 03-31-2005, 8:43 PM
    • Posts 22

    Sad [:(]Can anyone tell me how to add a line break or hard return in the body of an e-mail text in an asp webform????

    Thanks!!!

  • Re: Line Break, Hard return Help?????

    04-22-2005, 1:25 PM
    • Member
      5 point Member
    • sdog
    • Member since 04-22-2005, 5:24 PM
    • Posts 1

    i believe all your looking for is 'vbcrlf' 

    text="bla blab bla " & vbcrlf & "2nd line bla bla bla"

     

  • Re: Line Break, Hard return Help?????

    04-22-2005, 1:32 PM
    • Member
      700 point Member
    • Jeremy123
    • Member since 11-30-2004, 3:47 PM
    • Posts 136

    in your mail.mailmessage object set the MailMessage.BodyFormat = Mail.MailFormat.Html then in the mail message you can add a <br />, or if your formatting the message from the code behind you can use any of the VB formatting strings like vbNewLine or vbCrLf or in C# use the \n character.

  • Re: Line Break, Hard return Help?????

    04-22-2005, 2:07 PM
    • Member
      110 point Member
    • HCPLconfused
    • Member since 03-31-2005, 8:43 PM
    • Posts 22

    I have tried that command and it does not take it to another line.  Here is a copy of part of the code.  Where it is highlighted is where I am trying to add a line break.  What am I doing wrong?Confused [*-)]

    mailMessage.Body = "<strong>First Name:</strong> " + FirstName.Text + " Last Name: " + LastName.Text & vbcrlf & "<strong>Address:</strong> " + Address.Text

    Thanks!!!

  • Super Angry [8o|] Re: Line Break, Hard return Help?????

    04-22-2005, 2:35 PM
    • Member
      110 point Member
    • HCPLconfused
    • Member since 03-31-2005, 8:43 PM
    • Posts 22

    I HAVE TRIED THAT AND NONE OF THOSE COMMANDS WORK.  What am I doing wrong?  Here is what the whole thing looks like. 

    <%@ Page Language="VB" %>
    <script runat="server">

        ' Insert page code here
        '

        Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs)

        End Sub

        Sub Button1_Click(sender As Object, e As EventArgs)

        ' Build a MailMessage
        Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
        mailMessage.From = "hcplpatron@hcpl.org"
        mailMessage.To = "cbowman@hcpl.org"
        mailMessage.Subject = "Email Subject"
        mailMessage.BodyFormat = System.Web.Mail.MailFormat.Html

        mailMessage.Body = "<strong>First Name:</strong> " + FirstName.Text + " Last Name: " + LastName.Text & _ vbNewLine "<strong>Address:</strong> " + Address.Text

        System.Web.Mail.SmtpMail.SmtpServer = "mail.lightpower.net"
        System.Web.Mail.SmtpMail.Send(mailMessage)

        End Sub

        Sub FirstName_TextChanged(sender As Object, e As EventArgs)

        End Sub

    </script>
    <html>
    <head>
    </head>
    <body>
        <form runat="server">
            <p>
                <strong>First Name</strong>
                <asp:TextBox id="FirstName" runat="server" AutoPostBack="True" OnTextChanged="FirstName_TextChanged" Width="113px"></asp:TextBox>
                &nbsp; Last Name<asp:TextBox id="LastName" runat="server"></asp:TextBox>
            </p>
            <p>
                Address<asp:TextBox id="Address" runat="server" Width="298px"></asp:TextBox>
            </p>
            <p>
                City
                <asp:TextBox id="City" runat="server"></asp:TextBox>
                &nbsp; State
                <asp:DropDownList id="State" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                    <asp:ListItem Value="Please Select a State">Please Select a State</asp:ListItem>
                    <asp:ListItem Value="IN">IN</asp:ListItem>
                    <asp:ListItem Value="IL">IL</asp:ListItem>
                    <asp:ListItem Value="TN">TN</asp:ListItem>
                    <asp:ListItem Value="VA">VA</asp:ListItem>
                    <asp:ListItem></asp:ListItem>
                    <asp:ListItem Value="KY">KY</asp:ListItem>
                </asp:DropDownList>
                &nbsp;&nbsp; Zip Code
                <asp:TextBox id="ZipCode" runat="server" Width="106px"></asp:TextBox>
            </p>
            <p>
            </p>
            <p>
            </p>
            <p>
                <input type="submit" value="Submit" />
            </p>
            <p>
            </p>
            <p>
                <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button>
            </p>
            <!-- Insert content here -->
        </form>
    </body>
    </html>

     

  • Re: Line Break, Hard return Help?????

    04-22-2005, 3:31 PM
    • Contributor
      2,652 point Contributor
    • dotnetrook
    • Member since 10-11-2004, 7:18 PM
    • Memphis, TN
    • Posts 529
    Use \n and see how it works.
    Rules at work:
    1) Boss is always right
    2) If Boss is wrong; refer rule #1
  • Angry [:@] Re: Line Break, Hard return Help?????

    04-22-2005, 3:40 PM
    • Member
      110 point Member
    • HCPLconfused
    • Member since 03-31-2005, 8:43 PM
    • Posts 22

    No luck with the  n/.  I have tried vbcrlf, nbsp, n/, and br.  Is there something seriously wrong with my setup or something?

    Please Help!!

  • Re: Line Break, Hard return Help?????

    04-22-2005, 3:53 PM
    • Contributor
      2,575 point Contributor
    • rx
    • Member since 08-29-2003, 10:16 PM
    • Los Angeles, CA
    • Posts 515
    Have you tried what jeremy123 suggested? (using <BR> should work, I have used it many times)
    Richard Xin
    MCAD(charter member),MCDBA,MCSD
    Web Site: www.richardxin.com (For ASP.Net tips and Code snippet)
  • No [Nope] Re: Line Break, Hard return Help?????

    04-23-2005, 10:11 AM
    • Member
      110 point Member
    • HCPLconfused
    • Member since 03-31-2005, 8:43 PM
    • Posts 22

    Yes I tried what Jeremy123 suggested, Still nothing, that is why I was wondering if there was something wrong in my code that was preventing these other little formatting tips from working.  I am getting at my wits end. 

     

  • Re: Line Break, Hard return Help?????

    04-23-2005, 12:31 PM
    • Contributor
      2,652 point Contributor
    • dotnetrook
    • Member since 10-11-2004, 7:18 PM
    • Memphis, TN
    • Posts 529
    I am not sure if you have typo in your message. It should be \n and not n\.
    Rules at work:
    1) Boss is always right
    2) If Boss is wrong; refer rule #1
  • Re: Line Break, Hard return Help?????

    07-03-2008, 1:47 AM

    text="Ist line bla blab bla \r\n 2nd line bla bla bla"

     

    This will works better.

     

    Thanks!

    Rajaram

    Thanks!
    Rajaram
Page 1 of 1 (11 items)