Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sarah 7 posts 77 karma points
    Jan 30, 2017 @ 15:48
    Sarah
    0

    Help with User Control for Contact Form Submission

    I am very very new to asp.net, and I am trying to amend the layout of an email when a user submits a contact form. We have a user control in place that outputs each field in it's own row:

    ef.AddHeading("Contact Details"); ef.AddRow("Title", DdlTitle); ef.AddRow("First Name", TbFirstName); ef.AddRow("Last Name", TbLastName);

    What I am trying to do, with much difficulty, is put the title, first name and surname in one row, rather than 3.

    Please excuse my complete lack of knowledge, I am a php kinda person...

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jan 30, 2017 @ 20:39
    Alex Skrypnyk
    0

    Hi Sarah

    What version of Umbraco are you using?

    Why did you decide to use usercontrols?

    Thanks,

    Alex

  • Sarah 7 posts 77 karma points
    Jan 31, 2017 @ 08:58
    Sarah
    0

    Hi Alex, We are using Umbraco 4 - I know it's old - but we inherited the website a few years ago for hosting and maintenance and now my client needs some changes making to the email they receive on form submission.

  • David Peck 690 posts 1896 karma points c-trib
    Jan 31, 2017 @ 09:22
    David Peck
    0

    Pure guess with not enough information but try:

    ef.AddHeading("Contact Details"); 
    ef.AddRow("Name", string.Concat(DdlTitle, " ",  TbFirstName, " ", TbLastName));
    

    or

    ef.AddHeading("Contact Details"); 
    ef.AddRow("Name", string.Concat(DdlTitle.SelectedValue, " ",  TbFirstName.Text, " ", TbLastName.Text));
    

    or

    ef.AddHeading("Contact Details"); 
    ef.AddRow("Name", string.Concat(DdlTitle.Value, " ",  TbFirstName.Value, " ", TbLastName.Value));
    

    or versions there of

  • Sarah 7 posts 77 karma points
    Jan 31, 2017 @ 09:38
    Sarah
    0

    Hi David, Thanks so much for the pointers - just to check, could this also be ef.AddRow("Title", string.Concat(DdlTitle, "First Name", TbFirstName, "Last name", TbLastName));

  • David Peck 690 posts 1896 karma points c-trib
    Jan 31, 2017 @ 09:44
    David Peck
    0

    I don't know TBH. I'm guessing the first argument should be a label and the second is the actual value. I've edited my previous post to put "Name" as the first property.

  • Sarah 7 posts 77 karma points
    Jan 31, 2017 @ 13:44
    Sarah
    0

    The suggestion doesn't seem to have worked - there is no error on the form, but the name still display over 3 lines...I'm baffled! Any other ideas?

  • David Peck 690 posts 1896 karma points c-trib
    Jan 31, 2017 @ 13:59
    David Peck
    0

    A line like string.Concat(DdlTitle.SelectedValue, " ", TbFirstName.Text, " ", TbLastName.Text) will create a single string and so shouldn't be separated by lines. You're sure it is this code that is generating the 3 lines?

  • Sarah 7 posts 77 karma points
    Jan 31, 2017 @ 14:04
    Sarah
    0

    I think so - this is what I have at the moment in the ascx.cs:

    EmailFormatter ef = new EmailFormatter(true);

            string subject = "Quotation Request: " + reference;
    
            ef.AddHeading(subject);
            ef.AddParagraph(String.Format("The following quotation request was submitted to the website on {0}:", DateTime.Now.ToLongDateString()));
            ef.AddRow("Reference", reference);
            ef.AddHeading("Contact Details");
            ef.AddRow("Name", string.Concat(DdlTitle, " ",  TbFirstName, " ", TbLastName));         
            ef.AddRow("Job Title / Company", string.Concat(TbJobTitle, " ",  TbCompany));
            ef.AddRow("Address", TbAddress);
            ef.AddRow("Email", String.Format("<a href='mailto:{0}'>{0}</a>", HttpUtility.HtmlEncode(TbEmail.Text)), false);
            ef.AddRow("Telephone", string.Concat(TbPhone, " ", TbMobile));
            ef.AddRow("Fax", TbFax);
            ef.AddRow("Contact Preference", DdlContactMethod.SelectedValue);
            ef.AddHeading("Desired Rental Period");
            ef.AddRow("From Date", DateTime.Parse(TbFromDate.Text).ToString("dddd, dd MMMM yyyy"));
            ef.AddRow("To Date", DateTime.Parse(TbToDate.Text).ToString("dddd, dd MMMM yyyy"));
            ef.AddRow("Duration", String.Format("{0} Days", DateTime.Parse(TbToDate.Text).Date.Subtract(DateTime.Parse(TbFromDate.Text).Date).TotalDays));
            ef.AddHeading("Venue Details");
            ef.AddRow("Venue", string.Concat(TbVenue, " ", TbVenueLocation));
            string gmapLink = String.Format("<a href=\"http://maps.google.co.uk/maps?&amp;hl=en&amp;q={0}\" target=\"_blank\" title=\"View map\">{0}</a>", HttpUtility.HtmlEncode(TbVenuePostcode.Text));
            ef.AddRow("Venue Postcode", gmapLink, false);
            ef.AddRow("Additional Info", TbInfo);
    
            ef.AddHeading(String.Format("{0} Requested Vehicles", basket.QuantityCount));
    
            foreach (var vehicle in basket.GetVehiclesInBasket())
            {
                string details = String.Format("<a href=\"{0}{1}\" title=\"View Vehicles\">{2}</a>", ef.BaseUrl, HttpUtility.HtmlEncode(vehicle.NiceUrl), HttpUtility.HtmlEncode(vehicle.NodeName));
                ef.AddRow(String.Format("{0} x", vehicle.Quantity), details, false);
                try
                {
                    Connect.Helpers.Umbraco.Library.UpdateViewCount(vehicle.Id, 50);
                }
                catch { }
            }
    
    
    
            MailMessage message = new MailMessage();
            message.IsBodyHtml = ef.IsHtml;
            message.Subject = subject;
            message.Body = ef.EmailBody;
            message.To.Add(new MailAddress(this.EmailTo));
            message.ReplyTo = senderAddress;
    
            SmtpClient mailClient = new SmtpClient();
            mailClient.Send(message);
    
Please Sign in or register to post replies

Write your reply to:

Draft