In every AspDotNetStorefront site, there is a contact form page that visitors can use to send you a message.
This is set up as a topic, and you can find it by going to www.yourdomain.com/t-contact.aspx.
This page can be modified through the HTML editor just like any other topic by going to Content > Manage Topics in version 8.0 or Misc > Topics in earlier versions.
Here, you can make any changes you like to the layout of the page, but what about modifying the actual email you get in your inbox when the contact form is submitted?
Unfortunately, there’s no HTML editor for that. Luckily, we found a great feature built right into AspDotNetStorefront that allows you to customize the contact form! Without this feature, you’ll still get your contact form results in your inbox, but using this feature will allow you to change the way it’s displayed.
This is especially useful for quoting the original message in an email response to the visitor, but if you don’t want those extra strange form tags to show up. What’s a ‘B1′? Who knows…let’s get rid of it!
This tutorial will show you how to turn this:
Name=Nicole Swan
Phone=541-201-9965
EMail=nicole@vortx.com
Subject=Contact Form Submit Test
S1=This is a test message submitted from the Contact Us page.
B1=Submit
into this:
Name: Nicole Swan
Phone Number: 541-201-9965
Email: nicole@vortx.com
Subject: Contact Form Submit Test
Message: This is a test message submitted from the Contact Us page.
This tutorial requires a basic knowledge of HTML and XML Packages. If you know a little HTML but you’re not familiar with XML Packages, read on! This tutorial will help you get to know them.
So, what’s an XML Package? Your AspDotNetStorefront site uses XML Packages for a variety of functions that you would not be able to live without. Your category and product pages need them to display content, your search function uses it to display results, your news, minicart, & customer receipts all depend on them as well.
With this tutorial, you will use an XML Package to control the form results sent from your contact page.
- Log in to your admin site, and head over to the AppConfig Parameters. This is located in the Configuration > Advanced menu in AspDotNetStorefront 8.0 or in the Misc menu in earlier versions.
- In the top left, under the “Add New” heading, you’ll see two fields for “Config Name” and “Config Value”, followed by a drop-down box.
- In the Config Namefield, type in ‘SendForm.XmlPackage’.
- In the Config value field, type in ‘notification.contactform.xml.config’
- In the drop-down menu, select XMLPACKAGE
Now, you should have a brand new AppConfig Parameter called SendForm.XmlPackage with a value set to notification.contactform.xml.config. This means your AspDotNetStorefront site will now look for the XML Package ‘notification.contactform.xml.config’ and use that to control the layout of the form results. So let’s go create that XML Package!
- Open the XML Packages folder in the root of your site.
- Open the notification.newmemberwelcome.xml.config file in your favorite text editor*.
- Save this file as ‘notification.contactform.xml.config’ in the XML Packages directory.
Now all we have to do is edit the file to display the results from the contact form, and not the new member welcome message. Let’s start at the top.
If your text editor shows line numbers, you’ll find displayname=”Welcome Email” on line number 2. Change “Welcome Email” to something a bit more accurate, like “Contact Inquiry Form.” The rest of the information on line 2 can stay the same.
Now go down to line 19. This is the template. This is the actual content that will be displayed in the email. Since we don’t want the new member welcome email to be sent out, let’s delete everything in between the <xsl:template match=”/”> and </xsl:template> tags.
Your XML Package should now look something like this:
<?xml version="1.0" encoding="utf-8" ?>
<package displayname="Contact Inquiry Form" version="2.1" debug="false">
<!-- ############################################ -->
<!-- Copyright AspDotNetStorefront.com, 1995-2008. All Rights Reserved. -->
<!-- http://www.aspdotnetstorefront.com -->
<!-- For details on this license please visit the product homepage at the URL above. -->
<!-- THE ABOVE NOTICE MUST REMAIN INTACT. -->
<!-- -->
<!-- ############################################ -->
<PackageTransform>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
<xsl:output method="html" omit-xml-declaration="yes" encoding="ISO-8859-1" />
<xsl:param name="LocaleSetting" select="/root/Runtime/LocaleSetting" />
<xsl:param name="WebConfigLocaleSetting" select="/root/Runtime/WebConfigLocaleSetting" />
<xsl:param name="StoreURL"><xsl:value-of select="/root/Runtime/StoreUrl" /></xsl:param>
<xsl:param name="StyleURL"><xsl:value-of select="$StoreURL" />skins/skin_<xsl:value-of select="aspdnsf:SkinID()" />/style.css</xsl:param>
<xsl:template match="/">
</xsl:template>
</xsl:stylesheet>
</PackageTransform>
</package> Now, we just need to put the form contents in between the <xsl:template match=”/”> and </xsl:template> tags. First let’s lay the groundwork. On the contact page, you have 5 fields to display:
- Name
- Phone Number
- Subject
- Message
So in the template in the XML Package, list those fields, and leave some space for the results to follow. This should look something like this:
<b>Name:</b>
<br />
<b>Phone Number:</b>
<br />
<b>Email Address:</b>
<br />
<b>Subject:</b>
<br />
<b>Message:</b>For every form field in the contact page, we want to display the results in the email. Each form field has several attributes, one of which is “name”. If you view the source of your t-contact.aspx page, you can find the ‘name’ attribute for each form tag. This is what we’ll need to display the results of the form.
Below, I’ve listed the form fields and their corresponding ‘name’ attributes as they are in the out of the box contact form.
Name – ‘name’
Phone Number – ‘phone’
Email – ‘email’
Subject – ’subject’
Message – ’s1′
As you can see, the AspDotNetStorefront programmers made it pretty easy for us to figure out what is what. Now in the XML Package, let’s add these values. We’ll do this with the value-of element in XSLT.
<b>Name:</b> <xsl:value-of select="/root/Form/name" />
<br />
<b>Phone Number:</b> <xsl:value-of select="/root/Form/phone" />
<br />
<b>Email Address:</b> <xsl:value-of select="/root/Form/email" />
<br />
<b>Subject:</b> <xsl:value-of select="/root/Form/subject" />
<br />
<b>Message:</b> <xsl:value-of select="/root/Form/s1" />
Now save your document and test it out! You can easily apply further modifications, just treat the <xsl:template> area of the XML Package like an HTML page. You can add HTML tags, & CSS styles to every element displayed. If you’d like to add your company logo at the bottom of the message, or a special coupon code for visitors sending inquiries, just add the text or image content wherever you’d like it to appear.
You can also add and remove form elements on the contact page, and display them on the page, just make sure your form fields each contain a unique ‘name’ attribute, and apply that with the value-of element in your Xml Package.
*All custom development of AspDotNetstorefront by Vortx is done with Microsoft Visual Studio. You can download the express edition here. You can also use any text editor such as notepad or wordpad, which both come with the Windows operating system. You can also use Notepad++ or Textpad, which are lightweight versions of Visual Studio, but heavyweight versions of notepad.
Written by Nicole
Tags: AspDotNetStoreFront, Contact Emails, XML



















is your expert

Captivate your audience and showcase your brand with our
Are you just starting your online business? Did you have a pre-exisiting site and have recently converted to the AspDotNetStoreFront platform? Try our economical design solution with
Increase conversions by up to 145%. Studies show that making the right changes to your site can increase your conversion rate by as much as 145%!
January 26th, 2009 at 11:59 pm
excellent..!! excellent post and help i have ever seen for ASPDNSF application. Just THE SAME what i want to have!! 1000 thanx to you buddy!!
March 30th, 2009 at 3:35 pm
[...] you may want to change the formatting of the emails you receive from the form. Take a look at this post for instructions on changing the appearance of contact form emails. Written by [...]
April 13th, 2009 at 4:32 pm
Hey – must have missed a step – i’m getting the formatting of the contact message correctly, but none of the content. No name, email or phone number is included in the email i receive after filling out the contact form. Any ideas?
thanks
April 13th, 2009 at 4:36 pm
First, set your Xml Package to debug=true, then run a test form through the site. Check your email, and there should be a bunch of Xml just below the contact form. Check each Xml node that you’re referencing in the form, and make sure it has content…for example, root > Form > name should have the name you put in the contact form. If root > Form > name does not exist, try and find whatever content you put in the form as a test, and see if it exists under another node.
Another thing to check for is case sensitivity. The latest ADSNF releases need to have the exact case used or it will not work, i.e. /root/Form/name is not the same as /root/Form/Name.
April 13th, 2009 at 8:39 pm
Hi
it was a case problem, but in an odd way. On the form, the fields were Name, Phone, EMail, etc. I set the case in the xml package to match the form – no luck. I then changed the field names in the form to all lower case (name, phone, email) and re-set the xml package to match that – and that worked. i don’t understand why that would be the case, but i can move on.
This is ASPDNSF ML 7.1.1.0. thanks for the advice.
October 12th, 2009 at 10:11 am
How do I get to the value of a dropdown selection with the xsl statement?
xsl:value-of select=”/root/Form/natureofrequest
nature of request is a select element in the form with three selection options:
General Inquiry
Order Status
Return